Skip to content

Commit

Permalink
replace AArt µPD1771C core with MAME
Browse files Browse the repository at this point in the history
  • Loading branch information
tildearrow committed Jan 29, 2025
1 parent 00ad4e4 commit 97402e6
Show file tree
Hide file tree
Showing 20 changed files with 1,126 additions and 380 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ src/engine/platform/sound/sm8521.c

src/engine/platform/sound/supervision.c

src/engine/platform/sound/upd1771.cpp
src/engine/platform/sound/upd1771c.c

src/engine/platform/sound/d65modified.c
Expand Down Expand Up @@ -790,7 +791,8 @@ src/engine/platform/k007232.cpp
src/engine/platform/ga20.cpp
src/engine/platform/sm8521.cpp
src/engine/platform/supervision.cpp
src/engine/platform/upd1771c.cpp
src/engine/platform/scvwave.cpp
src/engine/platform/scvtone.cpp
src/engine/platform/pv1000.cpp
src/engine/platform/k053260.cpp
src/engine/platform/ted.cpp
Expand Down
5 changes: 3 additions & 2 deletions papers/format.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,10 @@ size | description
| - 0xdf: YM2612 XGM extended - 13 channels (UNAVAILABLE)
| - 0xe0: QSound - 19 channels
| - 0xe1: PS1 - 24 channels (UNAVAILABLE)
| - 0xe2: C64 (6581) with PCM - 4 channels (UNAVAILABLE)
| - 0xe2: C64 (6581) with PCM - 4 channels
| - 0xe3: Watara Supervision - 4 channels
| - 0xe4: µPD1771C - 1 channel
| - 0xe4: µPD1771C-017 (wave mode) - 1 channel
| - 0xe5: µPD1771C-017 (tone mode) - 4 channels
| - 0xf0: SID2 - 3 channels
| - 0xf1: 5E01 - 5 channels
| - 0xf5: SID3 - 7 channels
Expand Down
8 changes: 6 additions & 2 deletions src/engine/dispatchContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
#include "platform/k007232.h"
#include "platform/ga20.h"
#include "platform/supervision.h"
#include "platform/upd1771c.h"
#include "platform/scvwave.h"
#include "platform/scvtone.h"
#include "platform/sm8521.h"
#include "platform/pv1000.h"
#include "platform/k053260.h"
Expand Down Expand Up @@ -732,7 +733,10 @@ void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, do
dispatch=new DivPlatformSupervision;
break;
case DIV_SYSTEM_UPD1771C:
dispatch=new DivPlatformUPD1771c;
dispatch=new DivPlatformSCVWave;
break;
case DIV_SYSTEM_UPD1771C_TONE:
dispatch=new DivPlatformSCVTone;
break;
case DIV_SYSTEM_SM8521:
dispatch=new DivPlatformSM8521;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include "upd1771c.h"
#include "scvtone.h"
#include "../engine.h"
#include "../../ta-log.h"
#include "furIcons.h"
Expand All @@ -28,15 +28,15 @@

#define CHIP_DIVIDER 64

