From 0ebb3a3b12ffb18b1f8e4157de951b84c2eb7b3f Mon Sep 17 00:00:00 2001 From: Ewoud Date: Fri, 9 Aug 2024 13:59:28 +0200 Subject: [PATCH] UserModLive: move main/setup/loop code out of sc file and generate --- misc/animwleSL.sc | 21 +++++++------- misc/ballsSL.sc | 45 ++++++++++-------------------- misc/beatmaniaSL.sc | 9 ------ misc/green_ripple_reflectionsSL.sc | 9 ------ src/User/UserModLive.h | 2 ++ 5 files changed, 27 insertions(+), 59 deletions(-) diff --git a/misc/animwleSL.sc b/misc/animwleSL.sc index 6c0cb5e2..25087f20 100644 --- a/misc/animwleSL.sc +++ b/misc/animwleSL.sc @@ -96,23 +96,22 @@ void render2D(int x1, int y1) } } -void main() +void setup() { -clear(); -resetStat(); + clear(); cR = -0.94299; cI = 0.3162; int h = 1 ; - while (h > 0) +} + +void loop() +{ + beforeRender(); + for (int i = 0; i < width; i++) { - beforeRender(); - for (int i = 0; i < width; i++) + for (int j = 0; j < height; j++) { - for (int j = 0; j < height; j++) - { - render2D(i, j); - } + render2D(i, j); } - show(); } } \ No newline at end of file diff --git a/misc/ballsSL.sc b/misc/ballsSL.sc index 5a1e7e33..25916906 100644 --- a/misc/ballsSL.sc +++ b/misc/ballsSL.sc @@ -86,22 +86,9 @@ void updateBall(int index) drawBall(_xc, _yc, _r, _color); } -void init() -{ - for(int i=0;imax_nb_balls) { nb_balls=max_nb_balls; @@ -113,11 +100,20 @@ nb_balls=slider1; } int h; + void setup() { - resetStat(); - //initleds(pins,NUM_STRIPS,NUM_LEDS_PER_STRIP); - init(); + for(int i=0;i 0) - { - loop(); - } } \ No newline at end of file diff --git a/misc/beatmaniaSL.sc b/misc/beatmaniaSL.sc index 806c5d68..c5600b6b 100644 --- a/misc/beatmaniaSL.sc +++ b/misc/beatmaniaSL.sc @@ -33,13 +33,4 @@ void loop() { sCFP(y*panel_width+locn1,colr2,bri1); sCFP(y*panel_width+locn2%(length-1),colr1,bri2); } -} - -void main() { - resetStat(); - setup(); - while (2>1) { - loop(); - show(); - } } \ No newline at end of file diff --git a/misc/green_ripple_reflectionsSL.sc b/misc/green_ripple_reflectionsSL.sc index 4d3a499a..ad2a6e75 100644 --- a/misc/green_ripple_reflectionsSL.sc +++ b/misc/green_ripple_reflectionsSL.sc @@ -42,13 +42,4 @@ void loop() { sPC(y*panel_width+index, gg); } } -} - -void main() { - resetStat(); - setup(); - while (2>1) { - loop(); - show(); - } } \ No newline at end of file diff --git a/src/User/UserModLive.h b/src/User/UserModLive.h index 3ffed7e6..6347f4ab 100644 --- a/src/User/UserModLive.h +++ b/src/User/UserModLive.h @@ -298,6 +298,8 @@ class UserModLive:public SysModule { scScript += string(f.readString().c_str()); // add sc file + scScript += "void main(){resetStat();setup();while(2>1){loop();show();}}"; + ppf("Before parsing of %s\n", fileName); ppf("%s:%d f:%d / t:%d (l:%d) B [%d %d]\n", __FUNCTION__, __LINE__, ESP.getFreeHeap(), ESP.getHeapSize(), ESP.getMaxAllocHeap(), esp_get_free_heap_size(), esp_get_free_internal_heap_size());