/** * Furnace Tracker - multi-system chiptune tracker * Copyright (C) 2021-2022 tildearrow and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "engine.h" static DivPattern emptyPat; DivPattern::DivPattern() { memset(data,-1,256*32*sizeof(short)); for (int i=0; i<256; i++) { data[i][0]=0; data[i][1]=0; } } DivPattern* DivChannelData::getPattern(int index, bool create) { if (data[index]==NULL) { if (create) { data[index]=new DivPattern; } else { return &emptyPat; } } return data[index]; } void DivChannelData::wipePatterns() { for (int i=0; i<128; i++) { if (data[i]!=NULL) { delete data[i]; data[i]=NULL; } } } void DivPattern::copyOn(DivPattern *dest) { dest->name=name; memcpy(dest->data,data,sizeof(data)); } SafeReader* DivPattern::compile(int len, int fxRows) { SafeWriter w; w.init(); short lastNote, lastOctave, lastInstr, lastVolume, lastEffect[8], lastEffectVal[8]; unsigned char rows=0; lastNote=0; lastOctave=0; lastInstr=-1; lastVolume=-1; memset(lastEffect,-1,8*sizeof(short)); memset(lastEffectVal,-1,8*sizeof(short)); for (int i=0; i