Getting Started
Supported Target
- Windows x64
Required Artifacts
grimoire_pcg.dllruntime binarygrimoire_pcg.libimport library for linker input- C headers under
grimoire-pcg/ - NASM import declarations in
grimoire_pcg.inc(if consuming from asm)
Export Package Layout
Expected package layout:
grimoire_pcg/bin/grimoire_pcg.dllgrimoire_pcg/bin/grimoire_pcg.libgrimoire_pcg/inc/grimoire_pcg.incgrimoire_pcg/include/grimoire-pcg/common.hgrimoire_pcg/include/grimoire-pcg/random.hgrimoire_pcg/include/grimoire-pcg/noise.h
C/C++ Integration
- Add
grimoire_pcg/includeto include paths. - Link
grimoire_pcg/bin/grimoire_pcg.lib. - Ensure
grimoire_pcg.dllis in your runtime search path. - Include headers with
<grimoire-pcg/...>.
Minimal C Example
#include <stdint.h>
#include <grimoire-pcg/random.h>
int main(void)
{
GrimoireRandom rng = GrimoireRandom_CreateSeed(1337);
if (!rng) {
return 1;
}
int32_t roll = GrimoireRandom_NextRange(rng, 1, 7);
(void)roll;
GrimoireRandom_Destroy(rng);
return 0;
}
Minimal Noise Example
#include <grimoire-pcg/noise.h>
float sample(float x, float y)
{
return Grimoire_Perlin2D(x, y, 0.0f, 2026);
}
NASM Integration
- Add
grimoire_pcg/incto your NASM include paths. - Link against
grimoire_pcg/bin/grimoire_pcg.lib. - Keep
grimoire_pcg.dllavailable at runtime. - Include
grimoire_pcg.incin modules that call Grimoire exports.
Minimal NASM Example
bits 64
%include "grimoire_pcg.inc"
section .data
seed dd 1337
section .text
global example_entry
example_entry:
sub rsp, 40
mov ecx, [rel seed]
call GrimoireRandom_CreateSeed
test rax, rax
jz .done
mov rbx, rax
mov rcx, rax
mov edx, 1
mov r8d, 6
call GrimoireRandom_NextRange
mov rcx, rbx
call GrimoireRandom_Destroy
.done:
add rsp, 40
ret
Build-Side Macros
- Define
_GRIMOIRE_BUILDonly when building the DLL itself. - Do not define
_GRIMOIRE_BUILDin consumer projects. - Define
GRIMOIRE_STATIConly when building/consuming as static linkage.
Determinism Checklist
- Use explicit seeds with
GrimoireRandom_CreateSeed. - Keep call order stable between runs.
- Use the same function family (ValueSmooth vs Perlin, etc.).
- Persist and restore RNG state when exact continuation is required.
Troubleshooting
Linker cannot resolve symbols
- Verify you linked the import library for the same build.
- Confirm target architecture is x64.
- For NASM projects, confirm the
.objoutput is linked withgrimoire_pcg.lib.
Runtime DLL not found
- Put the DLL next to the executable or on an expected DLL search path.
NASM include cannot be resolved
- Verify the assembler include path contains
grimoire_pcg/inc. - Confirm the source uses
%include "grimoire_pcg.inc".
Non-reproducible outputs
- Ensure fixed seed usage.
- Ensure identical function call order.
- Avoid replacing deterministic create calls with non-deterministic create calls.
Security Reminder
GrimoireRandom is not cryptographically secure.
Do not use it for cryptographic keys, secure tokens, or security boundaries.