| 1 |
/** |
| 2 |
* Furnace Tracker - multi-system chiptune tracker |
| 3 |
* Copyright (C) 2021-2025 tildearrow and contributors |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation; either version 2 of the License, or |
| 8 |
* (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License along |
| 16 |
* with this program; if not, write to the Free Software Foundation, Inc., |
| 17 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
#include "safeReader.h" |
| 21 |
#include "../pch.h" |
| 22 |
|
| 23 |
struct DivPattern { |
| 24 |
String name; |
| 25 |
short data[DIV_MAX_ROWS][DIV_MAX_COLS]; |
| 26 |
|
| 27 |
/** |
| 28 |
* clear the pattern. |
| 29 |
*/ |
| 30 |
void clear(); |
| 31 |
|
| 32 |
/** |
| 33 |
* copy this pattern to another. |
| 34 |
* @param dest the destination pattern. |
| 35 |
*/ |
| 36 |
void copyOn(DivPattern* dest); |
| 37 |
DivPattern(); |
| 38 |
}; |
| 39 |
|
| 40 |
struct DivChannelData { |
| 41 |
unsigned char effectCols; |
| 42 |
// data goes as follows: data[ROW][TYPE] |
| 43 |
// TYPE is: |
| 44 |
// 0: note |
| 45 |
// 1: octave |
| 46 |
// 2: instrument |
| 47 |
// 3: volume |
| 48 |
// 4-5+: effect/effect value |
| 49 |
// do NOT access directly unless you know what you're doing! |
| 50 |
DivPattern* data[DIV_MAX_PATTERNS]; |
| 51 |
|
| 52 |
/** |
| 53 |
* get a pattern from this channel, or the empty pattern if not initialized. |
| 54 |
* @param index the pattern ID. |
| 55 |
* @param create whether to initialize a new pattern if not init'ed. always use true if you're going to modify it! |
| 56 |
* @return a DivPattern. |
| 57 |
*/ |
| 58 |
DivPattern* getPattern(int index, bool create); |
| 59 |
|
| 60 |
/** |
| 61 |
* optimize pattern data. |
| 62 |
* not thread-safe! use a mutex! |
| 63 |
* @return a list of From -> To pairs |
| 64 |
*/ |
| 65 |
std::vector<std::pair<int,int>> optimize(); |
| 66 |
|
| 67 |
/** |
| 68 |
* re-arrange NULLs. |
| 69 |
* not thread-safe! use a mutex! |
| 70 |
* @return a list of From -> To pairs |
| 71 |
*/ |
| 72 |
std::vector<std::pair<int,int>> rearrange(); |
| 73 |
|
| 74 |
/** |
| 75 |
* destroy all patterns on this DivChannelData. |
| 76 |
*/ |
| 77 |
void wipePatterns(); |
| 78 |
DivChannelData(); |
| 79 |
}; |