| 
									
										
										
										
											2022-12-15 06:03:54 -05:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Furnace Tracker - multi-system chiptune tracker | 
					
						
							| 
									
										
										
										
											2024-01-16 21:26:57 -05:00
										 |  |  |  * Copyright (C) 2021-2024 tildearrow and contributors | 
					
						
							| 
									
										
										
										
											2022-12-15 06:03:54 -05:00
										 |  |  |  * | 
					
						
							|  |  |  |  * 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 _GA20_H
 | 
					
						
							|  |  |  | #define _GA20_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "../dispatch.h"
 | 
					
						
							| 
									
										
										
										
											2023-09-13 03:46:02 -04:00
										 |  |  | #include "../../fixedQueue.h"
 | 
					
						
							| 
									
										
										
										
											2022-12-15 06:03:54 -05:00
										 |  |  | #include "../macroInt.h"
 | 
					
						
							|  |  |  | #include "sound/ga20/iremga20.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class DivPlatformGA20: public DivDispatch, public iremga20_intf { | 
					
						
							|  |  |  |   struct Channel: public SharedChannel<int> { | 
					
						
							|  |  |  |     int prevFreq; | 
					
						
							|  |  |  |     unsigned int audPos; | 
					
						
							|  |  |  |     int sample; | 
					
						
							|  |  |  |     bool volumeChanged, setPos; | 
					
						
							| 
									
										
										
										
											2022-12-15 06:12:06 -05:00
										 |  |  |     int resVol; | 
					
						
							| 
									
										
										
										
											2022-12-15 06:03:54 -05:00
										 |  |  |     int macroVolMul; | 
					
						
							|  |  |  |     Channel(): | 
					
						
							| 
									
										
										
										
											2022-12-15 06:12:06 -05:00
										 |  |  |       SharedChannel<int>(255), | 
					
						
							| 
									
										
										
										
											2022-12-15 06:03:54 -05:00
										 |  |  |       prevFreq(-1), | 
					
						
							|  |  |  |       audPos(0), | 
					
						
							|  |  |  |       sample(-1), | 
					
						
							|  |  |  |       volumeChanged(false), | 
					
						
							|  |  |  |       setPos(false), | 
					
						
							| 
									
										
										
										
											2022-12-15 06:12:06 -05:00
										 |  |  |       resVol(255), | 
					
						
							| 
									
										
										
										
											2022-12-15 06:03:54 -05:00
										 |  |  |       macroVolMul(64) {} | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  |   Channel chan[4]; | 
					
						
							|  |  |  |   DivDispatchOscBuffer* oscBuf[4]; | 
					
						
							|  |  |  |   bool isMuted[4]; | 
					
						
							|  |  |  |   struct QueuedWrite { | 
					
						
							| 
									
										
										
										
											2023-07-13 05:09:20 -04:00
										 |  |  |     unsigned char addr; | 
					
						
							| 
									
										
										
										
											2022-12-15 06:03:54 -05:00
										 |  |  |     unsigned char val; | 
					
						
							| 
									
										
										
										
											2023-07-13 05:09:20 -04:00
										 |  |  |     QueuedWrite(): addr(0), val(0) {} | 
					
						
							|  |  |  |     QueuedWrite(unsigned char a, unsigned char v): | 
					
						
							| 
									
										
										
										
											2022-12-15 06:03:54 -05:00
										 |  |  |       addr(a), | 
					
						
							| 
									
										
										
										
											2023-07-13 05:09:20 -04:00
										 |  |  |       val(v) {} | 
					
						
							| 
									
										
										
										
											2022-12-15 06:03:54 -05:00
										 |  |  |   }; | 
					
						
							| 
									
										
										
										
											2023-07-13 05:09:20 -04:00
										 |  |  |   FixedQueue<QueuedWrite,256> writes; | 
					
						
							| 
									
										
										
										
											2022-12-15 06:03:54 -05:00
										 |  |  |   unsigned int sampleOffGA20[256]; | 
					
						
							|  |  |  |   bool sampleLoaded[256]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   int delay; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   short* ga20Buf[4]; | 
					
						
							|  |  |  |   size_t ga20BufLen; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   unsigned char* sampleMem; | 
					
						
							|  |  |  |   size_t sampleMemLen; | 
					
						
							|  |  |  |   iremga20_device ga20; | 
					
						
							| 
									
										
										
										
											2024-03-05 18:55:18 -05:00
										 |  |  |   DivMemoryComposition memCompo; | 
					
						
							| 
									
										
										
										
											2022-12-15 06:03:54 -05:00
										 |  |  |   unsigned char regPool[32]; | 
					
						
							|  |  |  |   friend void putDispatchChip(void*,int); | 
					
						
							|  |  |  |   friend void putDispatchChan(void*,int,int); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   void chWrite(unsigned char ch, unsigned int addr, unsigned char val); | 
					
						
							|  |  |  |   public: | 
					
						
							|  |  |  |     virtual u8 read_byte(u32 address) override; | 
					
						
							| 
									
										
										
										
											2023-01-02 04:53:37 -05:00
										 |  |  |     virtual void acquire(short** buf, size_t len) override; | 
					
						
							| 
									
										
										
										
											2022-12-15 06:37:19 -05:00
										 |  |  |     virtual int dispatch(DivCommand c) override; | 
					
						
							|  |  |  |     virtual void* getChanState(int chan) override; | 
					
						
							|  |  |  |     virtual DivMacroInt* getChanMacroInt(int ch) override; | 
					
						
							| 
									
										
										
										
											2023-03-21 04:56:17 -04:00
										 |  |  |     virtual DivSamplePos getSamplePos(int ch) override; | 
					
						
							| 
									
										
										
										
											2022-12-15 06:37:19 -05:00
										 |  |  |     virtual DivDispatchOscBuffer* getOscBuffer(int chan) override; | 
					
						
							|  |  |  |     virtual unsigned char* getRegisterPool() override; | 
					
						
							|  |  |  |     virtual int getRegisterPoolSize() override; | 
					
						
							|  |  |  |     virtual void reset() override; | 
					
						
							|  |  |  |     virtual void forceIns() override; | 
					
						
							|  |  |  |     virtual void tick(bool sysTick=true) override; | 
					
						
							|  |  |  |     virtual void muteChannel(int ch, bool mute) override; | 
					
						
							| 
									
										
										
										
											2023-01-01 19:46:08 -05:00
										 |  |  |     virtual int getOutputCount() override; | 
					
						
							| 
									
										
										
										
											2022-12-15 06:37:19 -05:00
										 |  |  |     virtual void notifyInsChange(int ins) override; | 
					
						
							|  |  |  |     virtual void notifyWaveChange(int wave) override; | 
					
						
							|  |  |  |     virtual void notifyInsDeletion(void* ins) override; | 
					
						
							|  |  |  |     virtual void setFlags(const DivConfig& flags) override; | 
					
						
							|  |  |  |     virtual void poke(unsigned int addr, unsigned short val) override; | 
					
						
							|  |  |  |     virtual void poke(std::vector<DivRegWrite>& wlist) override; | 
					
						
							|  |  |  |     virtual const char** getRegisterSheet() override; | 
					
						
							|  |  |  |     virtual const void* getSampleMem(int index = 0) override; | 
					
						
							|  |  |  |     virtual size_t getSampleMemCapacity(int index = 0) override; | 
					
						
							|  |  |  |     virtual size_t getSampleMemUsage(int index = 0) override; | 
					
						
							|  |  |  |     virtual bool isSampleLoaded(int index, int sample) override; | 
					
						
							| 
									
										
										
										
											2024-03-05 18:55:18 -05:00
										 |  |  |     virtual const DivMemoryComposition* getMemCompo(int index) override; | 
					
						
							| 
									
										
										
										
											2022-12-15 06:37:19 -05:00
										 |  |  |     virtual void renderSamples(int chipID) override; | 
					
						
							|  |  |  |     virtual int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags) override; | 
					
						
							|  |  |  |     virtual void quit() override; | 
					
						
							| 
									
										
										
										
											2022-12-15 06:03:54 -05:00
										 |  |  |     DivPlatformGA20(): | 
					
						
							|  |  |  |       DivDispatch(), | 
					
						
							|  |  |  |       iremga20_intf(), | 
					
						
							|  |  |  |       ga20(*this) {} | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif
 |