mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-05 04:15:05 +00:00
OPN: VGM export - good night
This commit is contained in:
parent
ab969c1da0
commit
ff0319780e
7 changed files with 1627 additions and 22 deletions
|
@ -27,8 +27,8 @@
|
|||
|
||||
#include "fmshared_OPN.h"
|
||||
|
||||
static unsigned char konOffs[6]={
|
||||
0, 1, 2, 4, 5, 6
|
||||
static unsigned char konOffs[3]={
|
||||
0, 1, 2
|
||||
};
|
||||
|
||||
#define CHIP_DIVIDER 32
|
||||
|
@ -287,11 +287,6 @@ const char* DivPlatformYM2203::getEffectName(unsigned char effect) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
double DivPlatformYM2203::NOTE_OPN(int ch, int note) {
|
||||
// FM
|
||||
return NOTE_FNUM_BLOCK(note,11);
|
||||
}
|
||||
|
||||
void DivPlatformYM2203::acquire(short* bufL, short* bufR, size_t start, size_t len) {
|
||||
static int os;
|
||||
|
||||
|
@ -314,9 +309,9 @@ void DivPlatformYM2203::acquire(short* bufL, short* bufR, size_t start, size_t l
|
|||
if (!writes.empty()) {
|
||||
if (--delay<1) {
|
||||
QueuedWrite& w=writes.front();
|
||||
fm->write(0x0+((w.addr>>8)<<1),w.addr);
|
||||
fm->write(0x1+((w.addr>>8)<<1),w.val);
|
||||
regPool[w.addr&0x1ff]=w.val;
|
||||
fm->write(0x0,w.addr);
|
||||
fm->write(0x1,w.val);
|
||||
regPool[w.addr&0xff]=w.val;
|
||||
writes.pop();
|
||||
delay=16;
|
||||
}
|
||||
|
@ -520,7 +515,7 @@ void DivPlatformYM2203::tick(bool sysTick) {
|
|||
}
|
||||
}
|
||||
|
||||
for (int i=16; i<512; i++) {
|
||||
for (int i=16; i<256; i++) {
|
||||
if (pendingWrites[i]!=oldWrites[i]) {
|
||||
immWrite(i,pendingWrites[i]&0xff);
|
||||
oldWrites[i]=pendingWrites[i];
|
||||
|
@ -670,7 +665,7 @@ int DivPlatformYM2203::dispatch(DivCommand c) {
|
|||
}
|
||||
case DIV_CMD_NOTE_PORTA: {
|
||||
if (c.chan>2 || parent->song.linearPitch==2) { // PSG
|
||||
int destFreq=NOTE_OPN(c.chan,c.value2);
|
||||
int destFreq=NOTE_FNUM_BLOCK(c.value2,11);
|
||||
bool return2=false;
|
||||
if (destFreq>chan[c.chan].baseFreq) {
|
||||
chan[c.chan].baseFreq+=c.value;
|
||||
|
@ -737,7 +732,7 @@ int DivPlatformYM2203::dispatch(DivCommand c) {
|
|||
break;
|
||||
}
|
||||
case DIV_CMD_LEGATO: {
|
||||
chan[c.chan].baseFreq=NOTE_OPN(c.chan,c.value);
|
||||
chan[c.chan].baseFreq=NOTE_FNUM_BLOCK(c.value,11);
|
||||
chan[c.chan].freqChanged=true;
|
||||
break;
|
||||
}
|
||||
|
@ -1002,7 +997,7 @@ unsigned char* DivPlatformYM2203::getRegisterPool() {
|
|||
}
|
||||
|
||||
int DivPlatformYM2203::getRegisterPoolSize() {
|
||||
return 512;
|
||||
return 256;
|
||||
}
|
||||
|
||||
void DivPlatformYM2203::poke(unsigned int addr, unsigned short val) {
|
||||
|
@ -1015,7 +1010,7 @@ void DivPlatformYM2203::poke(std::vector<DivRegWrite>& wlist) {
|
|||
|
||||
void DivPlatformYM2203::reset() {
|
||||
while (!writes.empty()) writes.pop();
|
||||
memset(regPool,0,512);
|
||||
memset(regPool,0,256);
|
||||
if (dumpWrites) {
|
||||
addWrite(0xffffffff,0);
|
||||
}
|
||||
|
@ -1032,7 +1027,7 @@ void DivPlatformYM2203::reset() {
|
|||
chan[i].vol=0x0f;
|
||||
}
|
||||
|
||||
for (int i=0; i<512; i++) {
|
||||
for (int i=0; i<256; i++) {
|
||||
oldWrites[i]=-1;
|
||||
pendingWrites[i]=-1;
|
||||
}
|
||||
|
|
|
@ -32,8 +32,8 @@ class DivYM2203Interface: public ymfm::ymfm_interface {
|
|||
|
||||
class DivPlatformYM2203: public DivDispatch {
|
||||
protected:
|
||||
const unsigned short chanOffs[6]={
|
||||
0x00, 0x01, 0x02, 0x100, 0x101, 0x102
|
||||
const unsigned short chanOffs[3]={
|
||||
0x00, 0x01, 0x02
|
||||
};
|
||||
|
||||
struct Channel {
|
||||
|
@ -101,10 +101,9 @@ class DivPlatformYM2203: public DivDispatch {
|
|||
|
||||
bool extMode;
|
||||
|
||||
short oldWrites[512];
|
||||
short pendingWrites[512];
|
||||
short oldWrites[256];
|
||||
short pendingWrites[256];
|
||||
|
||||
double NOTE_OPN(int ch, int note);
|
||||
friend void putDispatchChan(void*,int,int);
|
||||
|
||||
public:
|
||||
|
|
1449
src/engine/platform/ym2608.cpp
Normal file
1449
src/engine/platform/ym2608.cpp
Normal file
File diff suppressed because it is too large
Load diff
130
src/engine/platform/ym2608.h
Normal file
130
src/engine/platform/ym2608.h
Normal file
|
@ -0,0 +1,130 @@
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _YM2608_H
|
||||
#define _YM2608_H
|
||||
#include "../dispatch.h"
|
||||
#include "../macroInt.h"
|
||||
#include <queue>
|
||||
#include "sound/ymfm/ymfm_opn.h"
|
||||
|
||||
#include "ym2610.h"
|
||||
|
||||
class DivPlatformYM2608: public DivPlatformYM2610Base {
|
||||
protected:
|
||||
const unsigned short chanOffs[6]={
|
||||
0x00, 0x01, 0x02, 0x100, 0x101, 0x102
|
||||
};
|
||||
|
||||
struct Channel {
|
||||
DivInstrumentFM state;
|
||||
unsigned char freqH, freqL;
|
||||
int freq, baseFreq, pitch, pitch2, portaPauseFreq, note, ins;
|
||||
unsigned char psgMode, autoEnvNum, autoEnvDen;
|
||||
signed char konCycles;
|
||||
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta, furnacePCM, hardReset;
|
||||
int vol, outVol;
|
||||
int sample;
|
||||
unsigned char pan;
|
||||
DivMacroInt std;
|
||||
void macroInit(DivInstrument* which) {
|
||||
std.init(which);
|
||||
pitch2=0;
|
||||
}
|
||||
Channel():
|
||||
freqH(0),
|
||||
freqL(0),
|
||||
freq(0),
|
||||
baseFreq(0),
|
||||
pitch(0),
|
||||
pitch2(0),
|
||||
portaPauseFreq(0),
|
||||
note(0),
|
||||
ins(-1),
|
||||
psgMode(1),
|
||||
autoEnvNum(0),
|
||||
autoEnvDen(0),
|
||||
active(false),
|
||||
insChanged(true),
|
||||
freqChanged(false),
|
||||
keyOn(false),
|
||||
keyOff(false),
|
||||
portaPause(false),
|
||||
inPorta(false),
|
||||
furnacePCM(false),
|
||||
hardReset(false),
|
||||
vol(0),
|
||||
outVol(15),
|
||||
sample(-1),
|
||||
pan(3) {}
|
||||
};
|
||||
Channel chan[16];
|
||||
DivDispatchOscBuffer* oscBuf[16];
|
||||
bool isMuted[16];
|
||||
struct QueuedWrite {
|
||||
unsigned short addr;
|
||||
unsigned char val;
|
||||
bool addrOrVal;
|
||||
QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v), addrOrVal(false) {}
|
||||
};
|
||||
std::queue<QueuedWrite> writes;
|
||||
ymfm::ym2608* fm;
|
||||
ymfm::ym2608::output_data fmout;
|
||||
unsigned char regPool[512];
|
||||
unsigned char lastBusy;
|
||||
|
||||
DivPlatformAY8910* ay;
|
||||
unsigned char sampleBank;
|
||||
|
||||
int delay;
|
||||
|
||||
bool extMode;
|
||||
|
||||
short oldWrites[512];
|
||||
short pendingWrites[512];
|
||||
|
||||
double NOTE_OPNB(int ch, int note);
|
||||
double NOTE_ADPCMB(int note);
|
||||
friend void putDispatchChan(void*,int,int);
|
||||
|
||||
public:
|
||||
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
void* getChanState(int chan);
|
||||
DivDispatchOscBuffer* getOscBuffer(int chan);
|
||||
unsigned char* getRegisterPool();
|
||||
int getRegisterPoolSize();
|
||||
void reset();
|
||||
void forceIns();
|
||||
void tick(bool sysTick=true);
|
||||
void muteChannel(int ch, bool mute);
|
||||
bool isStereo();
|
||||
bool keyOffAffectsArp(int ch);
|
||||
void notifyInsChange(int ins);
|
||||
void notifyInsDeletion(void* ins);
|
||||
void setSkipRegisterWrites(bool val);
|
||||
void poke(unsigned int addr, unsigned short val);
|
||||
void poke(std::vector<DivRegWrite>& wlist);
|
||||
const char** getRegisterSheet();
|
||||
const char* getEffectName(unsigned char effect);
|
||||
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
|
||||
void quit();
|
||||
~DivPlatformYM2608();
|
||||
};
|
||||
#endif
|
|
@ -1259,7 +1259,7 @@ void DivEngine::registerSystems() {
|
|||
);
|
||||
|
||||
sysDefs[DIV_SYSTEM_OPN]=new DivSysDef(
|
||||
"Yamaha YM2203 (OPN)", NULL, 0x8d, 0, 6, true, false, 0, false,
|
||||
"Yamaha YM2203 (OPN)", NULL, 0x8d, 0, 6, true, false, 0x151, false,
|
||||
{"FM 1", "FM 2", "FM 3", "PSG 1", "PSG 2", "PSG 3"},
|
||||
{"F1", "F2", "F3", "S1", "S2", "S3"},
|
||||
{DIV_CH_FM, DIV_CH_FM, DIV_CH_FM, DIV_CH_PULSE, DIV_CH_PULSE, DIV_CH_PULSE},
|
||||
|
|
|
@ -530,6 +530,11 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write
|
|||
break;
|
||||
}
|
||||
break;
|
||||
case DIV_SYSTEM_OPN:
|
||||
w->writeC(5|baseAddr1);
|
||||
w->writeC(write.addr&0xff);
|
||||
w->writeC(write.val);
|
||||
break;
|
||||
case DIV_SYSTEM_OPLL:
|
||||
case DIV_SYSTEM_OPLL_DRUMS:
|
||||
case DIV_SYSTEM_VRC7:
|
||||
|
@ -949,6 +954,18 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version) {
|
|||
howManyChips++;
|
||||
}
|
||||
break;
|
||||
case DIV_SYSTEM_OPN:
|
||||
if (!hasOPN) {
|
||||
hasOPN=disCont[i].dispatch->chipClock;
|
||||
willExport[i]=true;
|
||||
writeDACSamples=true;
|
||||
} else if (!(hasOPN&0x40000000)) {
|
||||
isSecond[i]=true;
|
||||
willExport[i]=true;
|
||||
hasOPN|=0x40000000;
|
||||
howManyChips++;
|
||||
}
|
||||
break;
|
||||
case DIV_SYSTEM_OPLL:
|
||||
case DIV_SYSTEM_OPLL_DRUMS:
|
||||
case DIV_SYSTEM_VRC7:
|
||||
|
|
|
@ -355,6 +355,21 @@ void FurnaceGUI::drawSysConf(int chan, DivSystem type, unsigned int& flags, bool
|
|||
}
|
||||
break;
|
||||
}
|
||||
case DIV_SYSTEM_OPN: {
|
||||
if (ImGui::RadioButton("NTSC (3.58MHz)",(flags&3)==0)) {
|
||||
copyOfFlags=(flags&0x80000000)|0;
|
||||
}
|
||||
if (ImGui::RadioButton("PAL (3.54MHz)",(flags&3)==1)) {
|
||||
copyOfFlags=(flags&0x80000000)|1;
|
||||
}
|
||||
if (ImGui::RadioButton("Arcade (4MHz)",(flags&3)==2)) {
|
||||
copyOfFlags=(flags&0x80000000)|2;
|
||||
}
|
||||
if (ImGui::RadioButton("PC-9801-26K? TODO: CONFIRM (3MHz)",(flags&3)==3)) {
|
||||
copyOfFlags=(flags&0x80000000)|3;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DIV_SYSTEM_GB:
|
||||
case DIV_SYSTEM_SWAN:
|
||||
case DIV_SYSTEM_VERA:
|
||||
|
|
Loading…
Reference in a new issue