Virtual Boy: acquireDirect()
This commit is contained in:
parent
229003c597
commit
6050b2c31b
|
@ -631,11 +631,6 @@ void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, do
|
|||
break;
|
||||
case DIV_SYSTEM_VBOY:
|
||||
dispatch=new DivPlatformVB;
|
||||
if (isRender) {
|
||||
((DivPlatformVB*)dispatch)->setCoreQuality(eng->getConfInt("vbQualityRender",3));
|
||||
} else {
|
||||
((DivPlatformVB*)dispatch)->setCoreQuality(eng->getConfInt("vbQuality",3));
|
||||
}
|
||||
break;
|
||||
case DIV_SYSTEM_VERA:
|
||||
dispatch=new DivPlatformVERA;
|
||||
|
|
|
@ -44,14 +44,6 @@ VSU::~VSU()
|
|||
|
||||
void VSU::SetSoundRate(double rate)
|
||||
{
|
||||
/*
|
||||
for(int y = 0; y < 2; y++)
|
||||
{
|
||||
sbuf[y].set_sample_rate(rate ? rate : 44100, 50);
|
||||
sbuf[y].clock_rate((long)(VB_MASTER_CLOCK / 4));
|
||||
sbuf[y].bass_freq(20);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void VSU::Power(void)
|
||||
|
@ -106,7 +98,7 @@ void VSU::Write(int timestamp, unsigned int A, unsigned char V)
|
|||
//
|
||||
A &= 0x7FF;
|
||||
|
||||
//Update(timestamp);
|
||||
Update(timestamp);
|
||||
|
||||
//printf("VSU Write: %d, %08x %02x\n", timestamp, A, V);
|
||||
|
||||
|
@ -262,14 +254,19 @@ void VSU::Update(int timestamp)
|
|||
for(int ch = 0; ch < 6; ch++)
|
||||
{
|
||||
int clocks = timestamp - last_ts;
|
||||
//int running_timestamp = last_ts;
|
||||
int running_timestamp = last_ts;
|
||||
|
||||
// Output sound here
|
||||
CalcCurrentOutput(ch, left, right);
|
||||
/*Synth.offset_inline(running_timestamp, left - last_output[ch][0], &sbuf[0]);
|
||||
Synth.offset_inline(running_timestamp, right - last_output[ch][1], &sbuf[1]);*/
|
||||
if (left!=last_output[ch][0]) {
|
||||
blip_add_delta(bb[0],running_timestamp,left - last_output[ch][0]);
|
||||
last_output[ch][0] = left;
|
||||
}
|
||||
if (right!=last_output[ch][1]) {
|
||||
blip_add_delta(bb[1],running_timestamp,right - last_output[ch][1]);
|
||||
last_output[ch][1] = right;
|
||||
}
|
||||
oscBuf[ch]->putSample(running_timestamp,(left+right)*8);
|
||||
|
||||
if(!(IntlControl[ch] & 0x80))
|
||||
continue;
|
||||
|
@ -430,17 +427,20 @@ void VSU::Update(int timestamp)
|
|||
} // end if(ch == 4)
|
||||
} // end while(EffectsClockDivider[ch] <= 0)
|
||||
clocks -= chunk_clocks;
|
||||
//running_timestamp += chunk_clocks;
|
||||
running_timestamp += chunk_clocks;
|
||||
|
||||
// Output sound here too.
|
||||
CalcCurrentOutput(ch, left, right);
|
||||
/*
|
||||
Synth.offset_inline(running_timestamp, left - last_output[ch][0], &sbuf[0]);
|
||||
Synth.offset_inline(running_timestamp, right - last_output[ch][1], &sbuf[1]);
|
||||
*/
|
||||
if (left!=last_output[ch][0]) {
|
||||
blip_add_delta(bb[0],running_timestamp,left - last_output[ch][0]);
|
||||
last_output[ch][0] = left;
|
||||
}
|
||||
if (right!=last_output[ch][1]) {
|
||||
blip_add_delta(bb[1],running_timestamp,right - last_output[ch][1]);
|
||||
last_output[ch][1] = right;
|
||||
}
|
||||
oscBuf[ch]->putSample(running_timestamp,(left+right)*8);
|
||||
}
|
||||
}
|
||||
last_ts = timestamp;
|
||||
//puts("VSU End");
|
||||
|
@ -453,17 +453,6 @@ int VSU::EndFrame(int timestamp)
|
|||
Update(timestamp);
|
||||
last_ts = 0;
|
||||
|
||||
/*
|
||||
if(SoundBuf)
|
||||
{
|
||||
for(int y = 0; y < 2; y++)
|
||||
{
|
||||
sbuf[y].end_frame(timestamp);
|
||||
ret = sbuf[y].read_samples(SoundBuf + y, SoundBufMaxSize, 1);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,11 +22,16 @@
|
|||
#ifndef __VB_VSU_H
|
||||
#define __VB_VSU_H
|
||||
|
||||
#include "blip_buf.h"
|
||||
#include "../../dispatch.h"
|
||||
|
||||
class VSU
|
||||
{
|
||||
public:
|
||||
|
||||
int last_output[6][2];
|
||||
blip_buffer_t* bb[2];
|
||||
DivDispatchOscBuffer* oscBuf[6];
|
||||
|
||||
VSU();
|
||||
~VSU();
|
||||
|
|
|
@ -93,37 +93,26 @@ const char** DivPlatformVB::getRegisterSheet() {
|
|||
return regCheatSheetVB;
|
||||
}
|
||||
|
||||
void DivPlatformVB::acquire(short** buf, size_t len) {
|
||||
void DivPlatformVB::acquireDirect(blip_buffer_t** bb, size_t len) {
|
||||
for (int i=0; i<6; i++) {
|
||||
oscBuf[i]->begin(len);
|
||||
vb->oscBuf[i]=oscBuf[i];
|
||||
}
|
||||
|
||||
vb->bb[0]=bb[0];
|
||||
vb->bb[1]=bb[1];
|
||||
|
||||
for (size_t h=0; h<len; h++) {
|
||||
cycles=0;
|
||||
if (!writes.empty()) {
|
||||
QueuedWrite w=writes.front();
|
||||
vb->Write(cycles,w.addr,w.val);
|
||||
vb->Write(h,w.addr,w.val);
|
||||
regPool[w.addr>>2]=w.val;
|
||||
writes.pop();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
vb->EndFrame(coreQuality);
|
||||
|
||||
tempL=0;
|
||||
tempR=0;
|
||||
for (int i=0; i<6; i++) {
|
||||
oscBuf[i]->putSample(h,(vb->last_output[i][0]+vb->last_output[i][1])*8);
|
||||
tempL+=vb->last_output[i][0];
|
||||
tempR+=vb->last_output[i][1];
|
||||
}
|
||||
|
||||
if (tempL<-32768) tempL=-32768;
|
||||
if (tempL>32767) tempL=32767;
|
||||
if (tempR<-32768) tempR=-32768;
|
||||
if (tempR>32767) tempR=32767;
|
||||
|
||||
buf[0][h]=tempL;
|
||||
buf[1][h]=tempR;
|
||||
}
|
||||
vb->EndFrame(len);
|
||||
|
||||
for (int i=0; i<6; i++) {
|
||||
oscBuf[i]->end(len);
|
||||
|
@ -519,7 +508,6 @@ void DivPlatformVB::reset() {
|
|||
vb->Power();
|
||||
tempL=0;
|
||||
tempR=0;
|
||||
cycles=0;
|
||||
curChan=-1;
|
||||
modulation=0;
|
||||
modType=false;
|
||||
|
@ -548,6 +536,10 @@ bool DivPlatformVB::keyOffAffectsArp(int ch) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool DivPlatformVB::hasAcquireDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
float DivPlatformVB::getPostAmp() {
|
||||
return 6.0f;
|
||||
}
|
||||
|
@ -592,7 +584,7 @@ void DivPlatformVB::notifyInsDeletion(void* ins) {
|
|||
void DivPlatformVB::setFlags(const DivConfig& flags) {
|
||||
chipClock=5000000.0;
|
||||
CHECK_CUSTOM_CLOCK;
|
||||
rate=chipClock/coreQuality;
|
||||
rate=chipClock;
|
||||
for (int i=0; i<6; i++) {
|
||||
oscBuf[i]->setRate(rate);
|
||||
}
|
||||
|
@ -616,32 +608,6 @@ void DivPlatformVB::poke(std::vector<DivRegWrite>& wlist) {
|
|||
for (DivRegWrite& i: wlist) rWrite(i.addr,i.val);
|
||||
}
|
||||
|
||||
void DivPlatformVB::setCoreQuality(unsigned char q) {
|
||||
switch (q) {
|
||||
case 0:
|
||||
coreQuality=128;
|
||||
break;
|
||||
case 1:
|
||||
coreQuality=64;
|
||||
break;
|
||||
case 2:
|
||||
coreQuality=32;
|
||||
break;
|
||||
case 3:
|
||||
coreQuality=16;
|
||||
break;
|
||||
case 4:
|
||||
coreQuality=4;
|
||||
break;
|
||||
case 5:
|
||||
coreQuality=1;
|
||||
break;
|
||||
default:
|
||||
coreQuality=16;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int DivPlatformVB::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) {
|
||||
parent=p;
|
||||
dumpWrites=false;
|
||||
|
|
|
@ -73,7 +73,7 @@ class DivPlatformVB: public DivDispatch {
|
|||
friend void putDispatchChip(void*,int);
|
||||
friend void putDispatchChan(void*,int,int);
|
||||
public:
|
||||
void acquire(short** buf, size_t len);
|
||||
void acquireDirect(blip_buffer_t** bb, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
void* getChanState(int chan);
|
||||
DivMacroInt* getChanMacroInt(int ch);
|
||||
|
@ -88,6 +88,7 @@ class DivPlatformVB: public DivDispatch {
|
|||
void muteChannel(int ch, bool mute);
|
||||
int getOutputCount();
|
||||
bool keyOffAffectsArp(int ch);
|
||||
bool hasAcquireDirect();
|
||||
float getPostAmp();
|
||||
void setFlags(const DivConfig& flags);
|
||||
void notifyWaveChange(int wave);
|
||||
|
@ -95,7 +96,6 @@ class DivPlatformVB: public DivDispatch {
|
|||
void poke(unsigned int addr, unsigned short val);
|
||||
void poke(std::vector<DivRegWrite>& wlist);
|
||||
const char** getRegisterSheet();
|
||||
void setCoreQuality(unsigned char q);
|
||||
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
|
||||
void quit();
|
||||
~DivPlatformVB();
|
||||
|
|
Loading…
Reference in a new issue