2020-04-21 10:15:36 +10:00
|
|
|
// Code auto-generated by piet-gpu-derive
|
|
|
|
|
|
|
|
struct InstanceRef {
|
|
|
|
uint offset;
|
|
|
|
};
|
|
|
|
|
2020-04-26 03:15:22 +10:00
|
|
|
struct JumpRef {
|
|
|
|
uint offset;
|
|
|
|
};
|
|
|
|
|
2020-04-29 04:02:19 +10:00
|
|
|
struct ChunkRef {
|
|
|
|
uint offset;
|
|
|
|
};
|
|
|
|
|
2020-04-21 10:15:36 +10:00
|
|
|
struct TileGroupRef {
|
|
|
|
uint offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Instance {
|
|
|
|
uint item_ref;
|
|
|
|
vec2 offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define Instance_size 12
|
|
|
|
|
|
|
|
InstanceRef Instance_index(InstanceRef ref, uint index) {
|
|
|
|
return InstanceRef(ref.offset + index * Instance_size);
|
|
|
|
}
|
|
|
|
|
2020-04-26 03:15:22 +10:00
|
|
|
struct Jump {
|
2020-04-29 04:02:19 +10:00
|
|
|
TileGroupRef new_ref;
|
2020-04-26 03:15:22 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
#define Jump_size 4
|
|
|
|
|
|
|
|
JumpRef Jump_index(JumpRef ref, uint index) {
|
|
|
|
return JumpRef(ref.offset + index * Jump_size);
|
|
|
|
}
|
|
|
|
|
2020-04-29 04:02:19 +10:00
|
|
|
struct Chunk {
|
|
|
|
uint chunk_n;
|
|
|
|
ChunkRef next;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define Chunk_size 8
|
|
|
|
|
|
|
|
ChunkRef Chunk_index(ChunkRef ref, uint index) {
|
|
|
|
return ChunkRef(ref.offset + index * Chunk_size);
|
|
|
|
}
|
|
|
|
|
2020-04-21 10:15:36 +10:00
|
|
|
#define TileGroup_Instance 0
|
2020-04-26 03:15:22 +10:00
|
|
|
#define TileGroup_Jump 1
|
|
|
|
#define TileGroup_End 2
|
2020-04-21 10:15:36 +10:00
|
|
|
#define TileGroup_size 16
|
|
|
|
|
|
|
|
TileGroupRef TileGroup_index(TileGroupRef ref, uint index) {
|
|
|
|
return TileGroupRef(ref.offset + index * TileGroup_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
Instance Instance_read(InstanceRef ref) {
|
|
|
|
uint ix = ref.offset >> 2;
|
|
|
|
uint raw0 = tilegroup[ix + 0];
|
|
|
|
uint raw1 = tilegroup[ix + 1];
|
|
|
|
uint raw2 = tilegroup[ix + 2];
|
|
|
|
Instance s;
|
|
|
|
s.item_ref = raw0;
|
|
|
|
s.offset = vec2(uintBitsToFloat(raw1), uintBitsToFloat(raw2));
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Instance_write(InstanceRef ref, Instance s) {
|
|
|
|
uint ix = ref.offset >> 2;
|
|
|
|
tilegroup[ix + 0] = s.item_ref;
|
|
|
|
tilegroup[ix + 1] = floatBitsToUint(s.offset.x);
|
|
|
|
tilegroup[ix + 2] = floatBitsToUint(s.offset.y);
|
|
|
|
}
|
|
|
|
|
2020-04-26 03:15:22 +10:00
|
|
|
Jump Jump_read(JumpRef ref) {
|
|
|
|
uint ix = ref.offset >> 2;
|
|
|
|
uint raw0 = tilegroup[ix + 0];
|
|
|
|
Jump s;
|
2020-04-29 04:02:19 +10:00
|
|
|
s.new_ref = TileGroupRef(raw0);
|
2020-04-26 03:15:22 +10:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Jump_write(JumpRef ref, Jump s) {
|
|
|
|
uint ix = ref.offset >> 2;
|
2020-04-29 04:02:19 +10:00
|
|
|
tilegroup[ix + 0] = s.new_ref.offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
Chunk Chunk_read(ChunkRef ref) {
|
|
|
|
uint ix = ref.offset >> 2;
|
|
|
|
uint raw0 = tilegroup[ix + 0];
|
|
|
|
uint raw1 = tilegroup[ix + 1];
|
|
|
|
Chunk s;
|
|
|
|
s.chunk_n = raw0;
|
|
|
|
s.next = ChunkRef(raw1);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Chunk_write(ChunkRef ref, Chunk s) {
|
|
|
|
uint ix = ref.offset >> 2;
|
|
|
|
tilegroup[ix + 0] = s.chunk_n;
|
|
|
|
tilegroup[ix + 1] = s.next.offset;
|
2020-04-26 03:15:22 +10:00
|
|
|
}
|
|
|
|
|
2020-04-21 10:15:36 +10:00
|
|
|
uint TileGroup_tag(TileGroupRef ref) {
|
|
|
|
return tilegroup[ref.offset >> 2];
|
|
|
|
}
|
|
|
|
|
|
|
|
Instance TileGroup_Instance_read(TileGroupRef ref) {
|
|
|
|
return Instance_read(InstanceRef(ref.offset + 4));
|
|
|
|
}
|
|
|
|
|
2020-04-26 03:15:22 +10:00
|
|
|
Jump TileGroup_Jump_read(TileGroupRef ref) {
|
|
|
|
return Jump_read(JumpRef(ref.offset + 4));
|
|
|
|
}
|
|
|
|
|
2020-04-21 10:15:36 +10:00
|
|
|
void TileGroup_Instance_write(TileGroupRef ref, Instance s) {
|
|
|
|
tilegroup[ref.offset >> 2] = TileGroup_Instance;
|
|
|
|
Instance_write(InstanceRef(ref.offset + 4), s);
|
|
|
|
}
|
|
|
|
|
2020-04-26 03:15:22 +10:00
|
|
|
void TileGroup_Jump_write(TileGroupRef ref, Jump s) {
|
|
|
|
tilegroup[ref.offset >> 2] = TileGroup_Jump;
|
|
|
|
Jump_write(JumpRef(ref.offset + 4), s);
|
|
|
|
}
|
|
|
|
|
2020-04-21 10:15:36 +10:00
|
|
|
void TileGroup_End_write(TileGroupRef ref) {
|
|
|
|
tilegroup[ref.offset >> 2] = TileGroup_End;
|
|
|
|
}
|
|
|
|
|