Skip to content

Instantly share code, notes, and snippets.

@derrickturk
Created March 6, 2023 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derrickturk/7bf5652d7eb8e1f588d0eb7b34651b87 to your computer and use it in GitHub Desktop.
Save derrickturk/7bf5652d7eb8e1f588d0eb7b34651b87 to your computer and use it in GitHub Desktop.
An experiment with GNU Poke
load petra_grid;
%%
%entry
%name header
%type Header
%offset 0x0#B
%entry
%name latlongref
%type LatLongRef
%offset 0xb9#B
%entry
%name xyspec
%type XYSpec
%offset 0x3fd#B
%entry
%name zspec
%type ZSpec
%offset 0x429#B
%entry
%name triangularspec
%type TriangularSpec
%offset 0x431#B
%entry
%name grid
%type Grid
%offset 0x119c#B
/* Petra grid files */
/* no, this sucks and doesn't work with endianness annotations */
/* load ieee754; */
var FEET = 0U;
var METERS = 1U;
type Header = struct {
little uint<32> version : version == 2;
char[81] name;
little uint size;
little ulong xmin;
little ulong xmax;
little ulong ymin;
little ulong ymax;
little ulong xstep;
little ulong ystep;
little ulong zmin;
little ulong zmax;
computed string name_str;
method get_name_str = string:
{
return catos(name);
}
method set_name_str = (string name_str) void:
{
stoca(name_str, name);
}
method _print = void:
{
print "#<\n";
printf " version: %u32d\n", version;
printf " name: %s\n", get_name_str;
printf " size: %u32d\n", size;
printf " xmin: %f64d\n", xmin;
printf " xmax: %f64d\n", xmax;
printf " ymin: %f64d\n", ymin;
printf " ymax: %f64d\n", ymax;
printf " xstep: %f64d\n", xstep;
printf " ystep: %f64d\n", ystep;
printf " zmin: %f64d\n", zmin;
printf " zmax: %f64d\n", zmax;
print ">";
}
};
type LatLongRef = struct {
little ulong cm;
little ulong rlat;
method _print = void:
{
print "#<\n";
printf " cm: %f64d\n", cm;
printf " rlat: %f64d\n", rlat;
print ">";
}
};
type XYSpec = struct {
little uint rows;
little uint cols;
little uint meth;
little uint proj_code;
little uint xyunits : xyunits == FEET || xyunits == METERS;
};
type ZSpec = struct {
little uint zunits : zunits == FEET || zunits == METERS;
};
type TriangularSpec = struct {
little uint n_triangles;
};
type Grid = struct {
little ulong[] values;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment