diff options
author | lonkaars <loek@pipeframe.xyz> | 2024-05-02 16:58:53 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2024-05-02 16:58:53 +0200 |
commit | dcc3a747360382857b1fbae05a06061f44e64033 (patch) | |
tree | 809863468178c75cde57ffa2f0e391ffe6a77a36 /src | |
parent | d529048e9ba286af275d9cefc0ebae9800c34f76 (diff) |
more experimentation
Diffstat (limited to 'src')
-rw-r--r-- | src/frontend/qt_sdl/LocalMP.cpp | 52 | ||||
-rw-r--r-- | src/frontend/qt_sdl/Window.cpp | 14 | ||||
-rw-r--r-- | src/vsr.h | 4 |
3 files changed, 42 insertions, 28 deletions
diff --git a/src/frontend/qt_sdl/LocalMP.cpp b/src/frontend/qt_sdl/LocalMP.cpp index 7fe4f64..32f08c8 100644 --- a/src/frontend/qt_sdl/LocalMP.cpp +++ b/src/frontend/qt_sdl/LocalMP.cpp @@ -49,8 +49,10 @@ pcap_dumper_t* dumper; #endif #ifdef VSR_MESSAGE_FIDDLING +#include "Window.h" #include <time.h> -unsigned long test_start = time(NULL); +extern MainWindow* mainWindow; +bool fiddle = false; #endif using namespace melonDS; @@ -457,19 +459,6 @@ int SendPacketGeneric(u32 type, u8* packet, int len, u64 timestamp) u16 mask = header->ConnectedBitmask; -#ifdef VSR_MESSAGE_FIDDLING - // fiddle the packets after 20 seconds - unsigned long now = time(NULL); - static bool first = true; - bool fiddle = false; - if (now - test_start > 20 && InstanceID == 0) { - if (first == true) - printf("[INSTANCE %d] started fiddling!\n", InstanceID); - first = false; - fiddle = true; - } -#endif - // TODO: check if the FIFO is full! MPPacketHeader pktheader; @@ -479,8 +468,8 @@ int SendPacketGeneric(u32 type, u8* packet, int len, u64 timestamp) pktheader.Length = len; pktheader.Timestamp = timestamp; -#ifdef VSR_DUMP_MESSAGES - std::vector<uint8_t> buf; +#ifdef VSR_MESSAGE_FIDDLING + static int package_idx = 0; #endif type &= 0xFFFF; @@ -489,21 +478,32 @@ int SendPacketGeneric(u32 type, u8* packet, int len, u64 timestamp) // seems to consistently trigger PACKET FIFO OVERFLOW errors FIFOWrite(nfifo, &pktheader, sizeof(pktheader)); #ifdef VSR_DUMP_MESSAGES + std::vector<uint8_t> buf; buf.insert(buf.end(), (uint8_t*) &pktheader, (uint8_t*) &pktheader + sizeof(pktheader)); #endif if (len) { #ifdef VSR_MESSAGE_FIDDLING - if (fiddle && len == 0xde) { - // NOTE: packet indexes are after NIFI header! - packet[0x80] = 0x11; - packet[0x81] = 0x11; - packet[0x82] = 0x11; - packet[0x83] = 0x11; - packet[0x84] = 0x11; - packet[0x85] = 0x11; - packet[0x86] = 0x11; - packet[0x87] = 0x11; + // if message packet (has size 222 w/o ni-fi header) + if (fiddle && len == 222) { + // if fresh message (do not count resends) + if (packet[0x02] == 0x02) { + // corrupt all pixels in every nth package + package_idx = (package_idx + 1) % 10; + } + + if (true || package_idx == 0) { + // mainWindow->osdAddMessage(0x00ff00, "oops!"); + // NOTE: packet indexes are after NIFI header! + for (size_t i = 0; i < 0x80; i++) { + packet[0x3e + i] = 0x11; + } + // packet[0x3e + 0x00] = 0x13; + // packet[0x3e + 0x01] = 0x13; + + // packet[0x3e + 0x02] = 0x33; + // packet[0x3e + 0x04] = 0x33; + } } #endif diff --git a/src/frontend/qt_sdl/Window.cpp b/src/frontend/qt_sdl/Window.cpp index d1f16a1..16079be 100644 --- a/src/frontend/qt_sdl/Window.cpp +++ b/src/frontend/qt_sdl/Window.cpp @@ -83,6 +83,10 @@ #include "../../vsr.h" +#ifdef VSR_MESSAGE_FIDDLING +extern bool fiddle; +#endif + #ifdef VSR_INJECTION #include <fstream> @@ -102,6 +106,7 @@ void MainWindow::injectPacket(int type) { std::vector<uint8_t> buf(start, end); // TODO: is this melonDS::NDS::SysTimestamp??? + // emuThread->NDS->SysTimestamp melonDS::u64 timestamp = 0; switch(type) { @@ -605,6 +610,15 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) actAudioSync->setCheckable(true); connect(actAudioSync, &QAction::triggered, this, &MainWindow::onChangeAudioSync); } +#ifdef VSR_MESSAGE_FIDDLING + { + QMenu* menu = menubar->addMenu("Fiddle"); + + QAction* actFiddleToggle = menu->addAction("Enable fiddling"); + actFiddleToggle->setCheckable(true); + connect(actFiddleToggle, &QAction::triggered, this, [](){ fiddle = !fiddle; }); + } +#endif #ifdef VSR_INJECTION { QMenu* menu = menubar->addMenu("Inject"); @@ -3,11 +3,11 @@ /** This is a central file for contolling VSR-specific experiments */ // corrupt instance=0's messages after 20 seconds -// #define VSR_MESSAGE_FIDDLING +#define VSR_MESSAGE_FIDDLING // dump all sent Ni-Fi packets // #define VSR_DUMP_MESSAGES // add "Inject" menu bar item -#define VSR_INJECTION +// #define VSR_INJECTION |