#lib16

SuperIludec_hl
2025-10-23

You are bored and don't know how to spend your time ?

Well, now you are lucky, as I'd love some contributions to my projects!

Feel free to help me out with code, documentation or finally a "real" website for , , , , and more 😊

github.com/SuperIlu

SuperIludec_hl
2025-04-21

After some delay I did an update of (a tiny helper library for 16-bit DOS programs).

github.com/SuperIlu/lib16

This time I added to the mix (example prj04). You can now write graphical scripts using Lua on . I also included the regular lua.exe and luac.exe binaries. This is compiled for i386/387 upwards...

require "prj04/func"

T = 0
FG_COL_IDX = 63
BG_COL_IDX = 0

function Draw()
	vga_filled_rect(0, 0, width, height, BG_COL_IDX)
	vga_wait_for_retrace()
	for i = 0, 10 do
		V(width / 2, height / 2, i - T, 5)
	end
end

function V(x, y, a, l)
	x = x + l * math.sin(a) * 15
	y = y - l * math.cos(a) * 15

	-- vga_filled_rect(ix, iy, ix + 4, iy + 4, FG_COL_IDX)
	vga_set_pixel(x, y, FG_COL_IDX)

	if l > 1 then
		l = l * .7
		V(x, y, a + 1 + math.cos(T), l)
		V(x, y, a - 1 - math.sin(T), l)
	end
end

vga_init()
vga_grayscale_palette()
while true do
	local k = getkey();
	if k == KEY_ESC then
		break
	end
	Draw()
	T = T + 0.01
end
vga_exit()
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()
Picture of a notebook screen. The screen is black and filled with white dots in a circular pattern.picture of an EeePC netbook with a black screen. There is a wave pattern drawn from unfilled white circles on the screen.

Client Info

Server: https://mastodon.social
Version: 2025.07
Repository: https://github.com/cyevgeniy/lmst