| 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 "engine.h" |
| 21 |
|
| 22 |
DivROMExportDef* DivEngine::romExportDefs[DIV_ROM_MAX]; |
| 23 |
|
| 24 |
const DivROMExportDef* DivEngine::getROMExportDef(DivROMExportOptions opt) { |
| 25 |
return romExportDefs[opt]; |
| 26 |
} |
| 27 |
|
| 28 |
bool DivEngine::isROMExportViable(DivROMExportOptions opt) |
| 29 |
{ |
| 30 |
const DivROMExportDef* newDef=getROMExportDef(opt); |
| 31 |
if (newDef==NULL) { |
| 32 |
return false; |
| 33 |
} |
| 34 |
|
| 35 |
unsigned char sysReqCount[DIV_SYSTEM_MAX]; |
| 36 |
memset(sysReqCount,0,DIV_SYSTEM_MAX); |
| 37 |
for (int i=0; i<song.systemLen; i++) { |
| 38 |
sysReqCount[song.system[i]]++; |
| 39 |
} |
| 40 |
|
| 41 |
unsigned char defReqCount[DIV_SYSTEM_MAX]; |
| 42 |
memset(defReqCount,0,DIV_SYSTEM_MAX); |
| 43 |
for (DivSystem j: newDef->requisites) { |
| 44 |
defReqCount[j]++; |
| 45 |
} |
| 46 |
|
| 47 |
switch (newDef->requisitePolicy) { |
| 48 |
case DIV_REQPOL_EXACT: |
| 49 |
for (int j=0; j<DIV_SYSTEM_MAX; j++) { |
| 50 |
if (defReqCount[j]!=sysReqCount[j]) { |
| 51 |
return false; |
| 52 |
} |
| 53 |
} |
| 54 |
break; |
| 55 |
case DIV_REQPOL_ANY: |
| 56 |
for (int j=0; j<DIV_SYSTEM_MAX; j++) { |
| 57 |
if (defReqCount[j]>sysReqCount[j]) { |
| 58 |
return false; |
| 59 |
} |
| 60 |
} |
| 61 |
break; |
| 62 |
case DIV_REQPOL_LAX: |
| 63 |
for (DivSystem j: newDef->requisites) { |
| 64 |
if (defReqCount[j]<=sysReqCount[j]) { |
| 65 |
return true; |
| 66 |
} |
| 67 |
} |
| 68 |
return false; |
| 69 |
} |
| 70 |
return true; |
| 71 |
} |
| 72 |
|
| 73 |
void DivEngine::registerROMExports() { |
| 74 |
logD("registering ROM exports..."); |
| 75 |
|
| 76 |
romExportDefs[DIV_ROM_AMIGA_VALIDATION]=new DivROMExportDef( |
| 77 |
"Amiga Validation", "tildearrow", |
| 78 |
"a test export for ensuring Amiga emulation is accurate. do not use!", |
| 79 |
NULL, NULL, |
| 80 |
{DIV_SYSTEM_AMIGA}, |
| 81 |
true, DIV_REQPOL_EXACT |
| 82 |
); |
| 83 |
|
| 84 |
romExportDefs[DIV_ROM_ZSM]=new DivROMExportDef( |
| 85 |
"Commander X16 ZSM", "ZeroByteOrg and MooingLemur", |
| 86 |
"Commander X16 Zsound Music File.\n" |
| 87 |
"for use with Melodius, Calliope and/or ZSMKit:\n" |
| 88 |
"- https://github.com/mooinglemur/zsmkit (development)\n" |
| 89 |
"- https://github.com/mooinglemur/melodius (player)\n" |
| 90 |
"- https://github.com/ZeroByteOrg/calliope (player)\n", |
| 91 |
"ZSM file", ".zsm", |
| 92 |
{ |
| 93 |
DIV_SYSTEM_YM2151, DIV_SYSTEM_VERA |
| 94 |
}, |
| 95 |
false, DIV_REQPOL_LAX |
| 96 |
); |
| 97 |
|
| 98 |
romExportDefs[DIV_ROM_TIUNA]=new DivROMExportDef( |
| 99 |
"Atari 2600 (TIunA)", "Natt Akuma", |
| 100 |
"advanced driver with software tuning support.\n" |
| 101 |
"see https://github.com/AYCEdemo/twin-tiuna for code.", |
| 102 |
"assembly files", ".asm", |
| 103 |
{ |
| 104 |
DIV_SYSTEM_TIA |
| 105 |
}, |
| 106 |
false, DIV_REQPOL_ANY |
| 107 |
); |
| 108 |
|
| 109 |
romExportDefs[DIV_ROM_SAP_R]=new DivROMExportDef( |
| 110 |
"Atari 8-bit SAP-R", "asiekierka", |
| 111 |
"SAP type R export for POKEY songs.\n" |
| 112 |
"register dump-based, unlike normal SAP.\n" |
| 113 |
"for playback, you may use:\n" |
| 114 |
"- Altirra\n" |
| 115 |
"- lzss-sap (https://github.com/dmsc/lzss-sap/)", |
| 116 |
"SAP files", ".sap", |
| 117 |
{ |
| 118 |
DIV_SYSTEM_POKEY |
| 119 |
}, |
| 120 |
false, DIV_REQPOL_EXACT |
| 121 |
); |
| 122 |
|
| 123 |
romExportDefs[DIV_ROM_IPOD]=new DivROMExportDef( |
| 124 |
"iPod .tone alarm", "AArt1256", |
| 125 |
"iPod Beeper (.tone) Alarm export\n" |
| 126 |
"for playback, you can drag the resulting file\n" |
| 127 |
"into iPod_Control/Tones to your iPod IN DISK MODE", |
| 128 |
"alarm tone files", ".tone", |
| 129 |
{ |
| 130 |
DIV_SYSTEM_PCSPKR |
| 131 |
}, |
| 132 |
false, DIV_REQPOL_ANY |
| 133 |
); |
| 134 |
|
| 135 |
romExportDefs[DIV_ROM_GRUB]=new DivROMExportDef( |
| 136 |
"GRUB_INIT_TUNE", "AArt1256", |
| 137 |
"GRUB_INIT_TUNE export\n" |
| 138 |
"for use with the GRUB bootloader using the \"play\" command", |
| 139 |
"Text/Binary files", NULL, |
| 140 |
{ |
| 141 |
DIV_SYSTEM_PCSPKR |
| 142 |
}, |
| 143 |
false, DIV_REQPOL_ANY |
| 144 |
); |
| 145 |
} |