void CInstrumentEditorN163::OnCloneSequence()
{
	CFamiTrackerDoc *pDoc = GetDocument();
	int FreeIndex = pDoc->GetFreeSequenceN163(m_iSelectedSetting);
	CSequence *pSeq = pDoc->GetSequence(SNDCHIP_N163, FreeIndex, m_iSelectedSetting);
	pSeq->Copy(m_pSequence);
	SetDlgItemInt(IDC_SEQ_INDEX, FreeIndex, FALSE);
}
示例#2
0
void MusicEditorForm::onSave()
{
   CDesignerEditorBase::onSave();

   CFamiTrackerDoc* pDoc = (CFamiTrackerDoc*)AfxGetMainWnd()->GetActiveDocument();

   pDoc->OnSaveDocument((TCHAR*)m_fileName.toAscii().constData()); 
   
   setModified(false);
}
示例#3
0
void CCommentsDlg::OnBnClickedOk()
{
	CMainFrame *pMainFrame = (CMainFrame*)GetParentFrame();
	CFamiTrackerDoc *pDoc = (CFamiTrackerDoc*)pMainFrame->GetActiveDocument();
	CString comment;

	GetDlgItemText(IDC_COMMENTS, comment);

	pDoc->SetComment(comment);

	EndDialog(0);
}
示例#4
0
void CFrameAction::Update(CMainFrame *pMainFrm)
{
	CFamiTrackerView *pView = (CFamiTrackerView*)pMainFrm->GetActiveView();
	CFamiTrackerDoc *pDocument = pView->GetDocument();

	switch (m_iAction) {
		case ACT_CHANGE_COUNT:
			pDocument->SetFrameCount(m_iNewFrameCount);
			pDocument->UpdateAllViews(NULL, CHANGED_FRAMES);
			break;
		// TODO add change pattern 
	}
}
示例#5
0
QMessageBox::StandardButton MusicEditorForm::onCloseQuery()
{
   QMessageBox::StandardButton doSave;
   
   doSave = CDesignerEditorBase::onCloseQuery();
   if ( doSave == QMessageBox::No )
   {
      // Need to nix the MFC modified flag.
      CFamiTrackerDoc* pDoc = (CFamiTrackerDoc*)AfxGetMainWnd()->GetActiveDocument();
   
      pDoc->SetModifiedFlag(FALSE);
   }
   
   return doSave;
}
示例#6
0
void CCreateWaveDlg::OnBnClickedBegin()
{
	RENDER_END EndType;
	int EndParam;

	CFamiTrackerDoc *pDoc = CFamiTrackerDoc::GetDoc();

	CString FileName = pDoc->GetFileTitle();

	CWavProgressDlg ProgressDlg;
	CFileDialog SaveDialog(FALSE, _T("wav"), FileName, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("Microsoft PCM files (*.wav)|*.wav|All files (*.*)|*.*||"));

	// Close this dialog
	EndDialog(0);

	// Ask for file location
	if (SaveDialog.DoModal() == IDCANCEL)
		return;
	
	// Save
	if (IsDlgButtonChecked(IDC_RADIO_LOOP)) {
		EndType = SONG_LOOP_LIMIT;
		EndParam = GetFrameLoopCount();
	}
	else if (IsDlgButtonChecked(IDC_RADIO_TIME)) {
		EndType = SONG_TIME_LIMIT;
		EndParam = GetTimeLimit();
	}

	CFamiTrackerView *pView = CFamiTrackerView::GetView();

	pView->UnmuteAllChannels();

	// Mute selected channels
	for (int i = 0; i < m_ctlChannelList.GetCount(); ++i) {
		if (m_ctlChannelList.GetCheck(i) == 0)
			pView->ToggleChannel(i);
	}

//	m_sFileName = SaveDialog.GetPathName();
	ProgressDlg.SetFile(SaveDialog.GetPathName().GetString());
	ProgressDlg.SetOptions(EndType, EndParam);
	ProgressDlg.DoModal();

	// Unmute all channels
	pView->UnmuteAllChannels();
}
void CInstrumentList::InsertInstrument(int Index)
{
	// Inserts an instrument in the list (Index = instrument number)
	CFamiTrackerDoc *pDoc = CFamiTrackerDoc::GetDoc();

	if (!pDoc->IsInstrumentUsed(Index))
		return;

	char Name[CInstrument::INST_NAME_MAX];
	pDoc->GetInstrumentName(Index, Name);
	int Type = pDoc->GetInstrumentType(Index);

	// Name is of type index - name
	CString Text;
	Text.Format(_T("%02X - %s"), Index, A2T(Name));
	InsertItem(Index, Text, Type - 1);
}
示例#8
0
BOOL CChannelsDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	m_pAvailableTree = (CTreeCtrl*)GetDlgItem(IDC_AVAILABLE_TREE);
	m_pAddedChannels = (CListCtrl*)GetDlgItem(IDC_ADDED_LIST);

	int RootItems = sizeof(ROOT_ITEMS) / sizeof(TCHAR);