const char* regCheatSheetUPD1771c[]={
const char* regCheatSheetUPD1771cTone[]={
NULL
};

const char** DivPlatformUPD1771c::getRegisterSheet() {
return regCheatSheetUPD1771c;
const char** DivPlatformSCVTone::getRegisterSheet() {
return regCheatSheetUPD1771cTone;
}

void DivPlatformUPD1771c::acquire(short** buf, size_t len) {
void DivPlatformSCVTone::acquire(short** buf, size_t len) {
for (size_t h=0; h<len; h++) {
while (!writes.empty()) {
QueuedWrite w=writes.front();
Expand All @@ -53,7 +53,7 @@ void DivPlatformUPD1771c::acquire(short** buf, size_t len) {
}
}

void DivPlatformUPD1771c::tick(bool sysTick) {
void DivPlatformSCVTone::tick(bool sysTick) {
for (int i=0; i<1; i++) {

chan[i].std.next();
Expand Down Expand Up @@ -146,7 +146,7 @@ void DivPlatformUPD1771c::tick(bool sysTick) {
}
}

int DivPlatformUPD1771c::dispatch(DivCommand c) {
int DivPlatformSCVTone::dispatch(DivCommand c) {
switch (c.cmd) {
case DIV_CMD_NOTE_ON: {
DivInstrument* ins=parent->getIns(chan[c.chan].ins,DIV_INS_UPD1771C);
Expand Down Expand Up @@ -262,43 +262,43 @@ int DivPlatformUPD1771c::dispatch(DivCommand c) {
return 1;
}

void DivPlatformUPD1771c::muteChannel(int ch, bool mute) {
void DivPlatformSCVTone::muteChannel(int ch, bool mute) {
isMuted[ch]=mute;
}

void DivPlatformUPD1771c::forceIns() {
void DivPlatformSCVTone::forceIns() {
for (int i=0; i<1; i++) {
chan[i].insChanged=true;
chan[i].freqChanged=true;
//chwrite(i,0x05,isMuted[i]?0:chan[i].pan);
}
}

void* DivPlatformUPD1771c::getChanState(int ch) {
void* DivPlatformSCVTone::getChanState(int ch) {
return &chan[ch];
}

DivMacroInt* DivPlatformUPD1771c::getChanMacroInt(int ch) {
DivMacroInt* DivPlatformSCVTone::getChanMacroInt(int ch) {
return &chan[ch].std;
}

DivDispatchOscBuffer* DivPlatformUPD1771c::getOscBuffer(int ch) {
DivDispatchOscBuffer* DivPlatformSCVTone::getOscBuffer(int ch) {
return oscBuf[ch];
}

unsigned char* DivPlatformUPD1771c::getRegisterPool() {
unsigned char* DivPlatformSCVTone::getRegisterPool() {
return regPool;
}

int DivPlatformUPD1771c::getRegisterPoolSize() {
int DivPlatformSCVTone::getRegisterPoolSize() {
return 16;
}

void DivPlatformUPD1771c::reset() {
void DivPlatformSCVTone::reset() {
writes.clear();
memset(regPool,0,16);
for (int i=0; i<1; i++) {
chan[i]=DivPlatformUPD1771c::Channel();
chan[i]=DivPlatformSCVTone::Channel();
chan[i].std.setEngine(parent);
}
if (dumpWrites) {
Expand All @@ -311,21 +311,21 @@ void DivPlatformUPD1771c::reset() {
memset(initWrite,1,1*sizeof(unsigned char));
}

int DivPlatformUPD1771c::getOutputCount() {
int DivPlatformSCVTone::getOutputCount() {
return 2;
}

bool DivPlatformUPD1771c::keyOffAffectsArp(int ch) {
bool DivPlatformSCVTone::keyOffAffectsArp(int ch) {
return true;
}

void DivPlatformUPD1771c::notifyInsDeletion(void* ins) {
void DivPlatformSCVTone::notifyInsDeletion(void* ins) {
for (int i=0; i<1; i++) {
chan[i].std.notifyInsDeletion((DivInstrument*)ins);
}
}

void DivPlatformUPD1771c::setFlags(const DivConfig& flags) {
void DivPlatformSCVTone::setFlags(const DivConfig& flags) {
chipClock=6000000;
CHECK_CUSTOM_CLOCK;
rate=chipClock/32;
Expand All @@ -335,15 +335,15 @@ void DivPlatformUPD1771c::setFlags(const DivConfig& flags) {
upd1771c_sound_set_clock(&scv,(unsigned int)chipClock,8);
}

void DivPlatformUPD1771c::poke(unsigned int addr, unsigned short val) {
void DivPlatformSCVTone::poke(unsigned int addr, unsigned short val) {
rWrite(addr,val);
}

void DivPlatformUPD1771c::poke(std::vector<DivRegWrite>& wlist) {
void DivPlatformSCVTone::poke(std::vector<DivRegWrite>& wlist) {
for (DivRegWrite& i: wlist) rWrite(i.addr,i.val);
}

int DivPlatformUPD1771c::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) {
int DivPlatformSCVTone::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) {
parent=p;
dumpWrites=false;
skipRegisterWrites=false;
Expand All @@ -356,11 +356,11 @@ int DivPlatformUPD1771c::init(DivEngine* p, int channels, int sugRate, const Div
return 1;
}

void DivPlatformUPD1771c::quit() {
void DivPlatformSCVTone::quit() {
for (int i=0; i<1; i++) {
delete oscBuf[i];
}
}

DivPlatformUPD1771c::~DivPlatformUPD1771c() {
DivPlatformSCVTone::~DivPlatformSCVTone() {
}
84 changes: 84 additions & 0 deletions src/engine/platform/scvtone.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/**
* Furnace Tracker - multi-system chiptune tracker
* Copyright (C) 2021-2025 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 _SCV_TONE_H
#define _SCV_TONE_H

#include "../dispatch.h"
#include "../../fixedQueue.h"
#include "sound/upd1771c.h"

class DivPlatformSCVTone: public DivDispatch {
struct Channel: public SharedChannel<signed char> {
unsigned int wave;
int pos, duty;
Channel():
SharedChannel<signed char>(15),
wave(0),
pos(0),
duty(0) {}
};
Channel chan[4];
DivDispatchOscBuffer* oscBuf[4];
bool isMuted[4];
struct QueuedWrite {
unsigned char addr;
unsigned char val;
QueuedWrite(): addr(0), val(9) {}
QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {}
};
FixedQueue<QueuedWrite,512> writes;

int curChan;
int tempL[32];
int tempR[32];
int coreQuality;
unsigned char regPool[16];
unsigned char kon[4];
unsigned char initWrite[4];
struct upd1771c_t scv;


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();
bool keyOffAffectsArp(int ch);
void setFlags(const DivConfig& flags);
void notifyInsDeletion(void* ins);
void poke(unsigned int addr, unsigned short val);
void poke(std::vector<DivRegWrite>& wlist);
const char** getRegisterSheet();
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit();
~DivPlatformSCVTone();
};

#endif
Loading

0 comments on commit 97402e6

Please sign in to comment.