You are bored and don't know how to spend your time #RetroCoding?
Well, now you are lucky, as I'd love some contributions to my #MSDOS #RetroComputing projects!
Feel free to help me out with code, documentation or finally a "real" website for #DOjS, #DOStodon, #jSH, #DosView, #lib16 and more 😊

![require "prj04/func"
FG_COL_IDX = 32
BG_COL_IDX = 0
X_SPACING = 8
MAX_WAVES = 4
Theta = 0.0;
Amplitude = {}
Dx = {}
YValues = 0;
function Setup()
local w = width + 16; -- Width of entire wave
for i = 0, MAX_WAVES do
Amplitude[i] = (math.random(10, 30))
local period = math.random(100, 300)
Dx[i] = ((math.pi * 2 / period) * X_SPACING);
end
YValues = {}
NumYValues = math.floor(w / X_SPACING)
for i = 1, NumYValues do
YValues[i] = 0
end
end
function Draw()
CalcWave();
vga_wait_for_retrace()
vga_filled_rect(0, 0, width, height, BG_COL_IDX)
vga_wait_for_retrace()
RenderWave();
end
function CalcWave()
Theta = Theta + 0.02
for i = 0, NumYValues do
YValues[i] = 0;
end
for j = 0, MAX_WAVES do
local x = Theta;
for i = 0, NumYValues do
-- Every other wave is cosine instead of sine
if j % 2 == 0 then
YValues[i] = YValues[i] + math.sin(x) * Amplitude[j];
else
YValues[i] = YValues[i] + math.cos(x) * Amplitude[j];
end
x = x + Dx[j];
end
end
end
function RenderWave()
for x = 0, NumYValues do
vga_circle(x * X_SPACING, height / 2 + YValues[x], X_SPACING, FG_COL_IDX)
end
end
vga_init()
vga_grayscale_palette()
Setup()
while true do
local k = getkey();
if k == KEY_ESC then
break
end
Draw()
end
vga_exit()](https://files.mastodon.social/media_attachments/files/114/376/840/897/430/522/small/a58d8ee7ec60181d.png)

