Debian Codegraph @

src/engine/platform/dave.cpp

raw
1 /**
2 * Furnace Tracker - multi-system chiptune tracker
3 * Copyright (C) 2021-2025 tildearrow and contributors
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "dave.h"
21 #include "../engine.h"
22 #include <math.h>
23
24 //#define rWrite(a,v) pendingWrites[a]=v;
25 #define rWrite(a,v) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if (dumpWrites) {addWrite(a,v);} }
26
27 #define CHIP_DIVIDER 8
28
29 const char* regCheatSheetDave[]={
30 "Freq0", "00",
31 "Control0", "01",
32 "Freq1", "02",
33 "Control1", "03",
34 "Freq2", "04",
35 "Control2", "05",
36 "Control3", "06",
37 "SoundCtrl", "07",
38 "Vol0L", "08",
39 "Vol1L", "09",
40 "Vol2L", "0A",
41 "Vol3L", "0B",
42 "Vol0R", "0C",
43 "Vol1R", "0D",
44 "Vol2R", "0E",
45 "Vol3R", "0F",
46 "ClockDiv", "1F",
47 NULL
48 };
49
50 const unsigned char snapPeriodLong[15]={
51 0, 1, 3, 3, 3, 6, 6, 7, 7, 10, 10, 12, 12, 13, 13
52 };
53
54 const unsigned char snapPeriodShort[15]={
55 2, 2, 2, 2, 5, 5, 5, 8, 8, 8, 11, 11, 11, 11, 11
56 };
57
58 const unsigned char waveMap[8]={
59 0, 1, 1, 2, 3, 0, 0, 0
60 };
61
62 const char** DivPlatformDave::getRegisterSheet() {
63 return regCheatSheetDave;
64 }
65
66 void DivPlatformDave::acquire(short** buf, size_t len) {
67 for (int i=0; i<6; i++) {
68 oscBuf[i]->begin(len);
69 }
70
71 for (size_t h=0; h<len; h++) {
72 for (int i=4; i<6; i++) {
73 if (chan[i].dacSample!=-1) {
74 chan[i].dacPeriod+=chan[i].dacRate;
75 while (chan[i].dacPeriod>rate) {
76 DivSample* s=parent->getSample(chan[i].dacSample);
77 if (s->samples<=0 || chan[i].dacPos>=s->samples) {
78 chan[i].dacSample=-1;
79 writeControl=true;
80 chan[0].writeVol=true;
81 chan[i].dacPeriod-=rate;
82 continue;
83 }
84 signed char dacData=(s->data8[chan[i].dacPos]*chan[i].outVol)>>8;
85 chan[i].dacOut=dacData+32;
86 chan[i].dacPos++;
87 if (!isMuted[i]) {
88 rWrite(8+((i-4)<<2),chan[i].dacOut&0x3f);
89 }
90 if (s->isLoopable() && chan[i].dacPos>=(unsigned int)s->loopEnd) {
91 chan[i].dacPos=s->loopStart;
92 } else if (chan[i].dacPos>=s->samples) {
93 chan[i].dacSample=-1;
94 writeControl=true;
95 chan[0].writeVol=true;
96 }
97 chan[i].dacPeriod-=rate;
98 }
99 }
100 }
101
102 if (!writes.empty()) {
103 QueuedWrite w=writes.front();
104 dave->writePort(w.addr,w.val);
105 regPool[w.addr&0x1f]=w.val;
106 writes.pop();
107 }
108
109 unsigned int next=dave->runOneCycle();
110 unsigned short nextL=next&0xffff;
111 unsigned short nextR=next>>16;
112
113 if ((regPool[7]&0x18)==0x18) {
114 oscBuf[0]->putSample(h,0);
115 oscBuf[1]->putSample(h,0);
116 oscBuf[2]->putSample(h,0);
117 oscBuf[3]->putSample(h,0);
118 oscBuf[4]->putSample(h,dave->chn0_left<<9);
119 oscBuf[5]->putSample(h,dave->chn0_right<<9);
120 } else if (regPool[7]&0x08) {
121 oscBuf[0]->putSample(h,dave->chn0_state?(dave->chn0_right<<8):0);
122 oscBuf[1]->putSample(h,dave->chn1_state?(dave->chn1_right<<8):0);
123 oscBuf[2]->putSample(h,dave->chn2_state?(dave->chn2_right<<8):0);
124 oscBuf[3]->putSample(h,dave->chn3_state?(dave->chn3_right<<8):0);
125 oscBuf[4]->putSample(h,dave->chn0_left<<9);
126 oscBuf[5]->putSample(h,0);
127 } else if (regPool[7]&0x10) {
128 oscBuf[0]->putSample(h,dave->chn0_state?(dave->chn0_left<<8):0);
129 oscBuf[1]->putSample(h,dave->chn1_state?(dave->chn1_left<<8):0);
130 oscBuf[2]->putSample(h,dave->chn2_state?(dave->chn2_left<<8):0);
131 oscBuf[3]->putSample(h,dave->chn3_state?(dave->chn3_left<<8):0);
132 oscBuf[4]->putSample(h,0);
133 oscBuf[5]->putSample(h,dave->chn0_right<<9);
134 } else {
135 oscBuf[0]->putSample(h,dave->chn0_state?((dave->chn0_left+dave->chn0_right)<<8):0);
136 oscBuf[1]->putSample(h,dave->chn1_state?((dave->chn1_left+dave->chn1_right)<<8):0);
137 oscBuf[2]->putSample(h,dave->chn2_state?((dave->chn2_left+dave->chn2_right)<<8):0);
138 oscBuf[3]->putSample(h,dave->chn3_state?((dave->chn3_left+dave->chn3_right)<<8):0);
139 oscBuf[4]->putSample(h,0);
140 oscBuf[5]->putSample(h,0);
141 }
142
143 buf[0][h]=(short)nextL;
144 buf[1][h]=(short)nextR;
145 }
146
147 for (int i=0; i<6; i++) {
148 oscBuf[i]->end(len);
149 }
150 }
151
152 void DivPlatformDave::tick(bool sysTick) {
153 for (int i=0; i<6; i++) {
154 chan[i].std.next();
155 if (chan[i].std.vol.had) {
156 chan[i].outVol=VOL_SCALE_LINEAR(chan[i].vol&63,MIN(63,chan[i].std.vol.val),63);
157 chan[i].writeVol=true;
158 }
159 if (chan[i].std.duty.had) {
160 chan[i].noiseFreq=chan[i].std.duty.val&3;
161 chan[i].freqChanged=true;
162 }
163 if (NEW_ARP_STRAT) {
164 chan[i].handleArp();
165 } else if (chan[i].std.arp.had) {
166 if (!chan[i].inPorta) {
167 if (i>=4) {
168 chan[i].baseFreq=parent->calcBaseFreq(1,1,parent->calcArp(chan[i].note,chan[i].std.arp.val),false);
169 } else {
170 chan[i].baseFreq=NOTE_PERIODIC(parent->calcArp(chan[i].note,chan[i].std.arp.val));
171 }
172 }
173 chan[i].freqChanged=true;
174 }
175 if (chan[i].std.wave.had) {
176 chan[i].wave=chan[i].std.wave.val&7;
177 if (i==3 && chan[i].wave>3) chan[i].wave=3;
178 chan[i].freqChanged=true;
179 }
180 if (chan[i].std.panL.had) {
181 chan[i].panL=chan[i].std.panL.val&63;
182 }
183 if (chan[i].std.panR.had) {
184 chan[i].panR=chan[i].std.panR.val&63;
185 }
186 if (chan[i].std.panL.had || chan[i].std.panR.had) {
187 chan[i].writeVol=true;
188 }
189 if (chan[i].std.ex1.had) {
190 chan[i].highPass=chan[i].std.ex1.val&1;
191 chan[i].ringMod=chan[i].std.ex1.val&2;
192 chan[i].swapCounters=chan[i].std.ex1.val&4;
193 chan[i].lowPass=chan[i].std.ex1.val&8;
194 chan[i].freqChanged=true;
195 }
196 if (chan[i].std.pitch.had) {
197 if (chan[i].std.pitch.mode) {
198 chan[i].pitch2+=chan[i].std.pitch.val;
199 CLAMP_VAR(chan[i].pitch2,-32768,32767);
200 } else {
201 chan[i].pitch2=chan[i].std.pitch.val;
202 }
203 chan[i].freqChanged=true;
204 }
205 if (chan[i].std.phaseReset.had && chan[i].std.phaseReset.val==1) {
206 if (i>=4) {
207 if (chan[i].active && chan[i].dacSample>=0 && chan[i].dacSample<parent->song.sampleLen) {
208 if (chan[i].setPos) {
209 chan[i].setPos=false;
210 } else {
211 chan[i].dacPos=0;
212 }
213 chan[i].dacPeriod=0;
214 chan[i].keyOn=true;
215 }
216 } else {
217 chan[i].resetPhase=true;
218 writeControl=true;
219 }
220 }
221
222 if (chan[i].writeVol) {
223 if (i<4) {
224 if (chan[i].active && !isMuted[i]) {
225 if (i!=0 || chan[4].dacSample<0 || isMuted[4]) {
226 rWrite(8+i,(63+chan[i].outVol*chan[i].panL)>>6);
227 }
228 if (i!=0 || chan[5].dacSample<0 || isMuted[5]) {
229 rWrite(12+i,(63+chan[i].outVol*chan[i].panR)>>6);
230 }
231 } else {
232 if (i!=0 || chan[4].dacSample<0 || isMuted[4]) {
233 rWrite(8+i,0);
234 }
235 if (i!=0 || chan[5].dacSample<0 || isMuted[5]) {
236 rWrite(12+i,0);
237 }
238 }
239 }
240 chan[i].writeVol=false;
241 }
242
243 if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) {
244 if (i>=4) {
245 chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,chan[i].fixedArp?chan[i].baseNoteOverride:chan[i].arpOff,chan[i].fixedArp,false,0,chan[i].pitch2,1,1);
246
247 double off=1.0;
248 if (chan[i].dacSample>=0 && chan[i].dacSample<parent->song.sampleLen) {
249 DivSample* s=parent->getSample(chan[i].dacSample);
250 off=(double)s->centerRate/parent->getCenterRate();
251 }
252 chan[i].dacRate=chan[i].freq*off;
253 } else {
254 chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,chan[i].fixedArp?chan[i].baseNoteOverride:chan[i].arpOff,chan[i].fixedArp,true,0,chan[i].pitch2,chipClock,CHIP_DIVIDER);
255 }
256
257 if (i<3) {
258 switch (chan[i].wave) {
259 case 0:
260 chan[i].freq>>=2;
261 break;
262 case 1:
263 chan[i].freq/=5;
264 chan[i].freq>>=1;
265 break;
266 case 2:
267 chan[i].freq/=15;
268 chan[i].freq>>=1;
269 break;
270 case 3:
271 chan[i].freq/=63;
272 break;
273 case 4:
274 chan[i].freq>>=5;
275 break;
276 }
277 }
278
279 if (i<4) {
280 if (chan[i].freq<1) chan[i].freq=1;
281 if (chan[i].freq>4095) chan[i].freq=4095;
282 }
283
284 if (i<3) {
285 if (chan[i].wave==1) { // short 1
286 chan[i].freq=15*(chan[i].freq/15)+snapPeriodShort[(chan[i].freq%15)];
287 } else if (chan[i].wave==2) { // long 1
288 chan[i].freq=15*(chan[i].freq/15)+snapPeriodLong[(chan[i].freq%15)];
289 } else if (chan[i].wave==3) { // long 2 (30, 61, 92, 123... result in silence)
290 if ((chan[i].freq%30)==(chan[i].freq/30)-1) chan[i].freq++;
291 }
292 rWrite((i<<1),chan[i].freq&0xff);
293 rWrite(1+(i<<1),(chan[i].freq>>8)|((waveMap[chan[i].wave])<<4)|(chan[i].highPass?0x40:0)|(chan[i].ringMod?0x80:0));
294 } else if (i==3) {
295 rWrite(6,(chan[i].noiseFreq&3)|((chan[i].wave&3)<<2)|(chan[i].swapCounters?0x10:0)|(chan[i].lowPass?0x20:0)|(chan[i].highPass?0x40:0)|(chan[i].ringMod?0x80:0));
296 }
297
298 if (chan[i].keyOn) chan[i].keyOn=false;
299 if (chan[i].keyOff) chan[i].keyOff=false;
300 chan[i].freqChanged=false;
301 }
302 }
303
304 if (writeControl) {
305 rWrite(7,(chan[0].resetPhase?1:0)|(chan[1].resetPhase?2:0)|(chan[2].resetPhase?4:0)|((chan[4].dacSample>=0 && !isMuted[4])?8:0)|((chan[5].dacSample>=0 && !isMuted[5])?16:0));
306 rWrite(7,((chan[4].dacSample>=0 && !isMuted[4])?8:0)|((chan[5].dacSample>=0 && !isMuted[5])?16:0));
307 chan[0].resetPhase=false;
308 chan[1].resetPhase=false;
309 chan[2].resetPhase=false;
310 chan[3].resetPhase=false;
311 writeControl=false;
312 }
313 }
314
315 int DivPlatformDave::dispatch(DivCommand c) {
316 switch (c.cmd) {
317 case DIV_CMD_NOTE_ON: {
318 DivInstrument* ins=NULL;
319 // DAC
320 if (c.chan>=4) {
321 ins=parent->getIns(chan[c.chan].ins,DIV_INS_AMIGA);
322 if (c.value!=DIV_NOTE_NULL) {
323 chan[c.chan].dacSample=ins->amiga.getSample(c.value);
324 chan[c.chan].sampleNote=c.value;
325 c.value=ins->amiga.getFreq(c.value);
326 chan[c.chan].sampleNoteDelta=c.value-chan[c.chan].sampleNote;
327 } else if (chan[c.chan].sampleNote!=DIV_NOTE_NULL) {
328 chan[c.chan].dacSample=ins->amiga.getSample(chan[c.chan].sampleNote);
329 c.value=ins->amiga.getFreq(chan[c.chan].sampleNote);
330 }
331 if (chan[c.chan].dacSample<0 || chan[c.chan].dacSample>=parent->song.sampleLen) {
332 chan[c.chan].dacSample=-1;
333 chan[0].writeVol=true;
334 }
335 if (c.value!=DIV_NOTE_NULL) {
336 chan[c.chan].baseFreq=parent->calcBaseFreq(1,1,c.value,false);
337 chan[c.chan].freqChanged=true;
338 chan[c.chan].note=c.value;
339 }
340 if (chan[c.chan].setPos) {
341 chan[c.chan].setPos=false;
342 } else {
343 chan[c.chan].dacPos=0;
344 }
345 chan[c.chan].dacPeriod=0;
346 writeControl=true;
347 } else {
348 ins=parent->getIns(chan[c.chan].ins,DIV_INS_DAVE);
349 chan[c.chan].sampleNote=DIV_NOTE_NULL;
350 chan[c.chan].sampleNoteDelta=0;
351 if (c.value!=DIV_NOTE_NULL) {
352 chan[c.chan].baseFreq=NOTE_PERIODIC(c.value);
353 chan[c.chan].freqChanged=true;
354 chan[c.chan].note=c.value;
355 }
356 }
357 chan[c.chan].active=true;
358 chan[c.chan].keyOn=true;
359 chan[c.chan].writeVol=true;
360 chan[c.chan].macroInit(ins);
361 if (!parent->song.brokenOutVol && !chan[c.chan].std.vol.will) {
362 chan[c.chan].outVol=chan[c.chan].vol;
363 }
364 chan[c.chan].insChanged=false;
365 break;
366 }
367 case DIV_CMD_NOTE_OFF:
368 chan[c.chan].active=false;
369 chan[c.chan].keyOff=true;
370 chan[c.chan].writeVol=true;
371 if (c.chan>=4) {
372 chan[c.chan].dacSample=-1;
373 chan[0].writeVol=true;
374 writeControl=true;
375 }
376 chan[c.chan].macroInit(NULL);
377 break;
378 case DIV_CMD_NOTE_OFF_ENV:
379 case DIV_CMD_ENV_RELEASE:
380 chan[c.chan].std.release();
381 break;
382 case DIV_CMD_INSTRUMENT:
383 if (chan[c.chan].ins!=c.value || c.value2==1) {
384 chan[c.chan].ins=c.value;
385 chan[c.chan].insChanged=true;
386 }
387 break;
388 case DIV_CMD_VOLUME:
389 if (chan[c.chan].vol!=c.value) {
390 chan[c.chan].vol=c.value;
391 if (!chan[c.chan].std.vol.has) {
392 chan[c.chan].outVol=c.value;
393 if (chan[c.chan].active) {
394 chan[c.chan].writeVol=true;
395 }
396 }
397 }
398 break;
399 case DIV_CMD_GET_VOLUME:
400 if (chan[c.chan].std.vol.has) {
401 return chan[c.chan].vol;
402 }
403 return chan[c.chan].outVol;
404 break;
405 case DIV_CMD_PITCH:
406 chan[c.chan].pitch=c.value;
407 chan[c.chan].freqChanged=true;
408 break;
409 case DIV_CMD_WAVE:
410 chan[c.chan].wave=c.value;
411 if (chan[c.chan].wave>4) chan[c.chan].wave=4;
412 if (c.chan==3 && chan[c.chan].wave>3) chan[c.chan].wave=3;
413 chan[c.chan].freqChanged=true;
414 break;
415 case DIV_CMD_STD_NOISE_MODE:
416 chan[c.chan].noiseFreq=c.value&3;
417 chan[c.chan].freqChanged=true;
418 break;
419 case DIV_CMD_DAVE_HIGH_PASS:
420 chan[c.chan].highPass=c.value;
421 chan[c.chan].freqChanged=true;
422 break;
423 case DIV_CMD_DAVE_RING_MOD:
424 chan[c.chan].ringMod=c.value;
425 chan[c.chan].freqChanged=true;
426 break;
427 case DIV_CMD_DAVE_SWAP_COUNTERS:
428 chan[c.chan].swapCounters=c.value;
429 chan[c.chan].freqChanged=true;
430 break;
431 case DIV_CMD_DAVE_LOW_PASS:
432 chan[c.chan].lowPass=c.value;
433 chan[c.chan].freqChanged=true;
434 break;
435 case DIV_CMD_DAVE_CLOCK_DIV:
436 clockDiv=c.value;
437 rWrite(31,clockDiv?2:0);
438 break;
439 case DIV_CMD_NOTE_PORTA: {
440 int destFreq=NOTE_PERIODIC(c.value2+chan[c.chan].sampleNoteDelta);
441 bool return2=false;
442 if (destFreq>chan[c.chan].baseFreq) {
443 chan[c.chan].baseFreq+=c.value;
444 if (chan[c.chan].baseFreq>=destFreq) {
445 chan[c.chan].baseFreq=destFreq;
446 return2=true;
447 }
448 } else {
449 chan[c.chan].baseFreq-=c.value;
450 if (chan[c.chan].baseFreq<=destFreq) {
451 chan[c.chan].baseFreq=destFreq;
452 return2=true;
453 }
454 }
455 chan[c.chan].freqChanged=true;
456 if (return2) {
457 chan[c.chan].inPorta=false;
458 return 2;
459 }
460 break;
461 }
462 case DIV_CMD_PANNING: {
463 chan[c.chan].panL=c.value>>2;
464 chan[c.chan].panR=c.value2>>2;
465 break;
466 }
467 case DIV_CMD_LEGATO:
468 chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+chan[c.chan].sampleNoteDelta);
469 chan[c.chan].freqChanged=true;
470 chan[c.chan].note=c.value;
471 break;
472 case DIV_CMD_PRE_PORTA:
473 if (chan[c.chan].active && c.value2) {
474 if (parent->song.resetMacroOnPorta) chan[c.chan].macroInit(parent->getIns(chan[c.chan].ins,DIV_INS_DAVE));
475 }
476 if (!chan[c.chan].inPorta && c.value && !parent->song.brokenPortaArp && chan[c.chan].std.arp.will && !NEW_ARP_STRAT) chan[c.chan].baseFreq=NOTE_PERIODIC(chan[c.chan].note);
477 chan[c.chan].inPorta=c.value;
478 break;
479 case DIV_CMD_SAMPLE_POS:
480 if (c.chan<4) break;
481 chan[c.chan].dacPos=c.value;
482 chan[c.chan].setPos=true;
483 break;
484 case DIV_CMD_GET_VOLMAX:
485 return 63;
486 break;
487 case DIV_CMD_MACRO_OFF:
488 chan[c.chan].std.mask(c.value,true);
489 break;
490 case DIV_CMD_MACRO_ON:
491 chan[c.chan].std.mask(c.value,false);
492 break;
493 case DIV_CMD_MACRO_RESTART:
494 chan[c.chan].std.restart(c.value);
495 break;
496 default:
497 break;
498 }
499 return 1;
500 }
501
502 void DivPlatformDave::muteChannel(int ch, bool mute) {
503 isMuted[ch]=mute;
504 chan[ch].writeVol=true;
505 if (ch>=4) {
506 chan[0].writeVol=true;
507 writeControl=true;
508 }
509 }
510
511 void DivPlatformDave::forceIns() {
512 for (int i=0; i<6; i++) {
513 chan[i].insChanged=true;
514 chan[i].freqChanged=true;
515 chan[i].writeVol=true;
516 }
517 writeControl=true;
518 rWrite(31,clockDiv?2:0);
519 }
520
521 void* DivPlatformDave::getChanState(int ch) {
522 return &chan[ch];
523 }
524
525 DivMacroInt* DivPlatformDave::getChanMacroInt(int ch) {
526 return &chan[ch].std;
527 }
528
529 unsigned short DivPlatformDave::getPan(int ch) {
530 if (ch==5) return 1;
531 if (ch==4) return 0x100;
532 return (chan[ch].panL<<8)|chan[ch].panR;
533 }
534
535 void DivPlatformDave::getPaired(int ch, std::vector<DivChannelPair>& ret) {
536 if (chan[ch].highPass) {
537 ret.push_back(DivChannelPair(_("high"),(ch+1)&3));
538 }
539 if (chan[ch].ringMod) {
540 ret.push_back(DivChannelPair(_("ring"),(ch+2)&3));
541 }
542 if (chan[ch].lowPass && ch==3) {
543 ret.push_back(DivChannelPair(_("low"),2));
544 }
545 }
546
547 DivChannelModeHints DivPlatformDave::getModeHints(int ch) {
548 DivChannelModeHints ret;
549 return ret;
550 }
551
552 DivSamplePos DivPlatformDave::getSamplePos(int ch) {
553 if (ch<4 || ch>=6) return DivSamplePos();
554 return DivSamplePos(
555 chan[ch].dacSample,
556 chan[ch].dacPos,
557 chan[ch].dacRate
558 );
559 }
560
561 DivDispatchOscBuffer* DivPlatformDave::getOscBuffer(int ch) {
562 return oscBuf[ch];
563 }
564
565 unsigned char* DivPlatformDave::getRegisterPool() {
566 return regPool;
567 }
568
569 int DivPlatformDave::getRegisterPoolSize() {
570 return 32;
571 }
572
573 void DivPlatformDave::reset() {
574 writes.clear();
575 memset(regPool,0,32);
576 for (int i=0; i<6; i++) {
577 chan[i]=DivPlatformDave::Channel();
578 chan[i].std.setEngine(parent);
579 }
580 if (dumpWrites) {
581 addWrite(0xffffffff,0);
582 }
583 writeControl=false;
584 clockDiv=false;
585 dave->reset(true);
586 }
587
588 int DivPlatformDave::getOutputCount() {
589 return 2;
590 }
591
592 bool DivPlatformDave::keyOffAffectsArp(int ch) {
593 return true;
594 }
595
596 void DivPlatformDave::notifyInsDeletion(void* ins) {
597 for (int i=0; i<6; i++) {
598 chan[i].std.notifyInsDeletion((DivInstrument*)ins);
599 }
600 }
601
602 void DivPlatformDave::setFlags(const DivConfig& flags) {
603 chipClock=8000000.0;
604 CHECK_CUSTOM_CLOCK;
605 rate=chipClock/16;
606 for (int i=0; i<6; i++) {
607 oscBuf[i]->setRate(rate);
608 }
609 }
610
611 void DivPlatformDave::poke(unsigned int addr, unsigned short val) {
612 rWrite(addr,val);
613 }
614
615 void DivPlatformDave::poke(std::vector<DivRegWrite>& wlist) {
616 for (DivRegWrite& i: wlist) rWrite(i.addr,i.val);
617 }
618
619 int DivPlatformDave::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) {
620 parent=p;
621 dumpWrites=false;
622 skipRegisterWrites=false;
623 dave=new Ep128::Dave;
624 for (int i=0; i<6; i++) {
625 isMuted[i]=false;
626 oscBuf[i]=new DivDispatchOscBuffer;
627 }
628 setFlags(flags);
629 reset();
630 return 6;
631 }
632
633 void DivPlatformDave::quit() {
634 for (int i=0; i<6; i++) {
635 delete oscBuf[i];
636 }
637 delete dave;
638 }
639
640 DivPlatformDave::~DivPlatformDave() {
641 }