//	m_pAddedChannels->GetWIndowLon

	m_pAddedChannels->InsertColumn(0, _T("Name"), 0, 150);

	for (int i = 0; i < ROOT_ITEM_COUNT; ++i) {
		HTREEITEM hItem = m_pAvailableTree->InsertItem(ROOT_ITEMS[i]);
		m_hRootItems[i] = hItem;
		for (int j = 0; CHILD_ITEMS[i][j] != NULL; ++j) {
			CString str;
			str.Format(_T("%i: %s"), j + 1, CHILD_ITEMS[i][j]);
			HTREEITEM hChild = m_pAvailableTree->InsertItem(str, hItem);
			m_pAvailableTree->SetItemData(hChild, CHILD_ITEMS_ID[i][j]);
		}
		m_pAvailableTree->SortChildren(hItem);
	}

	CChannelMap *map = theApp.GetChannelMap();

	CFamiTrackerDoc *pDoc = CFamiTrackerDoc::GetDoc();

	for (unsigned i = 0; i < pDoc->GetAvailableChannels(); ++i) {
		CTrackerChannel *pChannel = pDoc->GetChannel(i);
		AddChannel(pChannel->GetID());
	}
/*
	AddChannel(CHANID_SQUARE1);
	AddChannel(CHANID_SQUARE2);
	AddChannel(CHANID_TRIANGLE);
	AddChannel(CHANID_NOISE);
	AddChannel(CHANID_DPCM);
*/
	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
