bool CInstrument2A03::Load(CDocumentFile *pDocFile) { int SeqCnt; int Octaves = OCTAVE_RANGE; int Index; int Version = pDocFile->GetBlockVersion(); SeqCnt = pDocFile->GetBlockInt(); ASSERT_FILE_DATA(SeqCnt < (SEQUENCE_COUNT + 1)); for (int i = 0; i < SeqCnt; ++i) { SetSeqEnable(i, pDocFile->GetBlockChar()); Index = pDocFile->GetBlockChar(); ASSERT_FILE_DATA(Index < MAX_SEQUENCES); SetSeqIndex(i, Index); } if (Version == 1) Octaves = 6; for (int i = 0; i < Octaves; ++i) { for (int j = 0; j < 12; ++j) { Index = pDocFile->GetBlockChar(); if (Index >= MAX_DSAMPLES) Index = 0; SetSample(i, j, Index); SetSamplePitch(i, j, pDocFile->GetBlockChar()); } } return true; }
bool CInstrumentFDS::LoadFile(CInstrumentFile *pFile, int iVersion, CFamiTrackerDoc *pDoc) { // Read wave for (int i = 0; i < WAVE_SIZE; ++i) { SetSample(i, pFile->ReadChar()); } // Read modulation table for (int i = 0; i < MOD_SIZE; ++i) { SetModulation(i, pFile->ReadChar()); } // Modulation parameters SetModulationSpeed(pFile->ReadInt()); SetModulationDepth(pFile->ReadInt()); SetModulationDelay(pFile->ReadInt()); // Sequences LoadInstSequence(pFile, m_pVolume); LoadInstSequence(pFile, m_pArpeggio); LoadInstSequence(pFile, m_pPitch); if (iVersion <= 22) { for (unsigned int i = 0; i < m_pVolume->GetItemCount(); ++i) m_pVolume->SetItem(i, m_pVolume->GetItem(i) * 2); } return true; }
void MAS::Window::MsgInitSkin() { Dialog::MsgInitSkin(); // setup icons iconMin.SetBitmap(Skin::ICONMIN); iconMax.SetBitmap(Skin::ICONMAX); iconExit.SetBitmap(Skin::ICONEXIT); // setup title title.SetFontColor(skin->fcol[Skin::INFO_WINDOW][Skin::NORMAL], skin->scol[Skin::INFO_WINDOW][Skin::NORMAL], Skin::NORMAL); title.SetFont(skin->fnt[Skin::INFO_WINDOW][Skin::NORMAL], Skin::NORMAL); title.SetFontColor(skin->fcol[Skin::INFO_WINDOW][Skin::SELECT], skin->scol[Skin::INFO_WINDOW][Skin::SELECT], Skin::DISABLE); title.SetFont(skin->fnt[Skin::INFO_WINDOW][Skin::SELECT], Skin::DISABLE); title.SetTextMode(Color::transparent); title.SetAlignment(skin->winTextAlign); title.SetFlag(D_AUTOSIZE); if (skin->winTextBack) { textBack.SetBitmap(Skin::WINTEXT); textBack.Unhide(); } else { textBack.Hide(); } // The samples SetSample(Skin::SAMPLE_GOTFOCUS, Skin::SAMPLE_GOTFOCUS); SetSample(Skin::SAMPLE_LOSTFOCUS, Skin::SAMPLE_LOSTFOCUS); SetSample(Skin::SAMPLE_OPEN, Skin::SAMPLE_OPEN); SetSample(Skin::SAMPLE_CLOSE, Skin::SAMPLE_CLOSE); iconMax.SetSample(Skin::SAMPLE_OPEN, Skin::SAMPLE_ACTIVATE); iconMin.SetSample(Skin::SAMPLE_CLOSE, Skin::SAMPLE_ACTIVATE); SetAnimationProperties(skin->winAnimationLength, skin->winAnimationType); if (clientArea->w() && clientArea->h()) { w(clientArea->w() + bLeft.GetBitmap().w()/2 + bRight.GetBitmap().w()/2); h(clientArea->h() + bTop.GetBitmap().h()/2 + bBottom.GetBitmap().h()/2 + bGrip.GetBitmap().h()/2); } minSize.w(minSize.w() + bLeft.GetBitmap().w()/2 + bRight.GetBitmap().w()/2); minSize.h(minSize.h() + bTop.GetBitmap().h()/2 + bBottom.GetBitmap().h()/2 + bGrip.GetBitmap().h()/2); UpdateSize(); UpdateWindowProperties(); }
void MAS::SpinBox::MsgInitSkin() { Dialog::MsgInitSkin(); bUp.SetBitmap(Skin::SCROLL_UP); bDown.SetBitmap(Skin::SCROLL_DOWN); bUp.SetSample(-1, Skin::SAMPLE_ACTIVATE); bDown.SetSample(-1, Skin::SAMPLE_ACTIVATE); SetSample(Skin::SAMPLE_SCROLL, Skin::SAMPLE_SCROLL); bUp.SetFlag(D_SPINNER); bDown.SetFlag(D_SPINNER); }
bool CInstrumentFDS::Load(CDocumentFile *pDocFile) { for (int i = 0; i < WAVE_SIZE; ++i) { SetSample(i, pDocFile->GetBlockChar()); } for (int i = 0; i < MOD_SIZE; ++i) { SetModulation(i, pDocFile->GetBlockChar()); } SetModulationSpeed(pDocFile->GetBlockInt()); SetModulationDepth(pDocFile->GetBlockInt()); SetModulationDelay(pDocFile->GetBlockInt()); // hack to fix earlier saved files (remove this eventually) /* if (pDocFile->GetBlockVersion() > 2) { LoadSequence(pDocFile, m_pVolume); LoadSequence(pDocFile, m_pArpeggio); if (pDocFile->GetBlockVersion() > 2) LoadSequence(pDocFile, m_pPitch); } else { */ unsigned int a = pDocFile->GetBlockInt(); unsigned int b = pDocFile->GetBlockInt(); pDocFile->RollbackPointer(8); if (a < 256 && (b & 0xFF) != 0x00) { } else { LoadSequence(pDocFile, m_pVolume); LoadSequence(pDocFile, m_pArpeggio); // // Note: Remove this line when files are unable to load // (if a file contains FDS instruments but FDS is disabled) // this was a problem in an earlier version. // if (pDocFile->GetBlockVersion() > 2) LoadSequence(pDocFile, m_pPitch); } // } // Older files was 0-15, new is 0-31 if (pDocFile->GetBlockVersion() <= 3) { for (unsigned int i = 0; i < m_pVolume->GetItemCount(); ++i) m_pVolume->SetItem(i, m_pVolume->GetItem(i) * 2); } return true; }
bool CInstrumentFDS::LoadFile(CFile *pFile, int iVersion, CFamiTrackerDoc *pDoc) { // Read wave for (int i = 0; i < WAVE_SIZE; ++i) { char sample; pFile->Read(&sample, 1); SetSample(i, sample); } // Read modulation table for (int i = 0; i < MOD_SIZE; ++i) { char mod; pFile->Read(&mod, 1); SetModulation(i, mod); } // Modulation parameters int data; pFile->Read(&data, sizeof(int)); SetModulationSpeed(data); pFile->Read(&data, sizeof(int)); SetModulationDepth(data); pFile->Read(&data, sizeof(int)); SetModulationDelay(data); // Sequences LoadInstSequence(pFile, m_pVolume); LoadInstSequence(pFile, m_pArpeggio); LoadInstSequence(pFile, m_pPitch); if (iVersion <= 22) { for (unsigned int i = 0; i < m_pVolume->GetItemCount(); ++i) m_pVolume->SetItem(i, m_pVolume->GetItem(i) * 2); } return true; }
bool CInstrumentN163::LoadFile(CFile *pFile, int iVersion, CFamiTrackerDoc *pDoc) { // Sequences unsigned char SeqCount; pFile->Read(&SeqCount, sizeof(char)); // Loop through all instrument effects for (unsigned int i = 0; i < SeqCount; ++i) { unsigned char Enabled; pFile->Read(&Enabled, sizeof(char)); if (Enabled == 1) { // Read the sequence int Count; pFile->Read(&Count, sizeof(int)); if (Count < 0 || Count > MAX_SEQUENCE_ITEMS) return false; // Find a free sequence int Index = pDoc->GetFreeSequenceN163(i); CSequence *pSeq = pDoc->GetSequenceN163(Index, i); pSeq->SetItemCount(Count); int LoopPoint; int Setting; pFile->Read(&LoopPoint, sizeof(int)); pSeq->SetLoopPoint(LoopPoint); int ReleasePoint; pFile->Read(&ReleasePoint, sizeof(int)); pSeq->SetReleasePoint(ReleasePoint); pFile->Read(&Setting, sizeof(int)); pSeq->SetSetting(Setting); for (int j = 0; j < Count; ++j) { char Val; pFile->Read(&Val, sizeof(char)); pSeq->SetItem(j, Val); } SetSeqEnable(i, true); SetSeqIndex(i, Index); } else { SetSeqEnable(i, false); SetSeqIndex(i, 0); } } // Read wave config int WaveSize, WavePos, WaveCount; pFile->Read(&WaveSize, sizeof(int)); pFile->Read(&WavePos, sizeof(int)); pFile->Read(&WaveCount, sizeof(int)); if (WaveSize <= 0 || WaveSize > 32) return false; if (WaveCount <= 0 || WaveCount > MAX_WAVE_COUNT) return false; SetWaveSize(WaveSize); SetWavePos(WavePos); SetWaveCount(WaveCount); for (int i = 0; i < WaveCount; ++i) { for (int j = 0; j < WaveSize; ++j) { char w; pFile->Read(&w, sizeof(char)); SetSample(i, j, w); } } return true; }
bool CInstrument2A03::LoadFile(CFile *pFile, int iVersion, CFamiTrackerDoc *pDoc) { // Reads an FTI file // //CFamiTrackerDoc *pDoc = (CFamiTrackerDoc*)theApp.GetFirstDocument(); char SampleNames[MAX_DSAMPLES][256]; stSequence OldSequence; // Sequences unsigned char SeqCount; pFile->Read(&SeqCount, sizeof(char)); // Loop through all instrument effects for (unsigned int i = 0; i < SeqCount; ++i) { unsigned char Enabled; pFile->Read(&Enabled, sizeof(char)); if (Enabled == 1) { // Read the sequence int Count; pFile->Read(&Count, sizeof(int)); if (Count < 0 || Count > MAX_SEQUENCE_ITEMS) return false; // Find a free sequence int Index = pDoc->GetFreeSequence(i); CSequence *pSeq = pDoc->GetSequence(Index, i); if (iVersion < 20) { OldSequence.Count = Count; for (int j = 0; j < Count; ++j) { pFile->Read(&OldSequence.Length[j], sizeof(char)); pFile->Read(&OldSequence.Value[j], sizeof(char)); } pDoc->ConvertSequence(&OldSequence, pSeq, i); // convert } else { pSeq->SetItemCount(Count); int LoopPoint; int Setting; pFile->Read(&LoopPoint, sizeof(int)); pSeq->SetLoopPoint(LoopPoint); if (iVersion > 20) { int ReleasePoint; pFile->Read(&ReleasePoint, sizeof(int)); pSeq->SetReleasePoint(ReleasePoint); } if (iVersion >= 23) { pFile->Read(&Setting, sizeof(int)); pSeq->SetSetting(Setting); } for (int j = 0; j < Count; ++j) { char Val; pFile->Read(&Val, sizeof(char)); pSeq->SetItem(j, Val); } } SetSeqEnable(i, true); SetSeqIndex(i, Index); } else { SetSeqEnable(i, false); SetSeqIndex(i, 0); } } bool SamplesFound[MAX_DSAMPLES]; memset(SamplesFound, 0, sizeof(bool) * MAX_DSAMPLES); unsigned int Count; pFile->Read(&Count, sizeof(int)); // DPCM instruments for (unsigned int i = 0; i < Count; ++i) { unsigned char InstNote; pFile->Read(&InstNote, sizeof(char)); int Octave = InstNote / 12; int Note = InstNote % 12; unsigned char Sample, Pitch; pFile->Read(&Sample, sizeof(char)); pFile->Read(&Pitch, sizeof(char)); SetSamplePitch(Octave, Note, Pitch); SetSample(Octave, Note, Sample); } // DPCM samples list bool bAssigned[OCTAVE_RANGE][NOTE_RANGE]; memset(bAssigned, 0, sizeof(bool) * OCTAVE_RANGE * NOTE_RANGE); unsigned int SampleCount; pFile->Read(&SampleCount, sizeof(int)); for (unsigned int i = 0; i < SampleCount; ++i) { int Index, Len; pFile->Read(&Index, sizeof(int)); pFile->Read(&Len, sizeof(int)); if (Index >= MAX_DSAMPLES || Len >= 256) return false; pFile->Read(SampleNames[Index], Len); SampleNames[Index][Len] = 0; int Size; pFile->Read(&Size, sizeof(int)); char *SampleData = new char[Size]; pFile->Read(SampleData, Size); bool Found = false; for (int j = 0; j < MAX_DSAMPLES; ++j) { CDSample *pSample = pDoc->GetDSample(j); // Compare size and name to see if identical sample exists if (pSample->SampleSize == Size && !strcmp(pSample->Name, SampleNames[Index])) { Found = true; // Assign sample for (int o = 0; o < OCTAVE_RANGE; ++o) { for (int n = 0; n < NOTE_RANGE; ++n) { if (GetSample(o, n) == (Index + 1) && !bAssigned[o][n]) { SetSample(o, n, j + 1); bAssigned[o][n] = true; } } } } } if (!Found) { // Load sample int FreeSample = pDoc->GetFreeDSample(); if (FreeSample != -1) { if ((pDoc->GetTotalSampleSize() + Size) <= MAX_SAMPLE_SPACE) { CDSample *Sample = pDoc->GetDSample(FreeSample); strcpy(Sample->Name, SampleNames[Index]); Sample->SampleSize = Size; Sample->SampleData = SampleData; // Assign it for (int o = 0; o < OCTAVE_RANGE; ++o) { for (int n = 0; n < NOTE_RANGE; ++n) { if (GetSample(o, n) == (Index + 1) && !bAssigned[o][n]) { SetSample(o, n, FreeSample + 1); bAssigned[o][n] = true; } } } } else { // AfxMessageBox(IDS_OUT_OF_SAMPLEMEM, MB_ICONERROR); SAFE_RELEASE_ARRAY(SampleData); return false; } } else { // AfxMessageBox(IDS_OUT_OF_SLOTS, MB_ICONERROR); SAFE_RELEASE_ARRAY(SampleData); return false; } } else { SAFE_RELEASE_ARRAY(SampleData); } } return true; }