From be9a1a17f01392f2043c83b668be38d3e080ada2 Mon Sep 17 00:00:00 2001 From: cam900 Date: Thu, 15 Dec 2022 20:37:19 +0900 Subject: [PATCH] GA20: Fix build and sound output, Add debug --- src/engine/platform/ga20.cpp | 5 ++-- src/engine/platform/ga20.h | 53 ++++++++++++++++++------------------ src/gui/debug.cpp | 23 ++++++++++++++++ 3 files changed, 52 insertions(+), 29 deletions(-) diff --git a/src/engine/platform/ga20.cpp b/src/engine/platform/ga20.cpp index 20059a69..ceccac65 100644 --- a/src/engine/platform/ga20.cpp +++ b/src/engine/platform/ga20.cpp @@ -71,8 +71,9 @@ void DivPlatformGA20::acquire(short* bufL, short* bufR, size_t start, size_t len delay=w.delay; } } - ga20.sound_stream_update(ga20Buf, 1); - bufL[h]=(ga20Buf[0][h]+ga20Buf[1][h]+ga20Buf[2][h]+ga20Buf[3][h]); + short *buffer[4] = {&ga20Buf[0][h],&ga20Buf[1][h],&ga20Buf[2][h],&ga20Buf[3][h]}; + ga20.sound_stream_update(buffer, 1); + bufL[h]=(signed int)(ga20Buf[0][h]+ga20Buf[1][h]+ga20Buf[2][h]+ga20Buf[3][h])>>2; for (int i=0; i<4; i++) { oscBuf[i]->data[oscBuf[i]->needle++]=ga20Buf[i][h]; } diff --git a/src/engine/platform/ga20.h b/src/engine/platform/ga20.h index 462a8e87..88b47547 100644 --- a/src/engine/platform/ga20.h +++ b/src/engine/platform/ga20.h @@ -74,33 +74,32 @@ class DivPlatformGA20: public DivDispatch, public iremga20_intf { void chWrite(unsigned char ch, unsigned int addr, unsigned char val); public: virtual u8 read_byte(u32 address) override; - void acquire(short* bufL, short* bufR, size_t start, size_t len); - int dispatch(DivCommand c); - void* getChanState(int chan); - DivMacroInt* getChanMacroInt(int ch); - DivDispatchOscBuffer* getOscBuffer(int chan); - unsigned char* getRegisterPool(); - int getRegisterPoolSize(); - void reset(); - void forceIns(); - void tick(bool sysTick=true); - void muteChannel(int ch, bool mute); - bool isStereo(); - void setChipModel(int type); - void notifyInsChange(int ins); - void notifyWaveChange(int wave); - void notifyInsDeletion(void* ins); - void setFlags(const DivConfig& flags); - void poke(unsigned int addr, unsigned short val); - void poke(std::vector& wlist); - const char** getRegisterSheet(); - const void* getSampleMem(int index = 0); - size_t getSampleMemCapacity(int index = 0); - size_t getSampleMemUsage(int index = 0); - bool isSampleLoaded(int index, int sample); - void renderSamples(int chipID); - int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); - void quit(); + virtual void acquire(short* bufL, short* bufR, size_t start, size_t len) override; + virtual int dispatch(DivCommand c) override; + virtual void* getChanState(int chan) override; + virtual DivMacroInt* getChanMacroInt(int ch) override; + 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; + virtual bool isStereo() override; + 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& 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; + virtual void renderSamples(int chipID) override; + virtual int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags) override; + virtual void quit() override; DivPlatformGA20(): DivDispatch(), iremga20_intf(), diff --git a/src/gui/debug.cpp b/src/gui/debug.cpp index c32cc2f6..c008770f 100644 --- a/src/gui/debug.cpp +++ b/src/gui/debug.cpp @@ -49,6 +49,7 @@ #include "../engine/platform/lynx.h" #include "../engine/platform/pcmdac.h" #include "../engine/platform/k007232.h" +#include "../engine/platform/ga20.h" #include "../engine/platform/dummy.h" #define COMMON_CHIP_DEBUG \ @@ -502,6 +503,14 @@ void putDispatchChip(void* data, int type) { ImGui::TextColored(ch->stereo?colorOn:colorOff,">> Stereo"); break; } + case DIV_SYSTEM_GA20: { + DivPlatformGA20* ch=(DivPlatformGA20*)data; + ImGui::Text("> GA20"); + COMMON_CHIP_DEBUG; + ImGui::Text("- delay: %.2x",ch->delay); + COMMON_CHIP_DEBUG_BOOL; + break; + } default: ImGui::Text("Unimplemented chip! Help!"); break; @@ -914,6 +923,20 @@ void putDispatchChan(void* data, int chanNum, int type) { ImGui::TextColored(ch->setPos?colorOn:colorOff,">> SetPos"); break; } + case DIV_SYSTEM_GA20: { + DivPlatformGA20::Channel* ch=(DivPlatformGA20::Channel*)data; + ImGui::Text("> GA20"); + COMMON_CHAN_DEBUG; + ImGui::Text("- prevFreq: %d",ch->prevFreq); + ImGui::Text("* Sample: %d",ch->sample); + ImGui::Text(" - pos: %d",ch->audPos); + ImGui::Text("- resVol: %.2x",ch->resVol); + ImGui::Text("- macroVolMul: %.2x",ch->macroVolMul); + COMMON_CHAN_DEBUG_BOOL; + ImGui::TextColored(ch->volumeChanged?colorOn:colorOff,">> VolumeChanged"); + ImGui::TextColored(ch->setPos?colorOn:colorOff,">> SetPos"); + break; + } default: ImGui::Text("Unimplemented chip! Help!"); break;