示例#9
0
BOOL CCommentsDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	CMainFrame *pMainFrame = (CMainFrame*)GetParentFrame();
	CFamiTrackerDoc *pDoc = (CFamiTrackerDoc*)pMainFrame->GetActiveDocument();
	CString comment = pDoc->GetComment();

	SetDlgItemText(IDC_COMMENTS, comment);

	CEdit *pEdit = (CEdit*)GetDlgItem(IDC_COMMENTS);

	CFont *pFont = new CFont();
	
	pFont->CreateFont(12, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, FONT_FACE);

	pEdit->SetFont(pFont);

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
示例#10
0
bool CChannelHandlerVRC6::HandleInstrument(int Instrument, bool Trigger, bool NewInstrument)
{
	CFamiTrackerDoc *pDocument = m_pSoundGen->GetDocument();
	CInstrumentContainer<CInstrumentVRC6> instContainer(pDocument, Instrument);
	CInstrumentVRC6 *pInstrument = instContainer();

	if (!pInstrument)
		return false;

	// Setup instrument
	for (int i = 0; i < CInstrumentVRC6::SEQUENCE_COUNT; ++i) {
		const CSequence *pSequence = pDocument->GetSequence(SNDCHIP_VRC6, pInstrument->GetSeqIndex(i), i);
		if (Trigger || !IsSequenceEqual(i, pSequence) || pInstrument->GetSeqEnable(i) > GetSequenceState(i)) {
			if (pInstrument->GetSeqEnable(i) == 1)
				SetupSequence(i, pSequence);
			else
				ClearSequence(i);
		}
	}

	return true;
}
示例#11
0
BOOL CCreateWaveDlg::OnInitDialog()
{
	CheckDlgButton(IDC_RADIO_LOOP, BST_CHECKED);
	CheckDlgButton(IDC_RADIO_TIME, BST_UNCHECKED);

	SetDlgItemText(IDC_TIMES, _T("1"));
	SetDlgItemText(IDC_SECONDS, _T("01:00"));

	m_ctlChannelList.SubclassDlgItem(IDC_CHANNELS, this);

	m_ctlChannelList.ResetContent();
	m_ctlChannelList.SetCheckStyle(BS_AUTOCHECKBOX);

	CFamiTrackerDoc *pDoc = CFamiTrackerDoc::GetDoc();

	for (int i = 0; i < pDoc->GetChannelCount(); ++i) {
		m_ctlChannelList.AddString(pDoc->GetChannel(i)->GetChannelName());
		m_ctlChannelList.SetCheck(i, 1);
	}

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
void CInstrumentEditDlg::SwitchOnNote(int x, int y)
{
	CFamiTrackerView *pView = CFamiTrackerView::GetView();
	CFamiTrackerDoc *pDoc = static_cast<CFamiTrackerDoc*>(static_cast<CFrameWnd*>(GetParent())->GetActiveDocument());
	CMainFrame *pFrameWnd = static_cast<CMainFrame*>(GetParent());
	int Channel = pView->GetSelectedChannel();		// // //
	int Chip = pDoc->GetExpansionChip();

	stChanNote NoteData { };

	// // // Send to respective channels whenever cursor is outside instrument chip
	if (m_iSelectedInstType == INST_2A03) {
		if (m_pPanels[0]->IsWindowVisible() && Channel > CHANID_NOISE)
			pView->SelectChannel(pDoc->GetChannelIndex(CHANID_SQUARE1));
		if (m_pPanels[1]->IsWindowVisible())
			pView->SelectChannel(pDoc->GetChannelIndex(CHANID_DPCM));
	}
	else {
		chan_id_t First = CHANNELS;
		switch (m_iSelectedInstType) {
		case INST_VRC6: First = CHANID_VRC6_PULSE1; break;
		case INST_N163: First = CHANID_N163_CH1; break;
		case INST_FDS:  First = CHANID_FDS; break;
		case INST_VRC7: First = CHANID_VRC7_CH1; break;
		case INST_S5B:  First = CHANID_S5B_CH1; break;
		}
		int Index = pDoc->GetChannelIndex(First);
		if (Index != -1 && pDoc->GetChipType(Index) != pDoc->GetChipType(Channel))
			pView->SelectChannel(Index);
	}
	Channel = pView->GetSelectedChannel();		// // //

	if (m_KeyboardRect.PtInRect({x, y})) {
		int KeyPos = (x - m_KeyboardRect.left) % 70;		// // //
		int Octave = (x - m_KeyboardRect.left) / 70;
		int Note;

		if (y > m_KeyboardRect.top + 38) {
			// Only white keys
			     if (KeyPos >= 60) Note = NOTE_B;
			else if (KeyPos >= 50) Note = NOTE_A;
			else if (KeyPos >= 40) Note = NOTE_G;
			else if (KeyPos >= 30) Note = NOTE_F;
			else if (KeyPos >= 20) Note = NOTE_E;
			else if (KeyPos >= 10) Note = NOTE_D;
			else if (KeyPos >=  0) Note = NOTE_C;
		}
		else {
			// Black and white keys
			     if (KeyPos >= 62) Note = NOTE_B;
			else if (KeyPos >= 56) Note = NOTE_As;
			else if (KeyPos >= 53) Note = NOTE_A;
			else if (KeyPos >= 46) Note = NOTE_Gs;
			else if (KeyPos >= 43) Note = NOTE_G;
			else if (KeyPos >= 37) Note = NOTE_Fs;
			else if (KeyPos >= 30) Note = NOTE_F;
			else if (KeyPos >= 23) Note = NOTE_E;
			else if (KeyPos >= 16) Note = NOTE_Ds;
			else if (KeyPos >= 13) Note = NOTE_D;
			else if (KeyPos >=  7) Note = NOTE_Cs;
			else if (KeyPos >=  0) Note = NOTE_C;
		}

		int NewNote = MIDI_NOTE(Octave, Note);		// // //
		if (NewNote != m_iLastKey) {
			NoteData.Note			= Note;
			NoteData.Octave			= Octave;
			NoteData.Vol			= MAX_VOLUME - 1;
			NoteData.Instrument		= pFrameWnd->GetSelectedInstrument();
			memset(NoteData.EffNumber, 0, 4);
			memset(NoteData.EffParam, 0, 4);

			theApp.GetSoundGenerator()->QueueNote(Channel, NoteData, NOTE_PRIO_2);
			theApp.GetSoundGenerator()->ForceReloadInstrument(Channel);		// // //
			m_iLastKey = NewNote;
		}
	}
	else {
		NoteData.Note			= pView->DoRelease() ? RELEASE : HALT;//HALT;
		NoteData.Vol			= MAX_VOLUME;
		NoteData.Instrument		= pFrameWnd->GetSelectedInstrument();;
		memset(NoteData.EffNumber, 0, 4);
		memset(NoteData.EffParam, 0, 4);

		theApp.GetSoundGenerator()->QueueNote(Channel, NoteData, NOTE_PRIO_2);

		m_iLastKey = -1;
	}
}
void CInstrumentEditDlg::SetCurrentInstrument(int Index)
{
	CFamiTrackerDoc *pDoc = CFamiTrackerDoc::GetDoc();
	std::shared_ptr<CInstrument> pInstrument = pDoc->GetInstrument(Index);
	int InstType = pInstrument->GetType();

	// Dialog title
	char Name[256];
	pDoc->GetInstrumentName(Index, Name);	
	CString Suffix;
	Suffix.Format(_T("%02X. %s (%s)"), Index, Name, CHIP_NAMES[InstType]);
	CString Title;
	AfxFormatString1(Title, IDS_INSTRUMENT_EDITOR_TITLE, Suffix);
	SetWindowText(Title);

	if (InstType != m_iSelectedInstType) {
		ShowWindow(SW_HIDE);
		ClearPanels();

		switch (InstType) {
			case INST_2A03: {
					int Channel = CFamiTrackerView::GetView()->GetSelectedChannel();
					int Type = pDoc->GetChannelType(Channel);
					bool bShowDPCM = (Type == CHANID_DPCM) || (std::static_pointer_cast<CInstrument2A03>(pInstrument)->AssignedSamples());
					InsertPane(new CInstrumentEditorSeq(NULL, _T("2A03 settings"), CInstrument2A03::SEQUENCE_NAME, 15, 3, INST_2A03), !bShowDPCM); // // //
					InsertPane(new CInstrumentEditorDPCM(), bShowDPCM);
				}
				break;
			case INST_VRC6:
				InsertPane(new CInstrumentEditorSeq(NULL, _T("Konami VRC6"), CInstrumentVRC6::SEQUENCE_NAME, 15, 7, INST_VRC6), true);
				break;
			case INST_VRC7:
				InsertPane(new CInstrumentEditorVRC7(), true);
				break;
			case INST_FDS:
				InsertPane(new CInstrumentEditorFDS(), true);
				InsertPane(new CInstrumentEditorFDSEnvelope(), false);
				break;
			case INST_N163:
				InsertPane(new CInstrumentEditorSeq(
					NULL, _T("Envelopes"), CInstrumentN163::SEQUENCE_NAME, 15, CInstrumentN163::MAX_WAVE_COUNT - 1, INST_N163
				), true);
				InsertPane(new CInstrumentEditorN163Wave(), false);
				break;
			case INST_S5B:
				InsertPane(new CInstrumentEditorSeq(NULL, _T("Sunsoft 5B"), CInstrumentS5B::SEQUENCE_NAME, 15, 255, INST_S5B), true);
				break;
		}

		m_iSelectedInstType = InstType;
	}

	for (int i = 0; i < PANEL_COUNT; ++i) {
		if (m_pPanels[i] != NULL) {
			m_pPanels[i]->SelectInstrument(pInstrument);
		}
	}

	ShowWindow(SW_SHOW);
	UpdateWindow();

	m_iSelectedInstType = InstType;
}
示例#14
0
void MainWindow::onIdleSlot()
{
   CFamiTrackerApp* pApp = (CFamiTrackerApp*)AfxGetApp();   
   CMainFrame* pMainFrame = (CMainFrame*)pApp->m_pMainWnd;
   CFamiTrackerDoc* pDoc = (CFamiTrackerDoc*)pMainFrame->GetActiveDocument();
   CFamiTrackerView* pView = (CFamiTrackerView*)pMainFrame->GetActiveView();
   static int lastFrame = -1;
   
   ui->sampleWindow->update();

   if ( m_bCheck )
   {
      // Move to next song if playing and the current song has reached a stop.
      if ( m_bCheck && m_bPlaying && !m_bChangeSong )
      {
         // Check if time is at time limit and if so, advance to next song.
         int timeLimit = m_pWndMFC->GetTimeLimit();
         CString playTime;
         int totalPlayTime;
         
         pMainFrame->GetDescendantWindow(AFX_IDW_STATUS_BAR)->GetDlgItemText(ID_INDICATOR_TIME,playTime);
         totalPlayTime = m_pWndMFC->ConvertTime(playTime);
         
         if ( lastFrame != pView->GetPlayFrame() )
         {
            lastFrame = pView->GetPlayFrame();
            m_iFramesPlayed++;
         }
         
         if ( m_bTimeLimited &&
              (timeLimit == totalPlayTime) )
         {
            // Force stop...
            m_bPlaying = false;
            pApp->OnCmdMsg(ID_TRACKER_TOGGLE_PLAY,0,0,0);
            m_bChangeSong = true;
            
            // Create a bit of a delay between songs.
            m_pTimer->start(500);
         }
         else if ( m_bLoopLimited &&
                   m_iFramesPlayed > pDoc->ScanActualLength(pDoc->GetSelectedTrack(),m_pWndMFC->GetFrameLoopCount()) )
         {   
            // Force stop...
            m_bPlaying = false;
            pApp->OnCmdMsg(ID_TRACKER_TOGGLE_PLAY,0,0,0);
            m_bChangeSong = true;
            
            // Create a bit of a delay between songs.
            m_pTimer->start(500);
         }
         if ( !pApp->GetSoundGenerator()->IsPlaying() )
         {
            m_bPlaying = false;
            m_bChangeSong = true;
            
            // Create a bit of a delay between songs.
            m_pTimer->start(500);
         }
      }
      // Wait until player starts playing before turning the above logic back on.
      else if ( m_bChangeSong )
      {
         on_playStop_clicked();
         if ( !ui->repeat->isChecked() )
         {
            on_next_clicked();
         }
         m_bChangeSong = false;
         ui->position->setValue((pView->GetPatternView()->GetPlayFrame()*pDoc->GetPatternLength())+pView->GetPatternView()->GetPlayRow());
         startSettleTimer();
         m_pTimer->start(0);
      }
   }
   if ( m_bDraggingPosition )
   {
      // FF/RW
      m_bCheck = false;
      pView->PlayerCommand(CMD_JUMP_TO,(ui->position->value()/pDoc->GetPatternLength())-1);
      pView->GetPatternView()->JumpToRow(ui->position->value()%pDoc->GetPatternLength());
   }
   else
   {
      m_bCheck = true;
      ui->frames->setText(QString::number(m_iFramesPlayed)+"/"+QString::number(pDoc->ScanActualLength(pDoc->GetSelectedTrack(),m_pWndMFC->GetFrameLoopCount())));
      ui->position->setValue((pView->GetPatternView()->GetPlayFrame()*pDoc->GetPatternLength())+pView->GetPatternView()->GetPlayRow());
   }
}
示例#15
0
void CFrameAction::Redo(CMainFrame *pMainFrm)
{
	// Redo action

	CFamiTrackerView *pView = (CFamiTrackerView*)pMainFrm->GetActiveView();
	CFamiTrackerDoc *pDocument = pView->GetDocument();

	switch (m_iAction) {
		case ACT_ADD:
			pDocument->InsertFrame(m_iUndoFramePos + 1);
			pDocument->UpdateAllViews(NULL, CHANGED_FRAMES);
			break;
		case ACT_REMOVE:
			pDocument->RemoveFrame(m_iUndoFramePos);
			pDocument->UpdateAllViews(NULL, CHANGED_FRAMES);
			break;
		case ACT_DUPLICATE:
			pDocument->DuplicateFrame(m_iUndoFramePos);
			pDocument->UpdateAllViews(NULL, CHANGED_FRAMES);
			break;
		case ACT_DUPLICATE_PATTERNS:
			pDocument->DuplicatePatterns(m_iUndoFramePos + 1);
			pDocument->UpdateAllViews(NULL, CHANGED_FRAMES);
			break;
		case ACT_CHANGE_COUNT:
			pDocument->SetFrameCount(m_iNewFrameCount);
			pDocument->UpdateAllViews(NULL, CHANGED_FRAMES);
			break;
		case ACT_SET_PATTERN:
			pDocument->SetPatternAtFrame(m_iUndoFramePos, m_iUndoChannelPos, m_iNewPattern);
			pDocument->UpdateAllViews(NULL, CHANGED_PATTERN);
			pMainFrm->UpdateControls();
			break;
		case ACT_SET_PATTERN_ALL:
			{
				int Channels = pDocument->GetAvailableChannels();
				for (int i = 0; i < Channels; ++i) {
					pDocument->SetPatternAtFrame(m_iUndoFramePos, i, m_iNewPattern);
				}
				pDocument->UpdateAllViews(NULL, CHANGED_PATTERN);
			}
			break;
		case ACT_CHANGE_PATTERN:
			pDocument->SetPatternAtFrame(m_iUndoFramePos, m_iUndoChannelPos, m_iOldPattern + m_iPatternDelta);
			pDocument->UpdateAllViews(NULL, CHANGED_PATTERN);
			break;
		case ACT_CHANGE_PATTERN_ALL:
			{
				int Channels = pDocument->GetAvailableChannels();
				for (int i = 0; i < Channels; ++i) {
					pDocument->SetPatternAtFrame(m_iUndoFramePos, i, m_iPatterns[i] + m_iPatternDelta);
				}
				pDocument->UpdateAllViews(NULL, CHANGED_PATTERN);
			}
			break;
		case ACT_MOVE_DOWN:
			pDocument->MoveFrameDown(m_iUndoFramePos);
			pDocument->UpdateAllViews(NULL, CHANGED_FRAMES);
			break;
		case ACT_MOVE_UP:
			pDocument->MoveFrameUp(m_iUndoFramePos);
			pDocument->UpdateAllViews(NULL, CHANGED_FRAMES);
			break;
		case ACT_PASTE:
			{
				int Channels = pDocument->GetAvailableChannels();
				for (int i = 0; i < Channels; ++i)
					pDocument->SetPatternAtFrame(m_iUndoFramePos, i, m_iPasteData[i]);
			}
			pDocument->UpdateAllViews(NULL, CHANGED_PATTERN);
			break;
	}

	pView->SelectFrame(m_iRedoFramePos);
	pView->SelectChannel(m_iRedoChannelPos);
}
// Command line export function
void CCommandLineExport::CommandLineExport(const CString& fileIn, const CString& fileOut, const CString& fileLog,  const CString& fileDPCM)
{
	// open log
	bool bLog = false;
	CStdioFile fLog;
	if (fileLog.GetLength() > 0)
	{
		if(fLog.Open(fileLog, CFile::modeCreate | CFile::modeWrite | CFile::typeText, NULL))
			bLog = true;
	}

	// create CFamiTrackerDoc for export
	CRuntimeClass* pRuntimeClass = RUNTIME_CLASS(CFamiTrackerDoc);
	CObject* pObject = pRuntimeClass->CreateObject();
	if (pObject == NULL || !pObject->IsKindOf(RUNTIME_CLASS(CFamiTrackerDoc)))
	{
		if (bLog) fLog.WriteString(_T("Error: unable to create CFamiTrackerDoc\n"));
		return;
	}
	CFamiTrackerDoc* pExportDoc = static_cast<CFamiTrackerDoc*>(pObject);

	// open file
	if(!pExportDoc->OnOpenDocument(fileIn))
	{
		if (bLog)
		{
			fLog.WriteString(_T("Error: unable to open document: "));
			fLog.WriteString(fileIn);
			fLog.WriteString(_T("\n"));
		}
		return;
	}
	if (bLog)
	{
		fLog.WriteString(_T("Opened: "));
		fLog.WriteString(fileIn);
		fLog.WriteString(_T("\n"));
	}

	// find extension
	int nPos = fileOut.ReverseFind(TCHAR('.'));
	if (nPos < 0)
	{
		if (bLog)
		{
			fLog.WriteString(_T("Error: export filename has no extension: "));
			fLog.WriteString(fileOut);
			fLog.WriteString(_T("\n"));
		}
		return;
	}
	CString ext = fileOut.Mid(nPos);

	theApp.GetSoundGenerator()->GenerateVibratoTable(pExportDoc->GetVibratoStyle());

	// export
	if      (0 == ext.CompareNoCase(_T(".nsf")))
	{
		CCompiler compiler(pExportDoc, bLog ? new CCommandLineLog(&fLog) : NULL);
		compiler.ExportNSF(fileOut, pExportDoc->GetMachine() );
		if (bLog)
		{
			fLog.WriteString(_T("\nNSF export complete.\n"));
		}
		return;
	}
	else if (0 == ext.CompareNoCase(_T(".nes")))
	{
		CCompiler compiler(pExportDoc, bLog ? new CCommandLineLog(&fLog) : NULL);
		compiler.ExportNES(fileOut, pExportDoc->GetMachine() == PAL);
		if (bLog)
		{
			fLog.WriteString(_T("\nNES export complete.\n"));
		}
		return;
	}
	// BIN export requires two files
	else if (0 == ext.CompareNoCase(_T(".bin")))
	{
		CCompiler compiler(pExportDoc, bLog ? new CCommandLineLog(&fLog) : NULL);
		compiler.ExportBIN(fileOut, fileDPCM);
		if (bLog)
		{
			fLog.WriteString(_T("\nBIN export complete.\n"));
		}
		return;
	}
	else if (0 == ext.CompareNoCase(_T(".prg")))
	{
		CCompiler compiler(pExportDoc, bLog ? new CCommandLineLog(&fLog) : NULL);
		compiler.ExportPRG(fileOut, pExportDoc->GetMachine() == PAL);
		if (bLog)
		{
			fLog.WriteString(_T("\nPRG export complete.\n"));
		}
		return;
	}
	else if (0 == ext.CompareNoCase(_T(".asm")))
	{
		CCompiler compiler(pExportDoc, bLog ? new CCommandLineLog(&fLog) : NULL);
		compiler.ExportASM(fileOut);
		if (bLog)
		{
			fLog.WriteString(_T("\nASM export complete.\n"));
		}
		return;
	}
	else if (0 == ext.CompareNoCase(_T(".nsfe")))		// // //
	{
		CCompiler compiler(pExportDoc, bLog ? new CCommandLineLog(&fLog) : NULL);
		compiler.ExportNSFE(fileOut, pExportDoc->GetMachine());
		if (bLog)
		{
			fLog.WriteString(_T("\nNSFe export complete.\n"));
		}
		return;
	}
	else if (0 == ext.CompareNoCase(_T(".txt")))
	{
		CTextExport textExport;
		CString result = textExport.ExportFile(fileOut, pExportDoc);
		if (result.GetLength() > 0)
		{
			if (bLog)
			{
				fLog.WriteString(_T("Error: "));
				fLog.WriteString(result);
				fLog.WriteString(_T("\n"));
			}
		}
		else if (bLog)
		{
			fLog.WriteString(_T("Exported: "));
			fLog.WriteString(fileOut);
			fLog.WriteString(_T("\n"));
		}
		return;
	}
	else // use first custom exporter
	{
		CCustomExporters* pExporters = theApp.GetCustomExporters();
		if (pExporters)
		{
			CStringArray sNames;
			pExporters->GetNames(sNames);
			if (sNames.GetCount())
			{
				pExporters->SetCurrentExporter(sNames[0]);
				CFamiTrackerDocWrapper documentWrapper(CFamiTrackerDoc::GetDoc(), 0);
				bool bResult = (pExporters->GetCurrentExporter().Export(&documentWrapper, fileOut));
				if (bLog)
				{
					fLog.WriteString(_T("Custom exporter: "));
					fLog.WriteString(sNames[0]);
					fLog.WriteString(_T("\n"));
					fLog.WriteString(_T("Export "));
					fLog.WriteString(bResult ? _T("succesful: ") : _T("failed: "));
					fLog.WriteString(fileOut);
					fLog.WriteString(_T("\n"));
				}
				return;
			}
		}
	}

	if (bLog)
	{
		fLog.WriteString(_T("Error: unable to find matching export extension for: "));
		fLog.WriteString(fileOut);
		fLog.WriteString(_T("\n"));
	}
	return;
}
示例#17
0
void CInstrumentEditDlg::SetCurrentInstrument(int Index)
{
    CFamiTrackerDoc *pDoc = CFamiTrackerDoc::GetDoc();
    CInstrumentContainer<CInstrument> instContainer(pDoc, Index);
    CInstrument *pInstrument = instContainer();
    int InstType = pInstrument->GetType();

    // Dialog title
    char Name[256];
    pDoc->GetInstrumentName(Index, Name);
    CString Suffix;
    Suffix.Format(_T("%02X. %s (%s)"), Index, Name, CHIP_NAMES[InstType]);
    CString Title;
    AfxFormatString1(Title, IDS_INSTRUMENT_EDITOR_TITLE, Suffix);
    SetWindowText(Title);

    if (InstType != m_iSelectedInstType) {
        ShowWindow(SW_HIDE);
        ClearPanels();

        switch (InstType) {
        case INST_2A03: {
            int Channel = CFamiTrackerView::GetView()->GetSelectedChannel();
            int Type = pDoc->GetChannelType(Channel);
            bool bShowDPCM = (Type == CHANID_DPCM) || (static_cast<CInstrument2A03*>(pInstrument)->AssignedSamples());
            InsertPane(new CInstrumentEditor2A03(), !bShowDPCM);
            InsertPane(new CInstrumentEditorDPCM(), bShowDPCM);
        }
        break;
        case INST_VRC6:
            InsertPane(new CInstrumentEditorVRC6(), true);
            break;
        case INST_VRC7:
            InsertPane(new CInstrumentEditorVRC7(), true);
            break;
        case INST_FDS:
            InsertPane(new CInstrumentEditorFDS(), true);
            InsertPane(new CInstrumentEditorFDSEnvelope(), false);
            break;
        case INST_N163:
            InsertPane(new CInstrumentEditorN163(), true);
            InsertPane(new CInstrumentEditorN163Wave(), false);
            break;
        case INST_S5B:
            InsertPane(new CInstrumentEditorS5B(), true);
            break;
        }

        m_iSelectedInstType = InstType;
    }

    for (int i = 0; i < PANEL_COUNT; ++i) {
        if (m_pPanels[i] != NULL) {
            m_pPanels[i]->SelectInstrument(Index);
        }
    }

    ShowWindow(SW_SHOW);
    UpdateWindow();

    m_iSelectedInstType = InstType;
}
示例#18
0
bool CFrameAction::SaveState(CMainFrame *pMainFrm)
{
	// Perform action

	CFrameEditor *pFrameEditor = pMainFrm->GetFrameEditor();
	CFamiTrackerView *pView = (CFamiTrackerView*)pMainFrm->GetActiveView();
	CFamiTrackerDoc *pDocument = pView->GetDocument();

	m_iUndoFramePos = pView->GetSelectedFrame();
	m_iUndoChannelPos = pView->GetSelectedChannel();

	switch (m_iAction) {
		case ACT_ADD:
			if (!pDocument->InsertFrame(m_iUndoFramePos + 1))
				return false;
			pDocument->UpdateAllViews(NULL, CHANGED_FRAMES);
			break;
		case ACT_REMOVE:
			SaveFrame(pDocument);
			if (!pDocument->RemoveFrame(m_iUndoFramePos))
				return false;
			pDocument->UpdateAllViews(NULL, CHANGED_FRAMES);
			break;
		case ACT_DUPLICATE:
			if (!pDocument->DuplicateFrame(m_iUndoFramePos))
				return false;
			pDocument->UpdateAllViews(NULL, CHANGED_FRAMES);
			break;
		case ACT_DUPLICATE_PATTERNS:
			if (!pDocument->DuplicatePatterns(m_iUndoFramePos + 1))
				return false;
			pDocument->UpdateAllViews(NULL, CHANGED_FRAMES);
			break;
		case ACT_CHANGE_COUNT:
			m_iUndoFrameCount = pDocument->GetFrameCount();
			pDocument->SetFrameCount(m_iNewFrameCount);
			pDocument->UpdateAllViews(NULL, CHANGED_FRAMES);
			break;
		case ACT_SET_PATTERN:
			m_iOldPattern = pDocument->GetPatternAtFrame(m_iUndoFramePos, m_iUndoChannelPos);
			pDocument->SetPatternAtFrame(m_iUndoFramePos, m_iUndoChannelPos, m_iNewPattern);
			pDocument->UpdateAllViews(NULL, CHANGED_PATTERN);
			break;
		case ACT_SET_PATTERN_ALL:
			{
				int Channels = pDocument->GetAvailableChannels();
				for (int i = 0; i < Channels; ++i) {
					m_iPatterns[i] = pDocument->GetPatternAtFrame(m_iUndoFramePos, i);
					pDocument->SetPatternAtFrame(m_iUndoFramePos, i, m_iNewPattern);
				}
				pDocument->UpdateAllViews(NULL, CHANGED_PATTERN);
			}
			break;
		case ACT_CHANGE_PATTERN:
			{
				m_iOldPattern = pDocument->GetPatternAtFrame(m_iUndoFramePos, m_iUndoChannelPos);
				int NewPattern = m_iOldPattern + m_iPatternDelta;
				if (NewPattern < 0)
					NewPattern = 0;
				if (NewPattern >= MAX_FRAMES)
					NewPattern = MAX_FRAMES - 1;
				if (NewPattern == m_iOldPattern)
					return false;
				pDocument->SetPatternAtFrame(m_iUndoFramePos, m_iUndoChannelPos, NewPattern);
				pDocument->UpdateAllViews(NULL, CHANGED_PATTERN);
			}
			break;
		case ACT_CHANGE_PATTERN_ALL:
			{
				int Channels = pDocument->GetAvailableChannels();
				for (int i = 0; i < Channels; ++i) {
					m_iPatterns[i] = pDocument->GetPatternAtFrame(m_iUndoFramePos, i);
					if (m_iPatterns[i] + m_iPatternDelta < 0 || m_iPatterns[i] + m_iPatternDelta >= MAX_FRAMES)
						return false;
				}
				for (int i = 0; i < Channels; ++i)
					pDocument->SetPatternAtFrame(m_iUndoFramePos, i, m_iPatterns[i] + m_iPatternDelta);
				pDocument->UpdateAllViews(NULL, CHANGED_PATTERN);
			}
			break;
		case ACT_MOVE_DOWN:
			if (!pDocument->MoveFrameDown(m_iUndoFramePos))
				return false;
			pView->SelectFrame(m_iUndoFramePos + 1);
			pDocument->UpdateAllViews(NULL, CHANGED_FRAMES);
			break;
		case ACT_MOVE_UP:
			if (!pDocument->MoveFrameUp(m_iUndoFramePos))
				return false;
			pView->SelectFrame(m_iUndoFramePos - 1);
			pDocument->UpdateAllViews(NULL, CHANGED_FRAMES);
			break;
		case ACT_PASTE:
			SaveFrame(pDocument);
			{
				int Channels = pDocument->GetAvailableChannels();
				for (int i = 0; i < Channels; ++i)
					pDocument->SetPatternAtFrame(m_iUndoFramePos, i, m_iPasteData[i]);
			}
			pDocument->UpdateAllViews(NULL, CHANGED_PATTERN);
			break;
	}

	return true;
}
示例#19
0
void CFrameAction::Undo(CMainFrame *pMainFrm)
{
	// Undo action

	CFrameEditor *pFrameEditor = pMainFrm->GetFrameEditor();
	CFamiTrackerView *pView = (CFamiTrackerView*)pMainFrm->GetActiveView();
	CFamiTrackerDoc *pDocument = pView->GetDocument();

	m_iRedoFramePos = pView->GetSelectedFrame();
	m_iRedoChannelPos = pView->GetSelectedChannel();

	pView->SelectFrame(m_iUndoFramePos);
	pView->SelectChannel(m_iUndoChannelPos);

	switch (m_iAction) {
		case ACT_ADD:
			pDocument->RemoveFrame(m_iUndoFramePos + 1);
			pDocument->UpdateAllViews(NULL, CHANGED_FRAMES);
			break;
		case ACT_REMOVE:
			pDocument->InsertFrame(m_iUndoFramePos);
			RestoreFrame(pDocument);
			pDocument->UpdateAllViews(NULL, CHANGED_FRAMES);
			break;
		case ACT_DUPLICATE:
			pDocument->RemoveFrame(m_iUndoFramePos);
			pDocument->UpdateAllViews(NULL, CHANGED_FRAMES);
			break;
		case ACT_DUPLICATE_PATTERNS:
			for (unsigned int i = 0; i < pDocument->GetAvailableChannels(); ++i) {
				pDocument->ClearPattern(m_iUndoFramePos + 1, i);
			}
			pDocument->RemoveFrame(m_iUndoFramePos + 1);
			pDocument->UpdateAllViews(NULL, CHANGED_FRAMES);
			break;
		case ACT_CHANGE_COUNT:
			pDocument->SetFrameCount(m_iUndoFrameCount);
			pDocument->UpdateAllViews(NULL, CHANGED_FRAMES);
			break;
		case ACT_SET_PATTERN:
			pDocument->SetPatternAtFrame(m_iUndoFramePos, m_iUndoChannelPos, m_iOldPattern);
			pDocument->UpdateAllViews(NULL, CHANGED_PATTERN);
			pMainFrm->UpdateControls();
			break;
		case ACT_SET_PATTERN_ALL:
			for (unsigned int i = 0; i < pDocument->GetAvailableChannels(); ++i) {
				pDocument->SetPatternAtFrame(m_iUndoFramePos, i, m_iPatterns[i]);
			}
			pDocument->UpdateAllViews(NULL, CHANGED_PATTERN);
			break;
		case ACT_CHANGE_PATTERN:
			pDocument->SetPatternAtFrame(m_iUndoFramePos, m_iUndoChannelPos, m_iOldPattern);
			pDocument->UpdateAllViews(NULL, CHANGED_PATTERN);
			break;
		case ACT_CHANGE_PATTERN_ALL:
			for (unsigned int i = 0; i < pDocument->GetAvailableChannels(); ++i) {
				pDocument->SetPatternAtFrame(m_iUndoFramePos, i, m_iPatterns[i]);
			}
			pDocument->UpdateAllViews(NULL, CHANGED_PATTERN);
			break;
		case ACT_MOVE_DOWN:
			pDocument->MoveFrameUp(m_iUndoFramePos + 1);
			pDocument->UpdateAllViews(NULL, CHANGED_FRAMES);
			break;
		case ACT_MOVE_UP:
			pDocument->MoveFrameDown(m_iUndoFramePos - 1);
			pDocument->UpdateAllViews(NULL, CHANGED_FRAMES);
			break;
		case ACT_PASTE:
			RestoreFrame(pDocument);
			pDocument->UpdateAllViews(NULL, CHANGED_PATTERN);
			break;
	}

	pView->SelectFrame(m_iUndoFramePos);
	pView->SelectChannel(m_iUndoChannelPos);
}