gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

mqmc.h (2122B)


      1 #pragma once
      2 
      3 #include <list>
      4 #include <memory>
      5 
      6 #include "buttons.h"
      7 #include "lcd.h"
      8 #include "leds.h"
      9 
     10 #include "hardwareLib/am29f.h"
     11 
     12 #include "mc68k/mc68k.h"
     13 #include "mc68k/hdi08periph.h"
     14 
     15 #define SUPPORT_NMI_INTERRUPT 0
     16 
     17 namespace mqLib
     18 {
     19 	class ROM;
     20 
     21 	using MqHdi08A = mc68k::Hdi08Periph<0xfd000>;
     22 	using MqHdi08B = mc68k::Hdi08Periph<0xfb000>;
     23 	using MqHdi08C = mc68k::Hdi08Periph<0xfc000>;
     24 
     25 	class MqMc final : public mc68k::Mc68k
     26 	{
     27 	public:
     28 		explicit MqMc(const ROM& _rom);
     29 		~MqMc() override;
     30 
     31 		uint32_t exec() override;
     32 
     33 		Buttons& getButtons() { return m_buttons; }
     34 		Leds& getLeds() { return m_leds; }
     35 		LCD& getLcd() { return m_lcd; }
     36 		MqHdi08A& getHdi08A() { return m_hdi08a; }
     37 		MqHdi08B& getHdi08B() { return m_hdi08b; }
     38 		MqHdi08C& getHdi08C() { return m_hdi08c; }
     39 
     40 		bool requestDSPReset() const { return m_dspResetRequest; }
     41 		void notifyDSPBooted();
     42 
     43 #if SUPPORT_NMI_INTERRUPT
     44 		uint8_t requestDSPinjectNMI() const { return m_dspInjectNmiRequest; }
     45 #endif
     46 
     47 		void dumpMemory(const char* _filename) const;
     48 		void dumpROM(const char* _filename) const;
     49 		void dumpAssembly(uint32_t _first, uint32_t _count);
     50 
     51 		uint16_t readImm16(uint32_t _addr) override;
     52 		uint16_t read16(uint32_t addr) override;
     53 		uint8_t read8(uint32_t addr) override;
     54 		void write16(uint32_t addr, uint16_t val) override;
     55 		void write8(uint32_t addr, uint8_t val) override;
     56 
     57 	private:
     58 		void onReset() override;
     59 		uint32_t onIllegalInstruction(uint32_t opcode) override;
     60 
     61 		void onPortEWritten();
     62 		void onPortFWritten();
     63 		void onPortGPWritten();
     64 		void onPortQSWritten();
     65 
     66 		void processLCDandLEDs();
     67 
     68 		const ROM& m_rom;
     69 		std::vector<uint8_t> m_romRuntimeData;
     70 		std::unique_ptr<hwLib::Am29f> m_flash;	// Its a MX 29F400TTC-70 which is a 4MBit (512kx8) AM29 compatible flash with top boot block
     71 		LCD m_lcd;
     72 		Buttons m_buttons;
     73 		Leds m_leds;
     74 
     75 		MqHdi08A m_hdi08a;
     76 		MqHdi08B m_hdi08b;
     77 		MqHdi08C m_hdi08c;
     78 
     79 		std::vector<uint8_t> m_memory;
     80 		std::list<uint32_t> m_lastPCs;
     81 		bool m_dspResetRequest = false;
     82 		bool m_dspResetCompleted = false;
     83 
     84 #if SUPPORT_NMI_INTERRUPT
     85 		uint8_t m_dspInjectNmiRequest = 0;
     86 #endif
     87 	};
     88 }