| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  | #include "amiga.h"
 | 
					
						
							|  |  |  | #include "../engine.h"
 | 
					
						
							|  |  |  | #include <math.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define AMIGA_DIVIDER 8
 | 
					
						
							| 
									
										
										
										
											2022-01-28 00:55:51 -05:00
										 |  |  | #define CHIP_DIVIDER 16
 | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-02 02:14:42 -05:00
										 |  |  | const char* regCheatSheetAmiga[]={ | 
					
						
							|  |  |  |   "DMACON", "96", | 
					
						
							|  |  |  |   "INTENA", "9A", | 
					
						
							|  |  |  |   "ADKCON", "9E", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   "AUD0LCH", "A0", | 
					
						
							|  |  |  |   "AUD0LCL", "A2", | 
					
						
							|  |  |  |   "AUD0LEN", "A4", | 
					
						
							|  |  |  |   "AUD0PER", "A6", | 
					
						
							|  |  |  |   "AUD0VOL", "A8", | 
					
						
							|  |  |  |   "AUD0DAT", "AA", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   "AUD1LCH", "B0", | 
					
						
							|  |  |  |   "AUD1LCL", "B2", | 
					
						
							|  |  |  |   "AUD1LEN", "B4", | 
					
						
							|  |  |  |   "AUD1PER", "B6", | 
					
						
							|  |  |  |   "AUD1VOL", "B8", | 
					
						
							|  |  |  |   "AUD1DAT", "BA", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   "AUD2LCH", "C0", | 
					
						
							|  |  |  |   "AUD2LCL", "C2", | 
					
						
							|  |  |  |   "AUD2LEN", "C4", | 
					
						
							|  |  |  |   "AUD2PER", "C6", | 
					
						
							|  |  |  |   "AUD2VOL", "C8", | 
					
						
							|  |  |  |   "AUD2DAT", "CA", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   "AUD3LCH", "D0", | 
					
						
							|  |  |  |   "AUD3LCL", "D2", | 
					
						
							|  |  |  |   "AUD3LEN", "D4", | 
					
						
							|  |  |  |   "AUD3PER", "D6", | 
					
						
							|  |  |  |   "AUD3VOL", "D8", | 
					
						
							|  |  |  |   "AUD3DAT", "DA", | 
					
						
							|  |  |  |   NULL | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-03 18:38:57 -05:00
										 |  |  | const char** DivPlatformAmiga::getRegisterSheet() { | 
					
						
							|  |  |  |   return regCheatSheetAmiga; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  | void DivPlatformAmiga::acquire(short* bufL, short* bufR, size_t start, size_t len) { | 
					
						
							|  |  |  |   for (size_t h=start; h<start+len; h++) { | 
					
						
							| 
									
										
										
										
											2022-01-15 17:28:33 -05:00
										 |  |  |     bufL[h]=0; | 
					
						
							|  |  |  |     bufR[h]=0; | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |     for (int i=0; i<4; i++) { | 
					
						
							| 
									
										
										
										
											2022-01-24 15:47:39 -05:00
										 |  |  |       if (chan[i].sample>=0 && chan[i].sample<parent->song.sampleLen) { | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |         chan[i].audSub-=AMIGA_DIVIDER; | 
					
						
							| 
									
										
										
										
											2022-01-15 17:28:33 -05:00
										 |  |  |         if (chan[i].audSub<0) { | 
					
						
							|  |  |  |           DivSample* s=parent->song.sample[chan[i].sample]; | 
					
						
							| 
									
										
										
										
											2022-01-24 15:47:39 -05:00
										 |  |  |           if (s->rendLength>0) { | 
					
						
							|  |  |  |             if (s->depth==8) { | 
					
						
							|  |  |  |               chan[i].audDat=s->rendData[chan[i].audPos++]; | 
					
						
							| 
									
										
										
										
											2022-01-15 18:03:37 -05:00
										 |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2022-01-24 15:47:39 -05:00
										 |  |  |               chan[i].audDat=s->rendData[chan[i].audPos++]>>8; | 
					
						
							| 
									
										
										
										
											2022-01-15 18:03:37 -05:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2022-01-24 15:47:39 -05:00
										 |  |  |             if (chan[i].audPos>=s->rendLength || chan[i].audPos>=131071) { | 
					
						
							|  |  |  |               if (s->loopStart>=0 && s->loopStart<=(int)s->rendLength) { | 
					
						
							|  |  |  |                 chan[i].audPos=s->loopStart; | 
					
						
							|  |  |  |               } else { | 
					
						
							|  |  |  |                 chan[i].sample=-1; | 
					
						
							|  |  |  |               } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           } else { | 
					
						
							|  |  |  |             chan[i].sample=-1; | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2022-02-12 17:43:30 -05:00
										 |  |  |           if (chan[i].freq<124) { | 
					
						
							|  |  |  |             if (++chan[i].busClock>=512) { | 
					
						
							|  |  |  |               unsigned int rAmount=(124-chan[i].freq)*2; | 
					
						
							|  |  |  |               if (chan[i].audPos>=rAmount) { | 
					
						
							|  |  |  |                 chan[i].audPos-=rAmount; | 
					
						
							|  |  |  |               } | 
					
						
							|  |  |  |               chan[i].busClock=0; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           } | 
					
						
							| 
									
										
										
										
											2022-01-15 22:49:09 -05:00
										 |  |  |           chan[i].audSub+=MAX(114,chan[i].freq); | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2022-01-15 17:28:33 -05:00
										 |  |  |       if (!isMuted[i]) { | 
					
						
							|  |  |  |         if (i==0 || i==3) { | 
					
						
							| 
									
										
										
										
											2022-02-04 17:59:55 -05:00
										 |  |  |           bufL[h]+=((chan[i].audDat*chan[i].outVol)*sep1)>>7; | 
					
						
							|  |  |  |           bufR[h]+=((chan[i].audDat*chan[i].outVol)*sep2)>>7; | 
					
						
							| 
									
										
										
										
											2022-01-15 17:28:33 -05:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2022-02-04 17:59:55 -05:00
										 |  |  |           bufL[h]+=((chan[i].audDat*chan[i].outVol)*sep2)>>7; | 
					
						
							|  |  |  |           bufR[h]+=((chan[i].audDat*chan[i].outVol)*sep1)>>7; | 
					
						
							| 
									
										
										
										
											2022-01-15 17:28:33 -05:00
										 |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void DivPlatformAmiga::tick() { | 
					
						
							|  |  |  |   for (int i=0; i<4; i++) { | 
					
						
							|  |  |  |     chan[i].std.next(); | 
					
						
							|  |  |  |     if (chan[i].std.hadVol) { | 
					
						
							| 
									
										
										
										
											2022-01-30 12:31:50 -05:00
										 |  |  |       chan[i].outVol=((chan[i].vol%65)*MIN(64,chan[i].std.vol))>>6; | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-02-04 03:29:40 -05:00
										 |  |  |     double off=1.0; | 
					
						
							|  |  |  |     if (chan[i].sample>=0 && chan[i].sample<parent->song.sampleLen) { | 
					
						
							|  |  |  |       DivSample* s=parent->song.sample[chan[i].sample]; | 
					
						
							|  |  |  |       if (s->centerRate<1) { | 
					
						
							|  |  |  |         off=1.0; | 
					
						
							|  |  |  |       } else { | 
					
						
							|  |  |  |         off=8363.0/(double)s->centerRate; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |     if (chan[i].std.hadArp) { | 
					
						
							|  |  |  |       if (!chan[i].inPorta) { | 
					
						
							|  |  |  |         if (chan[i].std.arpMode) { | 
					
						
							| 
									
										
										
										
											2022-02-04 03:29:40 -05:00
										 |  |  |           chan[i].baseFreq=off*NOTE_PERIODIC(chan[i].std.arp); | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2022-02-04 03:29:40 -05:00
										 |  |  |           chan[i].baseFreq=off*NOTE_PERIODIC(chan[i].note+chan[i].std.arp); | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       chan[i].freqChanged=true; | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       if (chan[i].std.arpMode && chan[i].std.finishedArp) { | 
					
						
							| 
									
										
										
										
											2022-02-04 03:29:40 -05:00
										 |  |  |         chan[i].baseFreq=off*NOTE_PERIODIC(chan[i].note); | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |         chan[i].freqChanged=true; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (chan[i].std.hadWave) { | 
					
						
							|  |  |  |       if (chan[i].wave!=chan[i].std.wave) { | 
					
						
							|  |  |  |         chan[i].wave=chan[i].std.wave; | 
					
						
							|  |  |  |         if (!chan[i].keyOff) chan[i].keyOn=true; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { | 
					
						
							|  |  |  |       //DivInstrument* ins=parent->getIns(chan[i].ins);
 | 
					
						
							|  |  |  |       chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true); | 
					
						
							|  |  |  |       if (chan[i].freq>4095) chan[i].freq=4095; | 
					
						
							|  |  |  |       if (chan[i].note>0x5d) chan[i].freq=0x01; | 
					
						
							|  |  |  |       if (chan[i].keyOn) { | 
					
						
							|  |  |  |         if (chan[i].wave<0) { | 
					
						
							|  |  |  |           chan[i].wave=0; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       if (chan[i].keyOff) { | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       if (chan[i].keyOn) chan[i].keyOn=false; | 
					
						
							|  |  |  |       if (chan[i].keyOff) chan[i].keyOff=false; | 
					
						
							|  |  |  |       chan[i].freqChanged=false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int DivPlatformAmiga::dispatch(DivCommand c) { | 
					
						
							|  |  |  |   switch (c.cmd) { | 
					
						
							| 
									
										
										
										
											2022-01-15 17:28:33 -05:00
										 |  |  |     case DIV_CMD_NOTE_ON: { | 
					
						
							|  |  |  |       DivInstrument* ins=parent->getIns(chan[c.chan].ins); | 
					
						
							| 
									
										
										
										
											2022-02-04 03:29:40 -05:00
										 |  |  |       chan[c.chan].sample=ins->amiga.initSample; | 
					
						
							|  |  |  |       double off=1.0; | 
					
						
							|  |  |  |       if (chan[c.chan].sample>=0 && chan[c.chan].sample<parent->song.sampleLen) { | 
					
						
							|  |  |  |         DivSample* s=parent->song.sample[chan[c.chan].sample]; | 
					
						
							|  |  |  |         if (s->centerRate<1) { | 
					
						
							|  |  |  |           off=1.0; | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |           off=8363.0/(double)s->centerRate; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2022-01-19 00:01:34 -05:00
										 |  |  |       if (c.value!=DIV_NOTE_NULL) { | 
					
						
							| 
									
										
										
										
											2022-02-04 03:29:40 -05:00
										 |  |  |         chan[c.chan].baseFreq=off*NOTE_PERIODIC(c.value); | 
					
						
							| 
									
										
										
										
											2022-01-19 00:01:34 -05:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2022-01-15 17:28:33 -05:00
										 |  |  |       if (chan[c.chan].sample<0 || chan[c.chan].sample>=parent->song.sampleLen) { | 
					
						
							|  |  |  |         chan[c.chan].sample=-1; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       chan[c.chan].audPos=0; | 
					
						
							|  |  |  |       chan[c.chan].audSub=0; | 
					
						
							| 
									
										
										
										
											2022-01-19 00:01:34 -05:00
										 |  |  |       if (c.value!=DIV_NOTE_NULL) { | 
					
						
							|  |  |  |         chan[c.chan].freqChanged=true; | 
					
						
							|  |  |  |         chan[c.chan].note=c.value; | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |       chan[c.chan].active=true; | 
					
						
							|  |  |  |       chan[c.chan].keyOn=true; | 
					
						
							| 
									
										
										
										
											2022-01-15 17:28:33 -05:00
										 |  |  |       chan[c.chan].std.init(ins); | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |       break; | 
					
						
							| 
									
										
										
										
											2022-01-15 17:28:33 -05:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |     case DIV_CMD_NOTE_OFF: | 
					
						
							| 
									
										
										
										
											2022-01-15 17:28:33 -05:00
										 |  |  |       chan[c.chan].sample=-1; | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |       chan[c.chan].active=false; | 
					
						
							|  |  |  |       chan[c.chan].keyOff=true; | 
					
						
							|  |  |  |       chan[c.chan].std.init(NULL); | 
					
						
							|  |  |  |       break; | 
					
						
							| 
									
										
										
										
											2022-02-08 13:11:04 -05:00
										 |  |  |     case DIV_CMD_NOTE_OFF_ENV: | 
					
						
							|  |  |  |     case DIV_CMD_ENV_RELEASE: | 
					
						
							|  |  |  |       chan[c.chan].std.release(); | 
					
						
							|  |  |  |       break; | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |     case DIV_CMD_INSTRUMENT: | 
					
						
							| 
									
										
										
										
											2022-01-17 18:01:40 -05:00
										 |  |  |       if (chan[c.chan].ins!=c.value || c.value2==1) { | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |         chan[c.chan].ins=c.value; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case DIV_CMD_VOLUME: | 
					
						
							|  |  |  |       if (chan[c.chan].vol!=c.value) { | 
					
						
							|  |  |  |         chan[c.chan].vol=c.value; | 
					
						
							|  |  |  |         if (!chan[c.chan].std.hasVol) { | 
					
						
							|  |  |  |           chan[c.chan].outVol=c.value; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case DIV_CMD_GET_VOLUME: | 
					
						
							|  |  |  |       if (chan[c.chan].std.hasVol) { | 
					
						
							|  |  |  |         return chan[c.chan].vol; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       return chan[c.chan].outVol; | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case DIV_CMD_PITCH: | 
					
						
							|  |  |  |       chan[c.chan].pitch=c.value; | 
					
						
							|  |  |  |       chan[c.chan].freqChanged=true; | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case DIV_CMD_WAVE: | 
					
						
							|  |  |  |       chan[c.chan].wave=c.value; | 
					
						
							|  |  |  |       chan[c.chan].keyOn=true; | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case DIV_CMD_NOTE_PORTA: { | 
					
						
							| 
									
										
										
										
											2022-01-28 00:55:51 -05:00
										 |  |  |       int destFreq=NOTE_PERIODIC(c.value2); | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |       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; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-02-04 03:29:40 -05:00
										 |  |  |     case DIV_CMD_LEGATO: { | 
					
						
							|  |  |  |       double off=1.0; | 
					
						
							|  |  |  |       if (chan[c.chan].sample>=0 && chan[c.chan].sample<parent->song.sampleLen) { | 
					
						
							|  |  |  |         DivSample* s=parent->song.sample[chan[c.chan].sample]; | 
					
						
							|  |  |  |         if (s->centerRate<1) { | 
					
						
							|  |  |  |           off=1.0; | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |           off=8363.0/(double)s->centerRate; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       chan[c.chan].baseFreq=off*NOTE_PERIODIC(c.value+((chan[c.chan].std.willArp && !chan[c.chan].std.arpMode)?(chan[c.chan].std.arp-12):(0))); | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |       chan[c.chan].freqChanged=true; | 
					
						
							|  |  |  |       chan[c.chan].note=c.value; | 
					
						
							|  |  |  |       break; | 
					
						
							| 
									
										
										
										
											2022-02-04 03:29:40 -05:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |     case DIV_CMD_PRE_PORTA: | 
					
						
							| 
									
										
										
										
											2022-02-08 22:49:52 -05:00
										 |  |  |       if (chan[c.chan].active && c.value2) { | 
					
						
							| 
									
										
										
										
											2022-02-08 22:46:58 -05:00
										 |  |  |         if (parent->song.resetMacroOnPorta) chan[c.chan].std.init(parent->getIns(chan[c.chan].ins)); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |       chan[c.chan].inPorta=c.value; | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case DIV_CMD_GET_VOLMAX: | 
					
						
							| 
									
										
										
										
											2022-01-15 17:54:09 -05:00
										 |  |  |       return 64; | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |       break; | 
					
						
							|  |  |  |     case DIV_ALWAYS_SET_VOLUME: | 
					
						
							|  |  |  |       return 1; | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   return 1; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void DivPlatformAmiga::muteChannel(int ch, bool mute) { | 
					
						
							|  |  |  |   isMuted[ch]=mute; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void DivPlatformAmiga::forceIns() { | 
					
						
							|  |  |  |   for (int i=0; i<4; i++) { | 
					
						
							|  |  |  |     chan[i].insChanged=true; | 
					
						
							|  |  |  |     chan[i].freqChanged=true; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-01-27 00:29:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | void* DivPlatformAmiga::getChanState(int ch) { | 
					
						
							|  |  |  |   return &chan[ch]; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | void DivPlatformAmiga::reset() { | 
					
						
							|  |  |  |   for (int i=0; i<4; i++) { | 
					
						
							|  |  |  |     chan[i]=DivPlatformAmiga::Channel(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool DivPlatformAmiga::isStereo() { | 
					
						
							|  |  |  |   return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool DivPlatformAmiga::keyOffAffectsArp(int ch) { | 
					
						
							|  |  |  |   return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-17 23:59:52 -05:00
										 |  |  | void DivPlatformAmiga::notifyInsChange(int ins) { | 
					
						
							|  |  |  |   for (int i=0; i<4; i++) { | 
					
						
							|  |  |  |     if (chan[i].ins==ins) { | 
					
						
							|  |  |  |       chan[i].insChanged=true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-18 00:25:10 -05:00
										 |  |  | void DivPlatformAmiga::notifyWaveChange(int wave) { | 
					
						
							|  |  |  |   // TODO when wavetables are added
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  | void DivPlatformAmiga::notifyInsDeletion(void* ins) { | 
					
						
							|  |  |  |   for (int i=0; i<4; i++) { | 
					
						
							|  |  |  |     chan[i].std.notifyInsDeletion((DivInstrument*)ins); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-28 12:59:53 -05:00
										 |  |  | void DivPlatformAmiga::setFlags(unsigned int flags) { | 
					
						
							| 
									
										
										
										
											2022-01-29 00:20:27 -05:00
										 |  |  |   if (flags&1) { | 
					
						
							| 
									
										
										
										
											2022-01-28 00:55:51 -05:00
										 |  |  |     chipClock=COLOR_PAL*4.0/5.0; | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |   } else { | 
					
						
							| 
									
										
										
										
											2022-01-28 00:55:51 -05:00
										 |  |  |     chipClock=COLOR_NTSC; | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2022-01-28 00:55:51 -05:00
										 |  |  |   rate=chipClock/AMIGA_DIVIDER; | 
					
						
							| 
									
										
										
										
											2022-02-04 17:59:55 -05:00
										 |  |  |   sep1=((flags>>8)&127)+127; | 
					
						
							|  |  |  |   sep2=127-((flags>>8)&127); | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-28 12:59:53 -05:00
										 |  |  | int DivPlatformAmiga::init(DivEngine* p, int channels, int sugRate, unsigned int flags) { | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |   parent=p; | 
					
						
							| 
									
										
										
										
											2022-01-16 23:21:27 -05:00
										 |  |  |   dumpWrites=false; | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |   skipRegisterWrites=false; | 
					
						
							|  |  |  |   for (int i=0; i<4; i++) { | 
					
						
							|  |  |  |     isMuted[i]=false; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2022-01-28 12:59:53 -05:00
										 |  |  |   setFlags(flags); | 
					
						
							| 
									
										
										
										
											2022-01-15 15:50:53 -05:00
										 |  |  |   reset(); | 
					
						
							|  |  |  |   return 6; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void DivPlatformAmiga::quit() { | 
					
						
							| 
									
										
										
										
											2022-01-30 12:31:50 -05:00
										 |  |  | } |