extern "C" { #include "iopins.h" #include "emuapi.h" } #include "keyboard_osd.h" #include "emu.h" #ifdef HAS_VGA #include uVGA uvga; #if F_CPU == 144000000 #define UVGA_144M_326X240 #define UVGA_XRES 326 #define UVGA_YRES 240 #define UVGA_XRES_EXTRA 10 #elif F_CPU == 180000000 #define UVGA_180M_360X300 #define UVGA_XRES 360 #define UVGA_YRES 300 #define UVGA_XRES_EXTRA 8 #elif F_CPU == 240000000 #define UVGA_240M_452X240 #define UVGA_XRES 452 #define UVGA_YRES 240 #define UVGA_XRES_EXTRA 12 #else #error Please select F_CPU=240MHz or F_CPU=180MHz or F_CPU=144MHz #endif #include uint8_t * VGA_frame_buffer; #endif #ifdef HAS_T4_VGA #include "vga_t_dma.h" TFT_T_DMA tft; #else #include "tft_t_dma.h" TFT_T_DMA tft = TFT_T_DMA(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCLK, TFT_MISO, TFT_TOUCH_CS, TFT_TOUCH_INT); #endif bool vgaMode = false; static unsigned char palette8[PALETTE_SIZE]; static unsigned short palette16[PALETTE_SIZE]; static IntervalTimer myTimer; volatile boolean vbl=true; static int skip=0; static elapsedMicros tius; volatile int16_t mClick=0; static void vblCount() { if (vbl) { vbl = false; } else { vbl = true; } } void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index) { if (index #if defined(__IMXRT1052__) || defined(__IMXRT1062__) //AudioOutputMQS mqs; //AudioConnection patchCord9(mymixer, 0, mqs, 1); AudioOutputI2S i2s1; AudioConnection patchCord8(mymixer, 0, i2s1, 0); AudioConnection patchCord9(mymixer, 0, i2s1, 1); AudioControlSGTL5000 sgtl5000_1; #else AudioOutputAnalog dac1; AudioConnection patchCord1(mymixer, dac1); #endif #endif void emu_sndInit() { Serial.println("sound init"); #ifdef HAS_T4_VGA tft.begin_audio(256, mymixer.snd_Mixer); // sgtl5000_1.enable(); // sgtl5000_1.volume(0.6); #endif mymixer.start(); } void emu_sndPlaySound(int chan, int volume, int freq) { if (chan < 6) { mymixer.sound(chan, freq, volume); } /* Serial.print(chan); Serial.print(":" ); Serial.print(volume); Serial.print(":" ); Serial.println(freq); */ } void emu_sndPlayBuzz(int size, int val) { mymixer.buzz(size,val); //Serial.print((val==1)?1:0); //Serial.print(":"); //Serial.println(size); } #endif