PDA

View Full Version : Layered.dll - Re-Written in Pure Zig


BLACKFIRE69
08-12-2024, 01:51
A few days ago, I met some of my classmates, and I learned that several of them had started game development projects using Zig . After talking to them, I felt motivated and, on my way home, decided to start my own project in Zig. However, my mind was blank, and I realized I had forgotten much of the language since I hadn't worked with Zig for months.

To refresh my skills, I began converting some of old C++ projects into Zig. One of these was the Layered project, originally developed by David D. Rocco.


Why Zig?
Zig is a modern, straightforward language that's easy to learn and enforces strict type matching for safer, more predictable code.
Designed as a powerful alternative to C, it combines performance and simplicity with seamless C interoperability,
advanced memory management, and built-in tooling for streamlined development.


Here is the Layered project, completely re-written in pure Zig.

Module: Layered.dll
Rewritten by: BLACKFIRE69
Compiler: Zig v0.14.0-dev.2371+c013f45ad

I started this project just for fun and don't intend to develop it further. For those who are interested, I've included the Zig source code, so feel free to take a look.

Also, if anyone has the latest version of the Layered C++ source code, I'd appreciate it if you could share it with me.

Example:
procedure TimerProc(hwnd: HWND; uMsg: UINT; idEvent: UINT_PTR; dwTime: DWORD);
begin
lBeginRender(scene);
lRenderHint(true);

lFillRectangle(b1, 0, 0, WizardForm.Width, WizardForm.Height);
lDrawRectangle(pen, 0, 0, WizardForm.Width, WizardForm.Height);

lSetImageTransparent(70);
lDrawImage(skip, 110, 210);

lSetStringAlignment(StringAlignmentCenter);
lSetStringLineAlignment(StringAlignmentCenter);

lDrawStringRectW(WizardForm.Caption, 0, 190, WizardForm.Width, 25, font, b7);

lEndRender();
end;

procedure InitializeWizard();
begin
lStartup;

scene := lCreateScene(WizardForm.Handle, WizardForm.Width, WizardForm.Height);

skip := lCreateTextureW(ExpandConstant('{tmp}\skip.gif'))
tex := lCreateTextureW(ExpandConstant('{tmp}\tex.png'));

b1 := lCreateTextureBrush(tex);
b6 := lCreateGradientBrush(0, 0, WizardForm.Width, 0, $ff00ff00, $ff0000ff);
b7 := lCreateSolidBrush($ffffffff);
pen := lCreatePen($ffff0000, 2);

TimerID := SetTimer(0, 0, 100, wrapEventProc(@TimerProc,4));
end;

procedure DeinitializeSetup();
begin
lShutdown;
end;


.

Cesar82
08-12-2024, 04:16
Also, if anyone has the latest version of the Layered C++ source code, I'd appreciate it if you could share it with me.
I don't know if that's it, or if this is the most recent version, but I decided to attach it here anyway.

Sergey3695
09-12-2024, 06:42
A little from me :)
https://krinkels.org/resources/layered_stripped-version.403/

Sergey3695
10-12-2024, 10:58
Without debug messages. 58 -> 43 Kb.