Merge pull request #1342 from tildearrow/c140

Chicken ice cream
This commit is contained in:
tildearrow 2023-08-12 16:29:49 -05:00 committed by GitHub
commit fc16164dbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 1111 additions and 13 deletions

View File

@ -507,6 +507,8 @@ src/engine/platform/sound/d65modified.c
src/engine/platform/sound/ted-sound.c
src/engine/platform/sound/c140.c
src/engine/platform/oplAInterface.cpp
src/engine/platform/ym2608Interface.cpp
src/engine/platform/ym2610Interface.cpp
@ -599,6 +601,7 @@ src/engine/platform/sm8521.cpp
src/engine/platform/pv1000.cpp
src/engine/platform/k053260.cpp
src/engine/platform/ted.cpp
src/engine/platform/c140.cpp
src/engine/platform/pcmdac.cpp
src/engine/platform/dummy.cpp

View File

@ -219,6 +219,7 @@ size | description
| - 0xcb: Casio PV-1000 - 3 channels
| - 0xcc: K053260 - 4 channels
| - 0xcd: TED - 2 channels
| - 0xce: Namco C140 - 24 channels
| - 0xde: YM2610B extended - 19 channels
| - 0xe0: QSound - 19 channels
| - 0xfc: Pong - 1 channel

View File

@ -119,6 +119,7 @@ the following instrument types are available:
- 49: PV-1000
- 50: K053260
- 52: TED
- 53: C140
the following feature codes are recognized:

View File

@ -80,6 +80,7 @@
#include "platform/pv1000.h"
#include "platform/k053260.h"
#include "platform/ted.h"
#include "platform/c140.h"
#include "platform/pcmdac.h"
#include "platform/dummy.h"
#include "../ta-log.h"
@ -504,6 +505,9 @@ void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, do
case DIV_SYSTEM_TED:
dispatch=new DivPlatformTED;
break;
case DIV_SYSTEM_C140:
dispatch=new DivPlatformC140;
break;
case DIV_SYSTEM_PCM_DAC:
dispatch=new DivPlatformPCMDAC;
break;

View File

