From 4dec5efa2a4e511eff63895e200c83844bccdba7 Mon Sep 17 00:00:00 2001 From: Rodrigo Alfonso Date: Sat, 6 Jan 2024 05:05:41 -0300 Subject: [PATCH] Adding lag option to wireless demo --- examples/LinkWireless_demo/src/main.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/examples/LinkWireless_demo/src/main.cpp b/examples/LinkWireless_demo/src/main.cpp index b4772a7..ac626b2 100644 --- a/examples/LinkWireless_demo/src/main.cpp +++ b/examples/LinkWireless_demo/src/main.cpp @@ -27,6 +27,7 @@ void connect(); void messageLoop(); void log(std::string text); void waitFor(u16 key); +void wait(u32 verticalLines); void hang(); LinkWireless::Error lastError; @@ -432,6 +433,10 @@ void messageLoop() { #endif } + // Test lag + if (keys & KEY_DOWN) + wait(9000); + // Print VBlankIntrWait(); log(output); @@ -451,6 +456,18 @@ void waitFor(u16 key) { } while (!(keys & key)); } +void wait(u32 verticalLines) { + u32 count = 0; + u32 vCount = REG_VCOUNT; + + while (count < verticalLines) { + if (REG_VCOUNT != vCount) { + count += max((int)REG_VCOUNT - (int)vCount, 0); + vCount = REG_VCOUNT; + } + }; +} + void hang() { waitFor(KEY_DOWN); } \ No newline at end of file