diff --git a/VortexEngine/src/Menus/MenuList/EditorConnection.cpp b/VortexEngine/src/Menus/MenuList/EditorConnection.cpp index c22c52eeaa..6632b7ffa3 100644 --- a/VortexEngine/src/Menus/MenuList/EditorConnection.cpp +++ b/VortexEngine/src/Menus/MenuList/EditorConnection.cpp @@ -197,7 +197,7 @@ Menu::MenuAction EditorConnection::run() case STATE_PULL_EACH_MODE_COUNT: if (receiveMessage(EDITOR_VERB_PULL_EACH_MODE_ACK)) { if (Modes::numModes() == 0) { - m_state = STATE_IDLE; + m_state = STATE_PULL_EACH_MODE_DONE; } else { m_previousModeIndex = Modes::curModeIndex(); m_state = STATE_PULL_EACH_MODE_SEND; @@ -245,6 +245,10 @@ Menu::MenuAction EditorConnection::run() if (receiveModeCount()) { // clear modes and start receiving Modes::clearModes(); + // write out an ack + m_receiveBuffer.clear(); + SerialComs::write(EDITOR_VERB_PUSH_EACH_MODE_ACK); + // ready to receive a mode m_state = STATE_PUSH_EACH_MODE_RECEIVE; } break; @@ -438,6 +442,42 @@ bool EditorConnection::receiveModeCount() return true; } +bool EditorConnection::receiveMode() +{ + // need at least the buffer size first + uint32_t size = 0; + if (m_receiveBuffer.size() < sizeof(size)) { + // wait, not enough data available yet + return false; + } + // grab the size out of the start + m_receiveBuffer.resetUnserializer(); + size = m_receiveBuffer.peek32(); + if (m_receiveBuffer.size() < (size + sizeof(size))) { + // don't unserialize yet, not ready + return false; + } + // okay unserialize now, first unserialize the size + if (!m_receiveBuffer.unserialize32(&size)) { + return false; + } + // create a new ByteStream that will hold the full buffer of data + ByteStream buf(m_receiveBuffer.rawSize()); + // then copy everything from the receive buffer into the rawdata + // which is going to overwrite the crc/size/flags of the ByteStream + memcpy(buf.rawData(), m_receiveBuffer.data() + sizeof(size), + m_receiveBuffer.size() - sizeof(size)); + // clear the receive buffer + m_receiveBuffer.clear(); + // unserialize the mode into the demo mode + if (!Modes::addModeFromBuffer(buf)) { + // error + } + return true; +} + + + bool EditorConnection::receiveDemoMode() { // need at least the buffer size first diff --git a/VortexEngine/src/Menus/MenuList/EditorConnection.h b/VortexEngine/src/Menus/MenuList/EditorConnection.h index 2a27d0601e..2f12509d0b 100644 --- a/VortexEngine/src/Menus/MenuList/EditorConnection.h +++ b/VortexEngine/src/Menus/MenuList/EditorConnection.h @@ -84,7 +84,7 @@ class EditorConnection : public Menu STATE_PUSH_EACH_MODE, STATE_PUSH_EACH_MODE_COUNT, STATE_PUSH_EACH_MODE_RECEIVE, - STATE_PULL_EACH_MODE_WAIT, + STATE_PUSH_EACH_MODE_WAIT, STATE_PUSH_EACH_MODE_DONE, }; diff --git a/VortexEngine/src/VortexConfig.h b/VortexEngine/src/VortexConfig.h index a10506b34e..e17f2f7b98 100644 --- a/VortexEngine/src/VortexConfig.h +++ b/VortexEngine/src/VortexConfig.h @@ -481,19 +481,54 @@ // the response from the device when it's done transmitting the mode #define EDITOR_VERB_TRANSMIT_VL_ACK "n" +// when the pc wants the chromadeck to listen for a mode from the duos +#define EDITOR_VERB_LISTEN_VL "o" +// and the response for when it's done fetching a duo mode +#define EDITOR_VERB_LISTEN_VL_ACK "p" + +// pull the duo saveheader via the chromalink +#define EDITOR_VERB_PULL_CHROMA_HDR "q" +// and the response for when it's done fetching the modes +#define EDITOR_VERB_PULL_CHROMA_HDR_ACK "r" + +// push the duo save header via the chromalink +#define EDITOR_VERB_PUSH_CHROMA_HDR "s" +// and the response for when it's done pushing the modes +#define EDITOR_VERB_PUSH_CHROMA_HDR_ACK "t" + +// pull a duo mode via the chromalink +#define EDITOR_VERB_PULL_CHROMA_MODE "u" +// and the response for when it's done fetching the modes +#define EDITOR_VERB_PULL_CHROMA_MODE_ACK "v" + +// push a duo mode via the chromalink +#define EDITOR_VERB_PUSH_CHROMA_MODE "w" +// and the response for when it's done pushing the modes +#define EDITOR_VERB_PUSH_CHROMA_MODE_ACK "x" + +// pull a single mode +#define EDITOR_VERB_PULL_SINGLE_MODE "y" +// and the response for when it's done +#define EDITOR_VERB_PULL_SINGLE_MODE_ACK "z" + +// push a single mode +#define EDITOR_VERB_PUSH_SINGLE_MODE "A" +// and the response for when it's done +#define EDITOR_VERB_PUSH_SINGLE_MODE_ACK "B" + // the command from the editor to send modes over -#define EDITOR_VERB_PULL_EACH_MODE "o" +#define EDITOR_VERB_PULL_EACH_MODE "C" // the response from the device when it acknowledges a command -#define EDITOR_VERB_PULL_EACH_MODE_ACK "p" +#define EDITOR_VERB_PULL_EACH_MODE_ACK "D" // the response from the editor once modes are received -#define EDITOR_VERB_PULL_EACH_MODE_DONE "q" +#define EDITOR_VERB_PULL_EACH_MODE_DONE "E" // the command from the editor to send modes over -#define EDITOR_VERB_PUSH_EACH_MODE "r" +#define EDITOR_VERB_PUSH_EACH_MODE "F" // the response from the device when it received the command -#define EDITOR_VERB_PUSH_EACH_MODE_ACK "s" +#define EDITOR_VERB_PUSH_EACH_MODE_ACK "G" // the response from the device when it received the command -#define EDITOR_VERB_PUSH_EACH_MODE_DONE "t" +#define EDITOR_VERB_PUSH_EACH_MODE_DONE "H" // =================================================================== // Manually Configured Sizes