Hi all,
D newbie here. I'm building a D WebAssembly binding for TIC-80, a fantasy gaming console.
TIC-80 has a fixed size RAM that is directly addressable by a running program using peek() and poke() functions. Basically, 16,384 bytes starting at address zero form the video RAM, next 8192 bytes are for storing tiles, next 8192 bytes for sprites, etc.
Here's how Zig's TIC-80 binding describes the memory layout:
pub const FRAMEBUFFER: *allowzero volatile [16320]u8 = @intToPtr(*allowzero volatile [16320]u8, 0);
pub const TILES : *[8192]u8 = @intToPtr(*[8192]u8, 0x4000);
pub const SPRITES : *[8192]u8 = @intToPtr(*[8192]u8, 0x6000);
I believe the above is declaring that FRAMEBUFFER is a pointer to 16320 (sic) bytes starting at address 0, TILES is a pointer to 8192 bytes starting at address 0x4000, and SPRITES a pointer to 8192 bytes starting at address 0x6000.
Currently for D I have the following, copying the D binding for Wasm4, another fantasy console:
const FRAMEBUFFER = cast(uint*)0;
const TILES = cast(uint*)0x4000;
const SPRITES = cast(uint*)0x6000;
How to express in D, similarly to Zig, that FRAMEBUFFER refers to a byte[16384] array starting from address zero, and so on?
Pierce