@ -963,6 +963,10 @@ void DivInstrument::putInsData2(SafeWriter* w, bool fui, const DivSong* song) {
break;
case DIV_INS_TED:
break;
case DIV_INS_C140:
featureSM=true;
featureSL=true;
break;
case DIV_INS_MAX:
break;

View File

@ -83,6 +83,7 @@ enum DivInstrumentType: unsigned short {
DIV_INS_K053260=50,
// DIV_INS_YMF292=51,
DIV_INS_TED=52,
DIV_INS_C140=53,
DIV_INS_MAX,
DIV_INS_NULL
};

View File

@ -0,0 +1,509 @@
/**
* Furnace Tracker - multi-system chiptune tracker
* Copyright (C) 2021-2023 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 "c140.h"
#include "../engine.h"
#include "../../ta-log.h"
#include <math.h>
#include <map>
#define CHIP_FREQBASE 12582912
#define rWrite(a,v) {if(!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if(dumpWrites) addWrite(a,v); }}
const char* regCheatSheetC140[]={
"CHx_RVol", "00+x*10",
"CHx_LVol", "01+x*10",
"CHx_FreqH", "02+x*10",
"CHx_FreqL", "03+x*10",
"CHx_Bank", "04+x*10",
"CHx_Ctrl", "05+x*10",
"CHx_StartH", "06+x*10",
"CHx_StartL", "07+x*10",
"CHx_EndH", "08+x*10",
"CHx_EndL", "09+x*10",
"CHx_LoopH", "0A+x*10",
"CHx_LoopL", "0B+x*10",
"Timer", "1FA",
"IRQ", "1FE",
NULL
};
const char** DivPlatformC140::getRegisterSheet() {
return regCheatSheetC140;
}
void DivPlatformC140::acquire(short** buf, size_t len) {
for (size_t h=0; h<len; h++) {
while (!writes.empty()) {
QueuedWrite w=writes.front();
c140_write(&c140, w.addr,w.val);
regPool[w.addr&0x1ff]=w.val;
writes.pop();
}
c140_tick(&c140, 1);
// scale as 16bit
c140.lout >>= 10;
c140.rout >>= 10;
if (c140.lout<-32768) c140.lout=-32768;
if (c140.lout>32767) c140.lout=32767;
if (c140.rout<-32768) c140.rout=-32768;
if (c140.rout>32767) c140.rout=32767;
buf[0][h]=c140.lout;
buf[1][h]=c140.rout;
for (int i=0; i<24; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=(c140.voice[i].lout+c140.voice[i].rout)>>9;
}
}
}
void DivPlatformC140::tick(bool sysTick) {
for (int i=0; i<24; i++) {
chan[i].std.next();
if (chan[i].std.vol.had) {
chan[i].outVol=(chan[i].vol*MIN(chan[i].macroVolMul,chan[i].std.vol.val))/chan[i].macroVolMul;
chan[i].volChangedL=true;
chan[i].volChangedR=true;
}
if (NEW_ARP_STRAT) {
chan[i].handleArp();
} else if (chan[i].std.arp.had) {
if (!chan[i].inPorta) {
chan[i].baseFreq=NOTE_FREQUENCY(parent->calcArp(chan[i].note,chan[i].std.arp.val));
}
chan[i].freqChanged=true;
}
if (chan[i].std.pitch.had) {
if (chan[i].std.pitch.mode) {
chan[i].pitch2+=chan[i].std.pitch.val;
CLAMP_VAR(chan[i].pitch2,-32768,32767);
} else {
chan[i].pitch2=chan[i].std.pitch.val;
}
chan[i].freqChanged=true;
}
if (chan[i].std.panL.had) {
chan[i].chPanL=(255*(chan[i].std.panL.val&255))/chan[i].macroPanMul;
chan[i].volChangedL=true;
}
if (chan[i].std.panR.had) {
chan[i].chPanR=(255*(chan[i].std.panR.val&255))/chan[i].macroPanMul;
chan[i].volChangedR=true;
}
if (chan[i].std.phaseReset.had) {
if ((chan[i].std.phaseReset.val==1) && chan[i].active) {
chan[i].audPos=0;
chan[i].setPos=true;
}
}
if (chan[i].volChangedL) {
chan[i].chVolL=(chan[i].outVol*chan[i].chPanL)/255;
rWrite(1+(i<<4),chan[i].chVolL);
chan[i].volChangedL=false;
}
if (chan[i].volChangedR) {
chan[i].chVolR=(chan[i].outVol*chan[i].chPanR)/255;
rWrite(0+(i<<4),chan[i].chVolR);
chan[i].volChangedR=false;
}
if (chan[i].setPos) {
// force keyon
chan[i].keyOn=true;
chan[i].setPos=false;
} else {
chan[i].audPos=0;
}
if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) {
bool writeCtrl=false;
DivSample* s=parent->getSample(chan[i].sample);
unsigned char ctrl=0;
double off=(s->centerRate>=1)?((double)s->centerRate/8363.0):1.0;
chan[i].freq=(int)(off*parent->calcFreq(chan[i].baseFreq,chan[i].pitch,chan[i].fixedArp?chan[i].baseNoteOverride:chan[i].arpOff,chan[i].fixedArp,false,2,chan[i].pitch2,chipClock,CHIP_FREQBASE));
if (chan[i].freq<0) chan[i].freq=0;
if (chan[i].freq>65535) chan[i].freq=65535;
ctrl|=(chan[i].active?0x80:0)|((s->isLoopable())?0x10:0)|((s->depth==DIV_SAMPLE_DEPTH_MULAW)?0x08:0);
if (chan[i].keyOn) {
unsigned int bank=0;
unsigned int start=0;
unsigned int loop=0;
unsigned int end=0;
if (chan[i].sample>=0 && chan[i].sample<parent->song.sampleLen) {
bank=(sampleOff[chan[i].sample]>>16)&0xff;
start=sampleOff[chan[i].sample]&0xffff;
end=MIN(start+s->length8-1,65535);
}
if (chan[i].audPos>0) {
start=MIN(start+MIN(chan[i].audPos,s->length8),65535);
}
if (s->isLoopable()) {
loop=MIN(start+s->loopStart,65535);
end=MIN(start+s->loopEnd-1,65535);
}
rWrite(0x05+(i<<4),0); // force keyoff first
rWrite(0x04+(i<<4),bank);
rWrite(0x06+(i<<4),(start>>8)&0xff);
rWrite(0x07+(i<<4),start&0xff);
rWrite(0x08+(i<<4),(end>>8)&0xff);
rWrite(0x09+(i<<4),end&0xff);
rWrite(0x0a+(i<<4),(loop>>8)&0xff);
rWrite(0x0b+(i<<4),loop&0xff);
if (!chan[i].std.vol.had) {
chan[i].outVol=chan[i].vol;
chan[i].volChangedL=true;
chan[i].volChangedR=true;
}
writeCtrl=true;
chan[i].keyOn=false;
}
if (chan[i].keyOff) {
writeCtrl=true;
chan[i].keyOff=false;
}
if (chan[i].freqChanged) {
rWrite(0x02+(i<<4),chan[i].freq>>8);
rWrite(0x03+(i<<4),chan[i].freq&0xff);
chan[i].freqChanged=false;
}
if (writeCtrl) {
rWrite(0x05+(i<<4),ctrl);
}
}
}
}
int DivPlatformC140::dispatch(DivCommand c) {
switch (c.cmd) {
case DIV_CMD_NOTE_ON: {
DivInstrument* ins=parent->getIns(chan[c.chan].ins,DIV_INS_AMIGA);
chan[c.chan].macroVolMul=ins->type==DIV_INS_AMIGA?64:255;
chan[c.chan].macroPanMul=ins->type==DIV_INS_AMIGA?127:255;
if (c.value!=DIV_NOTE_NULL) {
chan[c.chan].sample=ins->amiga.getSample(c.value);
c.value=ins->amiga.getFreq(c.value);
}
if (c.value!=DIV_NOTE_NULL) {
chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value);
}
if (chan[c.chan].sample<0 || chan[c.chan].sample>=parent->song.sampleLen) {
chan[c.chan].sample=-1;
}
if (c.value!=DIV_NOTE_NULL) {
chan[c.chan].freqChanged=true;
chan[c.chan].note=c.value;
}
chan[c.chan].active=true;
chan[c.chan].keyOn=true;
chan[c.chan].macroInit(ins);
if (!parent->song.brokenOutVol && !chan[c.chan].std.vol.will) {
chan[c.chan].outVol=chan[c.chan].vol;
chan[c.chan].volChangedL=true;
chan[c.chan].volChangedR=true;
}
break;
}
case DIV_CMD_NOTE_OFF:
chan[c.chan].sample=-1;
chan[c.chan].active=false;
chan[c.chan].keyOff=true;
chan[c.chan].macroInit(NULL);
break;
case DIV_CMD_NOTE_OFF_ENV:
case DIV_CMD_ENV_RELEASE:
chan[c.chan].std.release();
break;
case DIV_CMD_INSTRUMENT:
if (chan[c.chan].ins!=c.value || c.value2==1) {
chan[c.chan].ins=c.value;
}
break;
case DIV_CMD_VOLUME:
chan[c.chan].vol=c.value;
if (!chan[c.chan].std.vol.has) {
chan[c.chan].outVol=c.value;
}
chan[c.chan].volChangedL=true;
chan[c.chan].volChangedR=true;
break;
case DIV_CMD_GET_VOLUME:
if (chan[c.chan].std.vol.has) {
return chan[c.chan].vol;
}
return chan[c.chan].outVol;
break;
case DIV_CMD_PANNING:
chan[c.chan].chPanL=c.value;
chan[c.chan].chPanR=c.value2;
chan[c.chan].volChangedL=true;
chan[c.chan].volChangedR=true;
break;
case DIV_CMD_PITCH:
chan[c.chan].pitch=c.value;
chan[c.chan].freqChanged=true;
break;
case DIV_CMD_NOTE_PORTA: {
int destFreq=NOTE_FREQUENCY(c.value2);
bool return2=false;
if (destFreq>chan[c.chan].baseFreq) {
chan[c.chan].baseFreq+=c.value;
if (chan[c.chan].baseFreq>=destFreq) {
chan[c.chan].baseFreq=destFreq;
return2=true;
}
} else {
chan[c.chan].baseFreq-=c.value;
if (chan[c.chan].baseFreq<=destFreq) {
chan[c.chan].baseFreq=destFreq;
return2=true;
}
}
chan[c.chan].freqChanged=true;
if (return2) {
chan[c.chan].inPorta=false;
return 2;
}
break;
}
case DIV_CMD_LEGATO: {
chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value+((HACKY_LEGATO_MESS)?(chan[c.chan].std.arp.val-12):(0)));
chan[c.chan].freqChanged=true;
chan[c.chan].note=c.value;
break;
}
case DIV_CMD_PRE_PORTA:
if (chan[c.chan].active && c.value2) {
if (parent->song.resetMacroOnPorta) chan[c.chan].macroInit(parent->getIns(chan[c.chan].ins,DIV_INS_AMIGA));
}
if (!chan[c.chan].inPorta && c.value && !parent->song.brokenPortaArp && chan[c.chan].std.arp.will && !NEW_ARP_STRAT) chan[c.chan].baseFreq=NOTE_FREQUENCY(chan[c.chan].note);
chan[c.chan].inPorta=c.value;
break;
case DIV_CMD_SAMPLE_POS:
chan[c.chan].audPos=c.value;
chan[c.chan].setPos=true;
break;
case DIV_CMD_GET_VOLMAX:
return 255;
break;
case DIV_CMD_MACRO_OFF:
chan[c.chan].std.mask(c.value,true);
break;
case DIV_CMD_MACRO_ON:
chan[c.chan].std.mask(c.value,false);
break;
case DIV_ALWAYS_SET_VOLUME:
return 1;
break;
default:
break;
}
return 1;
}
void DivPlatformC140::muteChannel(int ch, bool mute) {
isMuted[ch]=mute;
c140.voice[ch].muted=mute;
}
void DivPlatformC140::forceIns() {
for (int i=0; i<24; i++) {
chan[i].insChanged=true;
chan[i].freqChanged=true;
chan[i].volChangedL=true;
chan[i].volChangedR=true;
chan[i].sample=-1;
}
}
void* DivPlatformC140::getChanState(int ch) {
return &chan[ch];
}
DivMacroInt* DivPlatformC140::getChanMacroInt(int ch) {
return &chan[ch].std;
}
DivDispatchOscBuffer* DivPlatformC140::getOscBuffer(int ch) {
return oscBuf[ch];
}
void DivPlatformC140::reset() {
while (!writes.empty()) writes.pop();
memset(regPool,0,512);
c140_reset(&c140);
for (int i=0; i<24; i++) {
chan[i]=DivPlatformC140::Channel();
chan[i].std.setEngine(parent);
rWrite(0x05+(i<<4),0);
}
}
int DivPlatformC140::getOutputCount() {
return 2;
}
void DivPlatformC140::notifyInsChange(int ins) {
for (int i=0; i<24; i++) {
if (chan[i].ins==ins) {
chan[i].insChanged=true;
}
}
}
void DivPlatformC140::notifyWaveChange(int wave) {
// TODO when wavetables are added
// TODO they probably won't be added unless the samples reside in RAM
}
void DivPlatformC140::notifyInsDeletion(void* ins) {
for (int i=0; i<24; i++) {
chan[i].std.notifyInsDeletion((DivInstrument*)ins);
}
}
void DivPlatformC140::poke(unsigned int addr, unsigned short val) {
rWrite(addr,val);
}
void DivPlatformC140::poke(std::vector<DivRegWrite>& wlist) {
for (DivRegWrite& i: wlist) rWrite(i.addr,i.val);
}
unsigned char* DivPlatformC140::getRegisterPool() {
return regPool;
}
int DivPlatformC140::getRegisterPoolSize() {
return 512;
}
const void* DivPlatformC140::getSampleMem(int index) {
return index == 0 ? sampleMem : NULL;
}
size_t DivPlatformC140::getSampleMemCapacity(int index) {
return index == 0 ? 16777216 : 0;
}
size_t DivPlatformC140::getSampleMemUsage(int index) {
return index == 0 ? sampleMemLen : 0;
}
bool DivPlatformC140::isSampleLoaded(int index, int sample) {
if (index!=0) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[sample];
}
void DivPlatformC140::renderSamples(int sysID) {
memset(sampleMem,0,getSampleMemCapacity());
memset(sampleOff,0,256*sizeof(unsigned int));
memset(sampleLoaded,0,256*sizeof(bool));
size_t memPos=0;
for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i];
if (!s->renderOn[0][sysID]) {
sampleOff[i]=0;
continue;
}
unsigned int length=s->length16;
// fit sample size to single bank size
if (length>(131072)) {
length=131072;
}
if ((memPos&0xfe0000)!=((memPos+length)&0xfe0000)) {
memPos=((memPos+0x1ffff)&0xfe0000);
}
if (memPos>=(getSampleMemCapacity())) {
logW("out of C140 memory for sample %d!",i);
break;
}
// why is C140 not G.711-compliant? this weird bit mangling had me puzzled for 3 hours...
if (memPos+length>=(getSampleMemCapacity())) {
if (s->depth==DIV_SAMPLE_DEPTH_MULAW) {
for (unsigned int i=0; i<(getSampleMemCapacity())-memPos; i++) {
unsigned char x=s->dataMuLaw[i]^0xff;
if (x&0x80) x^=15;
unsigned char c140Mu=(x&0x80)|((x&15)<<3)|((x&0x70)>>4);
sampleMem[i+(memPos/sizeof(short))]=((c140Mu)<<8);
}
} else {
memcpy(sampleMem+(memPos/sizeof(short)),s->data16,(getSampleMemCapacity())-memPos);
}
logW("out of C140 memory for sample %d!",i);
} else {
if (s->depth==DIV_SAMPLE_DEPTH_MULAW) {
for (unsigned int i=0; i<length; i++) {
unsigned char x=s->dataMuLaw[i]^0xff;
if (x&0x80) x^=15;
unsigned char c140Mu=(x&0x80)|((x&15)<<3)|((x&0x70)>>4);
sampleMem[i+(memPos/sizeof(short))]=((c140Mu)<<8);
}
} else {
memcpy(sampleMem+(memPos/sizeof(short)),s->data16,length);
}
}
sampleOff[i]=memPos>>1;
sampleLoaded[i]=true;
memPos+=length;
}
sampleMemLen=memPos+256;
}
void DivPlatformC140::setFlags(const DivConfig& flags) {
chipClock=32000*256; // 8.192MHz and 12.288MHz input, verified from Assault Schematics
CHECK_CUSTOM_CLOCK;
rate=chipClock/192;
for (int i=0; i<24; i++) {
oscBuf[i]->rate=rate;
}
}
int DivPlatformC140::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) {
parent=p;
dumpWrites=false;
skipRegisterWrites=false;
for (int i=0; i<24; i++) {
isMuted[i]=false;
oscBuf[i]=new DivDispatchOscBuffer;
}
sampleMem=new short[getSampleMemCapacity()>>1];
sampleMemLen=0;
c140_init(&c140);
c140.sample_mem=sampleMem;
setFlags(flags);
reset();
return 24;
}
void DivPlatformC140::quit() {
delete[] sampleMem;
for (int i=0; i<24; i++) {
delete oscBuf[i];
}
}

102
src/engine/platform/c140.h Normal file
View File

@ -0,0 +1,102 @@
/**
* Furnace Tracker - multi-system chiptune tracker
* Copyright (C) 2021-2023 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 _C140_H
#define _C140_H
#include "../dispatch.h"
#include "sound/c140.h"
#include "../fixedQueue.h"
class DivPlatformC140: public DivDispatch {
struct Channel: public SharedChannel<int> {
unsigned int audPos;
int sample, wave;
bool setPos, volChangedL, volChangedR;
int chPanL, chPanR;
int chVolL, chVolR;
int macroVolMul;
int macroPanMul;
Channel():
SharedChannel<int>(255),
audPos(0),
sample(-1),
wave(-1),
setPos(false),
volChangedL(false),
volChangedR(false),
chPanL(255),
chPanR(255),
chVolL(255),
chVolR(255),
macroVolMul(64),
macroPanMul(127) {}
};
Channel chan[24];
DivDispatchOscBuffer* oscBuf[24];
bool isMuted[24];
unsigned int sampleOff[256];
bool sampleLoaded[256];
signed short* sampleMem;
size_t sampleMemLen;
struct QueuedWrite {
unsigned short addr;
unsigned char val;
bool addrOrVal;
QueuedWrite(): addr(0), val(0), addrOrVal(false) {}
QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v), addrOrVal(false) {}
};
FixedQueue<QueuedWrite,2048> writes;
struct c140_t c140;
unsigned char regPool[512];
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
DivDispatchOscBuffer* getOscBuffer(int chan);
unsigned char* getRegisterPool();
int getRegisterPoolSize();
void reset();
void forceIns();
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
int getOutputCount();
void notifyInsChange(int ins);
void notifyWaveChange(int wave);
void notifyInsDeletion(void* ins);
void poke(unsigned int addr, unsigned short val);
void poke(std::vector<DivRegWrite>& wlist);
const char** getRegisterSheet();
const void* getSampleMem(int index = 0);
size_t getSampleMemCapacity(int index = 0);
size_t getSampleMemUsage(int index = 0);
bool isSampleLoaded(int index, int sample);
void renderSamples(int chipID);
void setFlags(const DivConfig& flags);
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit();
private:
};
#endif

View File

@ -0,0 +1,205 @@
/*
============================================================================
MODIFIED Namco C140 sound emulator - MODIFIED VERSION
by cam900
MODIFICATION by tildearrow - adds muting function
THIS IS NOT THE ORIGINAL VERSION - you can find the original one in
commit 72d04777c013988ed8cf6da27c62a9d784a59dff
This file is licensed under zlib license.
============================================================================
zlib License
(C) 2023-present cam900 and contributors
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
============================================================================
TODO:
- unknown registers (Bit 6 of control register, etc)
- Internal timer
*/
#include "c140.h"
static int c140_max(int a, int b) { return (a > b) ? a : b; }
static int c140_min(int a, int b) { return (a < b) ? a : b; }
static int c140_clamp(int v, int min, int max) { return c140_min(c140_max(v,min),max); }
static int c140_bit(int val, int bit) { return (val >> bit) & 1; }
static int c140_bitfield(int val, int bit, int len) { return (val >> bit) & ((1 << len) - 1);}
void c140_tick(struct c140_t *c140, const int cycle)
{
c140->lout = 0;
c140->rout = 0;
for (int i = 0; i < 24; i++)
{
c140_voice_tick(c140, i, cycle);
c140->lout += c140->voice[i].lout;
c140->rout += c140->voice[i].rout;
}
}
void c140_voice_tick(struct c140_t *c140, const unsigned char v, const int cycle)
{
struct c140_voice_t *voice = &c140->voice[v];
if (voice->busy && voice->keyon)
{
for (int c = 0; c < cycle; c++)
{
voice->frac += voice->freq;
if (voice->frac > 0xffff)
{
voice->addr += voice->frac >> 16;
if (voice->addr > voice->end_addr)
{
if (voice->loop)
{
voice->addr = (voice->addr + voice->loop_addr) - voice->end_addr;
}
else
{
voice->keyon = false;
voice->lout = 0;
voice->rout = 0;
return;
}
}
voice->frac &= 0xffff;
}
}
if (!voice->muted)
{
// fetch 12 bit sample
signed short s1 = c140->sample_mem[((unsigned int)(voice->bank) << 16) | voice->addr] & ~0xf;
signed short s2 = c140->sample_mem[((unsigned int)(voice->bank) << 16) | ((voice->addr + 1) & 0xffff)] & ~0xf;
if (voice->compressed)
{
s1 = c140->mulaw[(s1 >> 8) & 0xff];
s2 = c140->mulaw[(s2 >> 8) & 0xff];
}
// interpolate
signed int sample = s1 + (((voice->frac) * (s2 - s1)) >> 16);
voice->lout = sample * voice->lvol;
voice->rout = sample * voice->rvol;
}
else
{
voice->lout = 0;
voice->rout = 0;
}
}
else
{
voice->lout = 0;
voice->rout = 0;
}
}
void c140_keyon(struct c140_voice_t *c140_voice)
{
c140_voice->busy = true;
c140_voice->keyon = true;
c140_voice->frac = 0;
c140_voice->addr = c140_voice->start_addr;
}
void c140_init(struct c140_t *c140)
{
// u-law table verified from Wii Virtual Console Arcade Starblade
for (int i = 0; i < 256; i++)
{
const unsigned char exponent = c140_bitfield(i, 0, 3);
const unsigned char mantissa = c140_bitfield(i, 3, 4);
if (c140_bit(i, 7))
{
c140->mulaw[i] = (signed short)(((exponent ? 0xfe00 : 0xff00) | (mantissa << 4))
<< (exponent ? exponent - 1 : 0));
}
else
{
c140->mulaw[i] = (signed short)(((exponent ? 0x100 : 0) | (mantissa << 4))
<< (exponent ? exponent - 1 : 0));
}
}
for (int i = 0; i < 24; i++)
{
c140->voice[i].muted = false;
}
}
void c140_reset(struct c140_t *c140)
{
for (int i = 0; i < 24; i++)
{
c140->voice[i].busy = false;
c140->voice[i].keyon = false;
c140->voice[i].freq = 0;
c140->voice[i].bank = 0;
c140->voice[i].start_addr = 0;
c140->voice[i].loop_addr = 0;
c140->voice[i].end_addr = 0;
c140->voice[i].lvol = 0;
c140->voice[i].rvol = 0;
c140->voice[i].compressed = false;
c140->voice[i].loop = false;
c140->voice[i].addr = 0;
c140->voice[i].frac = 0;
c140->voice[i].lout = 0;
c140->voice[i].rout = 0;
}
}
void c140_write(struct c140_t *c140, const unsigned short addr, const unsigned char data)
{
// voice register
if (addr < 0x180)
{
struct c140_voice_t *voice = &c140->voice[addr >> 4];
switch (addr & 0xf)
{
case 0x0: voice->rvol = data; break;
case 0x1: voice->lvol = data; break;
case 0x2: voice->freq = (voice->freq & ~0xff00) | (unsigned int)(data << 8); break;
case 0x3: voice->freq = (voice->freq & ~0x00ff) | data; break;
case 0x4: voice->bank = data; break;
case 0x5:
voice->compressed = c140_bit(data, 3);
voice->loop = c140_bit(data, 4);
if (data & 0x80)
c140_keyon(voice);
else
voice->busy = false;
break;
case 0x6: voice->start_addr = (voice->start_addr & ~0xff00) | (unsigned int)(data << 8); break;
case 0x7: voice->start_addr = (voice->start_addr & ~0x00ff) | data; break;
case 0x8: voice->end_addr = (voice->end_addr & ~0xff00) | (unsigned int)(data << 8); break;
case 0x9: voice->end_addr = (voice->end_addr & ~0x00ff) | data; break;
case 0xa: voice->loop_addr = (voice->loop_addr & ~0xff00) | (unsigned int)(data << 8); break;
case 0xb: voice->loop_addr = (voice->loop_addr & ~0x00ff) | data; break;
default: break;
}
}
// Timer
}

View File

@ -0,0 +1,96 @@
/*
============================================================================
MODIFIED Namco C140 sound emulator - MODIFIED VERSION
by cam900
MODIFICATION by tildearrow - adds muting function
THIS IS NOT THE ORIGINAL VERSION - you can find the original one in
commit 72d04777c013988ed8cf6da27c62a9d784a59dff
This file is licensed under zlib license.
============================================================================
zlib License
(C) 2023-present cam900 and contributors
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
============================================================================
TODO:
- unknown registers (Bit 6 of control register, etc)
- Internal timer
*/
#ifndef _C140_EMU_H
#define _C140_EMU_H
#include <stdbool.h>
#ifdef __cplusplus
extern "C"
{
#endif
struct c140_voice_t
{
bool muted; // muted - can be set by user
bool busy; // busy flag
bool keyon; // key on flag
unsigned short freq; // sample frequency
unsigned char bank; // sample bank
unsigned short start_addr; // sample start address
unsigned short loop_addr; // sample loop address
unsigned short end_addr; // sample end address
int lvol, rvol; // left/right volume
bool compressed; // compressed sample flag
bool loop; // loop flag
unsigned short addr; // sample address
int frac; // frequency counter (.16 fixed point)
int lout, rout; // left/right output
};
struct c140_t
{
struct c140_voice_t voice[24];
signed int lout, rout;
signed short mulaw[256];
signed short *sample_mem;
};
void c140_tick(struct c140_t *c140, const int cycle);
void c140_voice_tick(struct c140_t *c140, const unsigned char v, const int cycle);
void c140_keyon(struct c140_voice_t *c140_voice);
void c140_write(struct c140_t *c140, const unsigned short addr, const unsigned char data);
void c140_init(struct c140_t *c140);
void c140_reset(struct c140_t *c140);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // _C140_EMU_H

View File

@ -269,6 +269,9 @@ int DivSample::getSampleOffset(int offset, int length, DivSampleDepth depth) {
case DIV_SAMPLE_DEPTH_VOX:
off=(offset+1)/2;
break;
case DIV_SAMPLE_DEPTH_MULAW:
off=offset;
break;
case DIV_SAMPLE_DEPTH_16BIT:
off=offset*2;
break;
@ -316,6 +319,10 @@ int DivSample::getSampleOffset(int offset, int length, DivSampleDepth depth) {
off=(offset+1)/2;
len=(length+1)/2;
break;
case DIV_SAMPLE_DEPTH_MULAW:
off=offset;
len=length;
break;
case DIV_SAMPLE_DEPTH_16BIT:
off=offset*2;
len=length*2;
@ -365,6 +372,9 @@ int DivSample::getEndPosition(DivSampleDepth depth) {
case DIV_SAMPLE_DEPTH_VOX:
off=lengthVOX;
break;
case DIV_SAMPLE_DEPTH_MULAW:
off=lengthMuLaw;
break;
case DIV_SAMPLE_DEPTH_16BIT:
off=length16;
break;
@ -538,6 +548,12 @@ bool DivSample::initInternal(DivSampleDepth d, int count) {
dataVOX=new unsigned char[lengthVOX];
memset(dataVOX,0,lengthVOX);
break;
case DIV_SAMPLE_DEPTH_MULAW: // 8-bit µ-law
if (dataMuLaw!=NULL) delete[] dataMuLaw;
lengthMuLaw=count;
dataMuLaw=new unsigned char[(count+4095)&(~0xfff)];
memset(dataMuLaw,0,(count+4095)&(~0xfff));
break;
case DIV_SAMPLE_DEPTH_16BIT: // 16-bit
if (data16!=NULL) delete[] data16;
length16=count*2;
@ -1112,6 +1128,11 @@ bool DivSample::resample(double sRate, double tRate, int filter) {
#define NOT_IN_FORMAT(x) (depth!=x && formatMask&(1U<<(unsigned int)x))
union IntFloat {
unsigned int i;
float f;
};
void DivSample::render(unsigned int formatMask) {
// step 1: convert to 16-bit if needed
if (depth!=DIV_SAMPLE_DEPTH_16BIT) {
@ -1155,6 +1176,14 @@ void DivSample::render(unsigned int formatMask) {
case DIV_SAMPLE_DEPTH_VOX: // VOX
oki_decode(dataVOX,data16,samples);
break;
case DIV_SAMPLE_DEPTH_MULAW: // 8-bit µ-law PCM
for (unsigned int i=0; i<samples; i++) {
IntFloat s;
s.i=(dataMuLaw[i]^0xff);
s.i=0x3f800000+(((s.i<<24)&0x80000000)|((s.i&0x7f)<<19));
data16[i]=(short)(s.f*128.0f);
}
break;
default:
return;
}
@ -1233,6 +1262,17 @@ void DivSample::render(unsigned int formatMask) {
if (!initInternal(DIV_SAMPLE_DEPTH_VOX,samples)) return;
oki_encode(data16,dataVOX,samples);
}
if (NOT_IN_FORMAT(DIV_SAMPLE_DEPTH_MULAW)) { // µ-law
if (!initInternal(DIV_SAMPLE_DEPTH_MULAW,samples)) return;
for (unsigned int i=0; i<samples; i++) {
IntFloat s;
s.f=fabs(data16[i]);
s.f/=128.0f;
s.f+=1.0f;
s.i-=0x3f800000;
dataMuLaw[i]=(((data16[i]<0)?0x80:0)|(s.i&0x03f80000)>>19)^0xff;
}
}
}
void* DivSample::getCurBuf() {
@ -1255,6 +1295,8 @@ void* DivSample::getCurBuf() {
return dataBRR;
case DIV_SAMPLE_DEPTH_VOX:
return dataVOX;
case DIV_SAMPLE_DEPTH_MULAW:
return dataMuLaw;
case DIV_SAMPLE_DEPTH_16BIT:
return data16;
default:
@ -1283,6 +1325,8 @@ unsigned int DivSample::getCurBufLen() {
return lengthBRR;
case DIV_SAMPLE_DEPTH_VOX:
return lengthVOX;
case DIV_SAMPLE_DEPTH_MULAW:
return lengthMuLaw;
case DIV_SAMPLE_DEPTH_16BIT:
return length16;
default:
@ -1392,4 +1436,5 @@ DivSample::~DivSample() {
if (dataB) delete[] dataB;
if (dataBRR) delete[] dataBRR;
if (dataVOX) delete[] dataVOX;
if (dataMuLaw) delete[] dataMuLaw;
}

View File

@ -43,6 +43,7 @@ enum DivSampleDepth: unsigned char {
DIV_SAMPLE_DEPTH_8BIT=8,
DIV_SAMPLE_DEPTH_BRR=9,
DIV_SAMPLE_DEPTH_VOX=10,
DIV_SAMPLE_DEPTH_MULAW=11,
DIV_SAMPLE_DEPTH_16BIT=16,
DIV_SAMPLE_DEPTH_MAX // boundary for sample depth
};
@ -108,6 +109,7 @@ struct DivSample {
// - 8: 8-bit PCM
// - 9: BRR (SNES)
// - 10: VOX ADPCM
// - 11: 8-bit µ-law PCM
// - 16: 16-bit PCM
DivSampleDepth depth;
bool loop, brrEmphasis, dither;
@ -130,8 +132,9 @@ struct DivSample {
unsigned char* dataB; // 6
unsigned char* dataBRR; // 9
unsigned char* dataVOX; // 10
unsigned char* dataMuLaw; // 11
unsigned int length8, length16, length1, lengthDPCM, lengthZ, lengthQSoundA, lengthA, lengthB, lengthBRR, lengthVOX;
unsigned int length8, length16, length1, lengthDPCM, lengthZ, lengthQSoundA, lengthA, lengthB, lengthBRR, lengthVOX, lengthMuLaw;
unsigned int samples;
@ -337,6 +340,7 @@ struct DivSample {
dataB(NULL),
dataBRR(NULL),
dataVOX(NULL),
dataMuLaw(NULL),
length8(0),
length16(0),
length1(0),
@ -347,6 +351,7 @@ struct DivSample {
lengthB(0),
lengthBRR(0),
lengthVOX(0),
lengthMuLaw(0),
samples(0) {
for (int i=0; i<DIV_MAX_CHIPS; i++) {
for (int j=0; j<DIV_MAX_SAMPLE_TYPE; j++) {

View File

@ -129,7 +129,8 @@ enum DivSystem {
DIV_SYSTEM_SM8521,
DIV_SYSTEM_PV1000,
DIV_SYSTEM_K053260,
DIV_SYSTEM_TED
DIV_SYSTEM_TED,
DIV_SYSTEM_C140
};
enum DivEffectType: unsigned short {

View File

@ -1872,6 +1872,17 @@ void DivEngine::registerSystems() {
{}
);
sysDefs[DIV_SYSTEM_C140]=new DivSysDef(
"Namco C140", NULL, 0xce, 0, 24, false, true, 0x161, false, (1U<<DIV_SAMPLE_DEPTH_MULAW)|(1U<<DIV_SAMPLE_DEPTH_8BIT),
"Namco's first PCM chip from 1987.",
{"Channel 1", "Channel 2", "Channel 3", "Channel 4", "Channel 5", "Channel 6", "Channel 7", "Channel 8", "Channel 9", "Channel 10", "Channel 11", "Channel 12", "Channel 13", "Channel 14", "Channel 15", "Channel 16", "Channel 17", "Channel 18", "Channel 19", "Channel 20", "Channel 21", "Channel 22", "Channel 23", "Channel 24"},
{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24"},
{DIV_CH_PCM, DIV_CH_PCM, DIV_CH_PCM, DIV_CH_PCM, DIV_CH_PCM, DIV_CH_PCM, DIV_CH_PCM, DIV_CH_PCM, DIV_CH_PCM, DIV_CH_PCM, DIV_CH_PCM, DIV_CH_PCM, DIV_CH_PCM, DIV_CH_PCM, DIV_CH_PCM, DIV_CH_PCM, DIV_CH_PCM, DIV_CH_PCM, DIV_CH_PCM, DIV_CH_PCM, DIV_CH_PCM, DIV_CH_PCM, DIV_CH_PCM, DIV_CH_PCM},
{DIV_INS_C140, DIV_INS_C140, DIV_INS_C140, DIV_INS_C140, DIV_INS_C140, DIV_INS_C140, DIV_INS_C140, DIV_INS_C140, DIV_INS_C140, DIV_INS_C140, DIV_INS_C140, DIV_INS_C140, DIV_INS_C140, DIV_INS_C140, DIV_INS_C140, DIV_INS_C140, DIV_INS_C140, DIV_INS_C140, DIV_INS_C140, DIV_INS_C140, DIV_INS_C140, DIV_INS_C140, DIV_INS_C140, DIV_INS_C140},
{DIV_INS_AMIGA, DIV_INS_AMIGA, DIV_INS_AMIGA, DIV_INS_AMIGA, DIV_INS_AMIGA, DIV_INS_AMIGA, DIV_INS_AMIGA, DIV_INS_AMIGA, DIV_INS_AMIGA, DIV_INS_AMIGA, DIV_INS_AMIGA, DIV_INS_AMIGA, DIV_INS_AMIGA, DIV_INS_AMIGA, DIV_INS_AMIGA, DIV_INS_AMIGA, DIV_INS_AMIGA, DIV_INS_AMIGA, DIV_INS_AMIGA, DIV_INS_AMIGA, DIV_INS_AMIGA, DIV_INS_AMIGA, DIV_INS_AMIGA, DIV_INS_AMIGA},
{}
);
sysDefs[DIV_SYSTEM_DUMMY]=new DivSysDef(
"Dummy System", NULL, 0xfd, 0, 8, false, true, 0, false, 0,
"this is a system designed for testing purposes.",

View File

@ -583,6 +583,19 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write
w->writeC(0);
}
break;
case DIV_SYSTEM_C140:
for (int i=0; i<24; i++) {
w->writeC(0xd4); // mute
w->writeS(baseAddr2S|(i<<4)|0);
w->writeC(0);
w->writeC(0xd4);
w->writeS(baseAddr2S|(i<<4)|1);
w->writeC(0);
w->writeC(0xd4); // keyoff
w->writeS(baseAddr2S|(i<<4)|5);
w->writeC(0);
}
break;
default:
break;
}
@ -1044,6 +1057,11 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write
w->writeC(baseAddr2|(write.addr&0x3f));
w->writeC(write.val&0xff);
break;
case DIV_SYSTEM_C140:
w->writeC(0xd4);
w->writeS_BE(baseAddr2S|(write.addr&0x1ff));
w->writeC(write.val&0xff);
break;
default:
logW("write not handled!");
break;
@ -1217,6 +1235,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
DivDispatch* writeMSM6295[2]={NULL,NULL};
DivDispatch* writeGA20[2]={NULL,NULL};
DivDispatch* writeK053260[2]={NULL,NULL};
DivDispatch* writeC140[2]={NULL,NULL};
DivDispatch* writeNES[2]={NULL,NULL};
int writeNESIndex[2]={0,0};
@ -1765,6 +1784,22 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
willExport[i]=true;
}
break;
case DIV_SYSTEM_C140:
if (!hasNamco) {
// ?!?!?!
hasNamco=disCont[i].dispatch->rate/2;
CHIP_VOL(40,0.4);
willExport[i]=true;
writeC140[0]=disCont[i].dispatch;
} else if (!(hasNamco&0x40000000)) {
isSecond[i]=true;
CHIP_VOL_SECOND(40,0.4);
willExport[i]=true;
writeC140[1]=disCont[i].dispatch;
hasNamco|=0x40000000;
howManyChips++;
}
break;
default:
break;
}
@ -2163,6 +2198,15 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
w->writeI(0);
w->write(writeES5506[i]->getSampleMem(),writeES5506[i]->getSampleMemUsage());
}
if (writeC140[i]!=NULL && writeC140[i]->getSampleMemUsage()>0) {
w->writeC(0x67);
w->writeC(0x66);
w->writeC(0x8d);
w->writeI((writeC140[i]->getSampleMemUsage()+8)|(i*0x80000000));
w->writeI(writeC140[i]->getSampleMemCapacity());
w->writeI(0);
w->write(writeC140[i]->getSampleMem(),writeC140[i]->getSampleMemUsage());
}
}
// initialize streams

View File

@ -192,12 +192,10 @@ const char* aboutLine[]={
"mzpokeysnd POKEY emulator by Michael Borisov",
"ASAP POKEY emulator by Piotr Fusik",
"ported by laoo to C++",
"K005289 emulator by cam900",
"Namco 163 emulator by cam900",
"Seta X1-010 emulator by cam900",
"Konami VRC6 emulator by cam900",
"Konami SCC emulator by cam900",
"MSM6295 emulator by cam900",
"vgsound_emu (second version, modified version) by cam900",
"SM8521 emulator (modified version) by cam900",
"D65010G031 emulator (modified version) by cam900",
"Namco C140 (modified version) emulator by cam900",
"",
"greetings to:",
"NEOART Costa Rica",

View File

@ -286,6 +286,10 @@ void FurnaceGUI::insListItem(int i, int dir, int asset) {
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_TED]);
name=fmt::sprintf(ICON_FA_BAR_CHART "##_INS%d",i);
break;
case DIV_INS_C140:
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_C140]);
name=fmt::sprintf(ICON_FA_VOLUME_UP "##_INS%d",i);
break;
default:
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_UNKNOWN]);
name=fmt::sprintf(ICON_FA_QUESTION "##_INS%d",i);

View File

@ -54,6 +54,7 @@
#include "../engine/platform/sm8521.h"
#include "../engine/platform/pv1000.h"
#include "../engine/platform/k053260.h"
#include "../engine/platform/c140.h"
#include "../engine/platform/dummy.h"
#define COMMON_CHIP_DEBUG \
@ -546,6 +547,13 @@ void putDispatchChip(void* data, int type) {
COMMON_CHIP_DEBUG_BOOL;
break;
}
case DIV_SYSTEM_C140: {
DivPlatformC140* ch=(DivPlatformC140*)data;
ImGui::Text("> C140");
COMMON_CHIP_DEBUG;
COMMON_CHIP_DEBUG_BOOL;
break;
}
default:
ImGui::Text("Unimplemented chip! Help!");
break;
@ -1066,6 +1074,24 @@ void putDispatchChan(void* data, int chanNum, int type) {
ImGui::TextColored(ch->reverse?colorOn:colorOff,">> Reverse");
break;
}
case DIV_SYSTEM_C140: {
DivPlatformC140::Channel* ch=(DivPlatformC140::Channel*)data;
ImGui::Text("> C140");
COMMON_CHAN_DEBUG;
ImGui::Text("* Sample: %d",ch->sample);
ImGui::Text(" - pos: %d",ch->audPos);
ImGui::Text("- chPanL: %.2x",ch->chPanL);
ImGui::Text("- chPanR: %.2x",ch->chPanR);
ImGui::Text("- chVolL: %.2x",ch->chVolL);
ImGui::Text("- chVolR: %.2x",ch->chVolR);
ImGui::Text("- macroVolMul: %.2x",ch->macroVolMul);
ImGui::Text("- macroPanMul: %.2x",ch->macroPanMul);
COMMON_CHAN_DEBUG_BOOL;
ImGui::TextColored(ch->volChangedL?colorOn:colorOff,">> VolChangedL");
ImGui::TextColored(ch->volChangedR?colorOn:colorOff,">> VolChangedR");
ImGui::TextColored(ch->setPos?colorOn:colorOff,">> SetPos");
break;
}
default:
ImGui::Text("Unimplemented chip! Help!");
break;

View File

@ -1396,7 +1396,8 @@ void FurnaceGUI::doAction(int what) {
i==DIV_INS_ES5506 ||
i==DIV_INS_K007232 ||
i==DIV_INS_GA20 ||
i==DIV_INS_K053260) {
i==DIV_INS_K053260 ||
i==DIV_INS_C140) {
makeInsTypeList.push_back(i);
}
}

View File

@ -258,6 +258,7 @@ enum FurnaceGUIColors {
GUI_COLOR_INSTR_K053260,
GUI_COLOR_INSTR_SCSP,
GUI_COLOR_INSTR_TED,
GUI_COLOR_INSTR_C140,
GUI_COLOR_INSTR_UNKNOWN,
GUI_COLOR_CHANNEL_BG,

View File

@ -170,6 +170,7 @@ const char* insTypes[DIV_INS_MAX+1]={
"K053260",
"SCSP",
"TED",
"C140",
NULL
};
@ -191,7 +192,7 @@ const char* sampleDepths[DIV_SAMPLE_DEPTH_MAX]={
"8-bit PCM",
"BRR",
"VOX",
NULL,
"8-bit µ-law PCM",
NULL,
NULL,
NULL,
@ -934,6 +935,7 @@ const FurnaceGUIColorDef guiColors[GUI_COLOR_MAX]={
D(GUI_COLOR_INSTR_K053260,"",ImVec4(1.0f,0.8f,0.1f,1.0f)),
D(GUI_COLOR_INSTR_SCSP,"",ImVec4(0.5f,0.5f,0.5f,1.0f)),
D(GUI_COLOR_INSTR_TED,"",ImVec4(0.7f,0.6f,1.0f,1.0f)),
D(GUI_COLOR_INSTR_C140,"",ImVec4(1.0f,1.0f,0.0f,1.0f)),
D(GUI_COLOR_INSTR_UNKNOWN,"",ImVec4(0.3f,0.3f,0.3f,1.0f)),
D(GUI_COLOR_CHANNEL_BG,"",ImVec4(0.4f,0.6f,0.8f,1.0f)),
@ -1119,6 +1121,7 @@ const int availableSystems[]={
DIV_SYSTEM_PV1000,
DIV_SYSTEM_K053260,
DIV_SYSTEM_TED,
DIV_SYSTEM_C140,
DIV_SYSTEM_PCM_DAC,
DIV_SYSTEM_PONG,
0 // don't remove this last one!
@ -1229,6 +1232,7 @@ const int chipsSample[]={
DIV_SYSTEM_PCM_DAC,
DIV_SYSTEM_ES5506,
DIV_SYSTEM_K053260,
DIV_SYSTEM_C140,
0 // don't remove this last one!
};

View File

@ -4413,7 +4413,8 @@ void FurnaceGUI::drawInsEdit() {
ins->type==DIV_INS_ES5506 ||
ins->type==DIV_INS_K007232 ||
ins->type==DIV_INS_GA20 ||
ins->type==DIV_INS_K053260) {
ins->type==DIV_INS_K053260 ||
ins->type==DIV_INS_C140) {
if (ImGui::BeginTabItem((ins->type==DIV_INS_SU)?"Sound Unit":"Sample")) {
String sName;
bool wannaOpenSMPopup=false;
@ -5420,7 +5421,7 @@ void FurnaceGUI::drawInsEdit() {
volMax=31;
}
if (ins->type==DIV_INS_ADPCMB || ins->type==DIV_INS_YMZ280B || ins->type==DIV_INS_RF5C68 ||
ins->type==DIV_INS_GA20) {
ins->type==DIV_INS_GA20 || ins->type==DIV_INS_C140) {
volMax=255;
}
if (ins->type==DIV_INS_QSOUND) {
@ -5480,7 +5481,8 @@ void FurnaceGUI::drawInsEdit() {
if (ins->type==DIV_INS_TIA || ins->type==DIV_INS_AMIGA || ins->type==DIV_INS_SCC ||
ins->type==DIV_INS_PET || ins->type==DIV_INS_SEGAPCM ||
ins->type==DIV_INS_FM || ins->type==DIV_INS_K007232 || ins->type==DIV_INS_GA20 ||
ins->type==DIV_INS_SM8521 || ins->type==DIV_INS_PV1000 || ins->type==DIV_INS_K053260) {
ins->type==DIV_INS_SM8521 || ins->type==DIV_INS_PV1000 || ins->type==DIV_INS_K053260 ||
ins->type==DIV_INS_C140) {
dutyMax=0;
}
if (ins->type==DIV_INS_VBOY) {
@ -5588,6 +5590,7 @@ void FurnaceGUI::drawInsEdit() {
if (ins->type==DIV_INS_K053260) waveMax=0;
if (ins->type==DIV_INS_POKEMINI) waveMax=0;
if (ins->type==DIV_INS_TED) waveMax=0;
if (ins->type==DIV_INS_C140) waveMax=0;
if (ins->type==DIV_INS_SU || ins->type==DIV_INS_POKEY) waveMax=7;
if (ins->type==DIV_INS_PET) {
waveMax=8;
@ -5718,6 +5721,10 @@ void FurnaceGUI::drawInsEdit() {
panMin=0;
panMax=127;
}
if (ins->type==DIV_INS_C140) {
panMin=0;
panMax=255;
}
if (ins->type==DIV_INS_ES5506) {
panMax=4095;
}
@ -5803,6 +5810,7 @@ void FurnaceGUI::drawInsEdit() {
ins->type==DIV_INS_K007232 ||
ins->type==DIV_INS_GA20 ||
ins->type==DIV_INS_K053260 ||
ins->type==DIV_INS_C140 ||
ins->type==DIV_INS_TED) {
macroList.push_back(FurnaceGUIMacroDesc("Phase Reset",&ins->std.phaseResetMacro,0,1,32,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true));
}

View File

@ -2024,6 +2024,12 @@ void FurnaceGUI::initSystemPresets() {
) // ""
}
);
ENTRY(
"Namco System 2", {
CH(DIV_SYSTEM_YM2151, 1.0f, 0, ""),
CH(DIV_SYSTEM_C140, 1.0f, 0, "")
}
);
ENTRY(
"Taito Arcade", {
CH(DIV_SYSTEM_YM2610B, 1.0f, 0, "")
@ -2546,6 +2552,11 @@ void FurnaceGUI::initSystemPresets() {
CH(DIV_SYSTEM_K053260, 1.0f, 0, "")
}
);
ENTRY(
"Namco C140", {
CH(DIV_SYSTEM_C140, 1.0f, 0, "")
}
);
CATEGORY_END;
CATEGORY_BEGIN("Wavetable","chips which use user-specified waveforms to generate sound.");

View File

@ -277,6 +277,11 @@ void FurnaceGUI::drawSampleEdit() {
SAMPLE_WARN(warnLength,"K053260: maximum sample length is 65535");
}
break;
case DIV_SYSTEM_C140:
if (sample->samples>65535) {
SAMPLE_WARN(warnLength,"C140: maximum sample length is 65535");
}
break;
default:
break;
}

View File

@ -2711,6 +2711,7 @@ void FurnaceGUI::drawSettings() {
UI_COLOR_CONFIG(GUI_COLOR_INSTR_SM8521,"SM8521");
UI_COLOR_CONFIG(GUI_COLOR_INSTR_PV1000,"PV-1000");
UI_COLOR_CONFIG(GUI_COLOR_INSTR_K053260,"K053260");
UI_COLOR_CONFIG(GUI_COLOR_INSTR_C140,"C140");
UI_COLOR_CONFIG(GUI_COLOR_INSTR_UNKNOWN,"Other/Unknown");
ImGui::TreePop();
}

View File

@ -2072,6 +2072,7 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo
case DIV_SYSTEM_GA20:
case DIV_SYSTEM_PV1000:
case DIV_SYSTEM_VERA:
case DIV_SYSTEM_C140:
break;
case DIV_SYSTEM_YMU759:
supportsCustomRate=false;

View File

@ -271,6 +271,9 @@ const char* FurnaceGUI::getSystemPartNumber(DivSystem sys, DivConfig& flags) {
case DIV_SYSTEM_TED:
return "TED";
break;
case DIV_SYSTEM_C140:
return "C140";
break;
default:
return FurnaceGUI::getSystemName(sys);
break;

View File

@ -208,6 +208,9 @@ TAParamResult pVersion(String) {
printf("- MAME GA20 core by Acho A. Tang, R. Belmont, Valley Bell (BSD 3-clause)\n");
printf("- Atari800 mzpokeysnd POKEY emulator by Michael Borisov (GPLv2)\n");
printf("- ASAP POKEY emulator by Piotr Fusik ported to C++ by laoo (GPLv2)\n");
printf("- SM8521 emulator (modified version) by cam900 (zlib license)\n");
printf("- D65010G031 emulator (modified version) by cam900 (zlib license)\n");
printf("- C140 emulator (modified version) by cam900 (zlib license)\n");
return TA_PARAM_QUIT;
}