| 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 |
#ifndef _EXPORT_H |
| 21 |
#define _EXPORT_H |
| 22 |
|
| 23 |
#include "song.h" |
| 24 |
#include <initializer_list> |
| 25 |
#include "../pch.h" |
| 26 |
|
| 27 |
class DivEngine; |
| 28 |
|
| 29 |
enum DivROMExportOptions { |
| 30 |
DIV_ROM_ABSTRACT=0, |
| 31 |
DIV_ROM_AMIGA_VALIDATION, |
| 32 |
DIV_ROM_ZSM, |
| 33 |
DIV_ROM_TIUNA, |
| 34 |
DIV_ROM_SAP_R, |
| 35 |
DIV_ROM_IPOD, |
| 36 |
DIV_ROM_GRUB, |
| 37 |
|
| 38 |
DIV_ROM_MAX |
| 39 |
}; |
| 40 |
|
| 41 |
struct DivROMExportOutput { |
| 42 |
String name; |
| 43 |
SafeWriter* data; |
| 44 |
|
| 45 |
DivROMExportOutput(String n, SafeWriter* d): |
| 46 |
name(n), |
| 47 |
data(d) {} |
| 48 |
DivROMExportOutput(): |
| 49 |
name(""), |
| 50 |
data(NULL) {} |
| 51 |
}; |
| 52 |
|
| 53 |
struct DivROMExportProgress { |
| 54 |
String name; |
| 55 |
float amount; |
| 56 |
}; |
| 57 |
|
| 58 |
class DivROMExport { |
| 59 |
protected: |
| 60 |
DivConfig conf; |
| 61 |
std::vector<DivROMExportOutput> output; |
| 62 |
void logAppend(String what); |
| 63 |
public: |
| 64 |
std::vector<String> exportLog; |
| 65 |
std::mutex logLock; |
| 66 |
|
| 67 |
void setConf(DivConfig& c); |
| 68 |
virtual bool go(DivEngine* eng); |
| 69 |
virtual void abort(); |
| 70 |
virtual void wait(); |
| 71 |
std::vector<DivROMExportOutput>& getResult(); |
| 72 |
virtual bool hasFailed(); |
| 73 |
virtual bool isRunning(); |
| 74 |
virtual DivROMExportProgress getProgress(int index=0); |
| 75 |
virtual ~DivROMExport() {} |
| 76 |
}; |
| 77 |
|
| 78 |
#define logAppendf(...) logAppend(fmt::sprintf(__VA_ARGS__)) |
| 79 |
|
| 80 |
enum DivROMExportReqPolicy { |
| 81 |
// exactly these chips. |
| 82 |
DIV_REQPOL_EXACT=0, |
| 83 |
// specified chips must be present but any amount of them is acceptable. |
| 84 |
DIV_REQPOL_ANY, |
| 85 |
// at least one of the specified chips. |
| 86 |
DIV_REQPOL_LAX |
| 87 |
}; |
| 88 |
|
| 89 |
struct DivROMExportDef { |
| 90 |
const char* name; |
| 91 |
const char* author; |
| 92 |
const char* description; |
| 93 |
const char* fileType; |
| 94 |
const char* fileExt; |
| 95 |
std::vector<DivSystem> requisites; |
| 96 |
bool multiOutput; |
| 97 |
DivROMExportReqPolicy requisitePolicy; |
| 98 |
|
| 99 |
DivROMExportDef(const char* n, const char* a, const char* d, const char* ft, const char* fe, std::initializer_list<DivSystem> req, bool multiOut, DivROMExportReqPolicy reqPolicy): |
| 100 |
name(n), |
| 101 |
author(a), |
| 102 |
description(d), |
| 103 |
fileType(ft), |
| 104 |
fileExt(fe), |
| 105 |
multiOutput(multiOut), |
| 106 |
requisitePolicy(reqPolicy) { |
| 107 |
requisites=req; |
| 108 |
} |
| 109 |
}; |
| 110 |
|
| 111 |
#endif |