From f215991585a522b8565b865f034c12fefe9604f0 Mon Sep 17 00:00:00 2001 From: Mike Subelsky <12020+subelsky@users.noreply.github.com> Date: Fri, 10 Oct 2025 17:46:02 -0400 Subject: [PATCH 1/2] rename location of folk-baltimore sounds --- .../folk-baltimore/{sounds => audio}/README.md | 0 .../{sounds => audio}/folk_boot_guitar.wav | Bin 2 files changed, 0 insertions(+), 0 deletions(-) rename user-programs/folk-baltimore/{sounds => audio}/README.md (100%) rename user-programs/folk-baltimore/{sounds => audio}/folk_boot_guitar.wav (100%) diff --git a/user-programs/folk-baltimore/sounds/README.md b/user-programs/folk-baltimore/audio/README.md similarity index 100% rename from user-programs/folk-baltimore/sounds/README.md rename to user-programs/folk-baltimore/audio/README.md diff --git a/user-programs/folk-baltimore/sounds/folk_boot_guitar.wav b/user-programs/folk-baltimore/audio/folk_boot_guitar.wav similarity index 100% rename from user-programs/folk-baltimore/sounds/folk_boot_guitar.wav rename to user-programs/folk-baltimore/audio/folk_boot_guitar.wav From 31eade83b6e898440b51fec4c8eb860ece000d01 Mon Sep 17 00:00:00 2001 From: Mike Subelsky <12020+subelsky@users.noreply.github.com> Date: Fri, 17 Oct 2025 16:18:27 -0400 Subject: [PATCH 2/2] Adds display saver when no programs are running Includes a user-customized display saver featuring a bouncing ball animation. --- .../folk-baltimore/display-saver.folk | 124 ++++++++++++++++++ virtual-programs/display-saver.folk | 25 ++++ 2 files changed, 149 insertions(+) create mode 100644 user-programs/folk-baltimore/display-saver.folk create mode 100644 virtual-programs/display-saver.folk diff --git a/user-programs/folk-baltimore/display-saver.folk b/user-programs/folk-baltimore/display-saver.folk new file mode 100644 index 00000000..491af7b2 --- /dev/null +++ b/user-programs/folk-baltimore/display-saver.folk @@ -0,0 +1,124 @@ +set cc [C] + +$cc cflags -O2 -Wall +$cc include +$cc include + +$cc code { + typedef struct BallState { + double x, y, vx, vy, lastT; + int initialized; + } BallState; + + static BallState ball = {0, 0, 250.0, 200.0, 0, 0}; + + static double random_bounce_factor() { + return 0.95 + ((double)rand() / RAND_MAX) * 0.1; + } + + static char* updateBallPhysics(double t, double displayWidth, + double displayHeight, double radius) { + static char buffer[100]; + double dt = t - ball.lastT; + + // Update position + double newX = ball.x + ball.vx * dt; + double newY = ball.y + ball.vy * dt; + double newVx = ball.vx; + double newVy = ball.vy; + + // Collision detection and response + if (newX < radius) { + newX = radius; + newVx = fabs(ball.vx) * random_bounce_factor(); + } else if (newX > displayWidth - radius) { + newX = displayWidth - radius; + newVx = -fabs(ball.vx) * random_bounce_factor(); + } + + if (newY < radius) { + newY = radius; + newVy = fabs(ball.vy) * random_bounce_factor(); + } else if (newY > displayHeight - radius) { + newY = displayHeight - radius; + newVy = -fabs(ball.vy) * random_bounce_factor(); + } + + // Update ball state + ball.x = newX; + ball.y = newY; + ball.vx = newVx; + ball.vy = newVy; + ball.lastT = t; + + // Return position as string + snprintf(buffer, 100, "%.2f %.2f", ball.x, ball.y); + return buffer; + } +} + +$cc proc initBall {double displayWidth double displayHeight double t} void { + ball.x = displayWidth * 0.5; + ball.y = displayHeight * 0.5; + ball.lastT = t; + ball.initialized = 1; +} + +$cc proc updateBall {double t double displayWidth double displayHeight double radius} char* { + return updateBallPhysics(t, displayWidth, displayHeight, radius); +} + +$cc proc isBallInitialized {} int { + return ball.initialized; +} + +set ballLib [$cc compile] +set radius 100 + +When tag /nobody/ has a program & \ + display /disp/ has width /displayWidth/ height /displayHeight/ & \ + the clock time is /t/ { + + if {![$ballLib isBallInitialized]} { + $ballLib initBall $displayWidth $displayHeight $t + return + } + + # Update physics in C and get position + set pos [$ballLib updateBall $t $displayWidth $displayHeight $radius] + lassign $pos x y + + Wish to draw a circle onto $disp with \ + center [list $x $y] \ + radius $radius \ + thickness 1 \ + color green \ + filled true +} + +When tag /nobody/ has a program & display /disp/ has width /displayWidth/ height /displayHeight/ { + puts "Starting display-saver" + + set cx [/ $displayWidth 2.0] + set cy [* $displayHeight 0.3] + set host [info hostname] + set msg "Welcome to Folk\n$host" + + Wish to draw text onto $disp with \ + x $cx \ + y $cy \ + text $msg \ + color green \ + scale 80 + + set borderPoints [list \ + [list 0 0] \ + [list $displayWidth 0] \ + [list $displayWidth $displayHeight] \ + [list 0 $displayHeight] \ + [list 0 0]] + + Wish to draw a line onto $disp with points $borderPoints width 6 color white +} + +Claim $this has a display saver \ No newline at end of file diff --git a/virtual-programs/display-saver.folk b/virtual-programs/display-saver.folk new file mode 100644 index 00000000..31e0e57b --- /dev/null +++ b/virtual-programs/display-saver.folk @@ -0,0 +1,25 @@ +When tag /nobody/ has a program & /nobody/ has a display saver & \ + /disp/ has width /displayWidth/ height /displayHeight/ { + puts "Starting display-saver" + + set cx [/ $displayWidth 2.0] + set cy [* $displayHeight 0.3] + set host [info hostname] + set msg "Welcome to Folk\n$host" + + Wish to draw text onto $disp with \ + x $cx \ + y $cy \ + text $msg \ + color green \ + scale 80 + + set borderPoints [list \ + [list 0 0] \ + [list $displayWidth 0] \ + [list $displayWidth $displayHeight] \ + [list 0 $displayHeight] \ + [list 0 0]] + + Wish to draw a line onto $disp with points $borderPoints width 6 color white +}