C140: add bank types
This commit is contained in:
parent
b08f1e656f
commit
8235f6ee66
10 changed files with 107 additions and 9 deletions
|
|
@ -271,6 +271,14 @@ void DivPlatformC140::tick(bool sysTick) {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
switch (bankType) {
|
||||
case 0:
|
||||
bank=((bank&8)<<2)|(bank&7);
|
||||
break;
|
||||
case 1:
|
||||
bank=((bank&0x18)<<1)|(bank&7);
|
||||
break;
|
||||
}
|
||||
rWrite(0x04+(i<<4),bank);
|
||||
}
|
||||
rWrite(0x06+(i<<4),(start>>8)&0xff);
|
||||
|
|
@ -548,7 +556,15 @@ const void* DivPlatformC140::getSampleMem(int index) {
|
|||
}
|
||||
|
||||
size_t DivPlatformC140::getSampleMemCapacity(int index) {
|
||||
return index == 0 ? (is219?524288:16777216) : 0;
|
||||
if (index!=0) return 0;
|
||||
if (is219) return 524288;
|
||||
switch (bankType) {
|
||||
case 0:
|
||||
return 2097152;
|
||||
case 1:
|
||||
return 4194304;
|
||||
}
|
||||
return 16777216;
|
||||
}
|
||||
|
||||
size_t DivPlatformC140::getSampleMemUsage(int index) {
|
||||
|
|
@ -562,7 +578,7 @@ bool DivPlatformC140::isSampleLoaded(int index, int sample) {
|
|||
}
|
||||
|
||||
void DivPlatformC140::renderSamples(int sysID) {
|
||||
memset(sampleMem,0,getSampleMemCapacity());
|
||||
memset(sampleMem,0,is219?524288:16777216);
|
||||
memset(sampleOff,0,256*sizeof(unsigned int));
|
||||
memset(sampleLoaded,0,256*sizeof(bool));
|
||||
|
||||
|
|
@ -701,6 +717,10 @@ void DivPlatformC140::setFlags(const DivConfig& flags) {
|
|||
CHECK_CUSTOM_CLOCK;
|
||||
rate=chipClock/192;
|
||||
}
|
||||
bankType=flags.getInt("bankType",0);
|
||||
if (!is219) {
|
||||
c140_bank_type(&c140,bankType);
|
||||
}
|
||||
for (int i=0; i<totalChans; i++) {
|
||||
oscBuf[i]->rate=rate;
|
||||
}
|
||||
|
|
@ -710,12 +730,13 @@ int DivPlatformC140::init(DivEngine* p, int channels, int sugRate, const DivConf
|
|||
parent=p;
|
||||
dumpWrites=false;
|
||||
skipRegisterWrites=false;
|
||||
bankType=2;
|
||||
|
||||
for (int i=0; i<totalChans; i++) {
|
||||
isMuted[i]=false;
|
||||
oscBuf[i]=new DivDispatchOscBuffer;
|
||||
}
|
||||
sampleMem=new unsigned char[getSampleMemCapacity()];
|
||||
sampleMem=new unsigned char[is219?524288:16777216];
|
||||
sampleMemLen=0;
|
||||
if (is219) {
|
||||
c219_init(&c219);
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ class DivPlatformC140: public DivDispatch {
|
|||
bool is219;
|
||||
int totalChans;
|
||||
unsigned char groupBank[4];
|
||||
unsigned char bankType;
|
||||
|
||||
unsigned char* sampleMem;
|
||||
size_t sampleMemLen;
|
||||
|
|
|
|||
|
|
@ -333,6 +333,11 @@ void c219_reset(struct c219_t *c219)
|
|||
}
|
||||
}
|
||||
|
||||
// TILDEARROW
|
||||
void c140_bank_type(struct c140_t *c140, unsigned char type) {
|
||||
c140->bank_type = type;
|
||||
}
|
||||
|
||||
void c140_write(struct c140_t *c140, const unsigned short addr, const unsigned char data)
|
||||
{
|
||||
// voice register
|
||||
|
|
@ -345,7 +350,16 @@ void c140_write(struct c140_t *c140, const unsigned short addr, const unsigned c
|
|||
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 0x4: { // TILDEARROW
|
||||
if (c140->bank_type == 0) {
|
||||
voice->bank = ((data&0x20)>>2)|data&7;
|
||||
} else if (c140->bank_type == 1) {
|
||||
voice->bank = ((data&0x30)>>1)|data&7;
|
||||
} else {
|
||||
voice->bank = data;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x5:
|
||||
voice->compressed = c140_bit(data, 3);
|
||||
voice->loop = c140_bit(data, 4);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
MODIFIED Namco C140/C219 sound emulator - MODIFIED VERSION
|
||||
by cam900
|
||||
|
||||
MODIFICATION by tildearrow - adds muting function
|
||||
MODIFICATION by tildearrow - adds muting function AND VGM banking
|
||||
THIS IS NOT THE ORIGINAL VERSION - you can find the original one in
|
||||
commit 72d04777c013988ed8cf6da27c62a9d784a59dff
|
||||
|
||||
|
|
@ -78,6 +78,7 @@ struct c140_t
|
|||
signed int lout, rout;
|
||||
signed short mulaw[256];
|
||||
signed short *sample_mem;
|
||||
unsigned char bank_type;
|
||||
};
|
||||
|
||||
struct c219_t
|
||||
|
|
@ -106,6 +107,8 @@ void c140_write(struct c140_t *c140, const unsigned short addr, const unsigned c
|
|||
|
||||
void c219_write(struct c219_t *c219, const unsigned short addr, const unsigned char data);
|
||||
|
||||
void c140_bank_type(struct c140_t *c140, unsigned char type);
|
||||
|
||||
void c140_init(struct c140_t *c140);
|
||||
|
||||
void c219_init(struct c219_t *c219);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue