Posted by: Wisp
« on: August 30, 2019, 02:13:32 PM »No, it does not look like a good fit for CREATE as it currently works.
DEFINE_ACTION_FUNCTION build_wed
INT_VAR width=0
height=0
STR_VAR tis=""
wed=""
BEGIN
COPY ".../stratagems-inline/blank" "override/%wed%.wed"
// make sure it starts empty
DELETE_BYTES 0x0 BUFFER_LENGTH
INSERT_BYTES 0x0 0x20 // header
WRITE_ASCII 0x0 "WED V1.3"
WRITE_LONG 0x8 5 // # overlays
WRITE_LONG 0x10 0x20 // overlay offset
// insert first overlay
INSERT_BYTES 0x20 0x18
WRITE_SHORT 0x20 width
WRITE_SHORT 0x22 height
WRITE_ASCII 0x24 "%tis%" (8)
INSERT_BYTES 0x38 0x60 // other overlays
SET sec_header_off=0x98
WRITE_LONG 0x14 sec_header_off
INSERT_BYTES sec_header_off 0x14
SET door_off=sec_header_off+0x14
WRITE_LONG 0x18 door_off
SET main_tilemap_off=door_off
WRITE_LONG 0x30 main_tilemap_off
FOR (i=0;i<width*height;i+=1) BEGIN
SET this_tile_off=main_tilemap_off + 0xa * i
INSERT_BYTES this_tile_off 0xa
WRITE_SHORT this_tile_off i
WRITE_SHORT (this_tile_off + 2) 1
WRITE_SHORT (this_tile_off + 4) "-1"
END
SET other_tilemap_off=main_tilemap_off + width*height*0xa
WRITE_LONG 0x48 other_tilemap_off
WRITE_LONG 0x60 other_tilemap_off
WRITE_LONG 0x78 other_tilemap_off
WRITE_LONG 0x90 other_tilemap_off
SET door_tile_ind_off=other_tilemap_off
WRITE_LONG 0x1c door_tile_ind_off
SET tile_lookup_off=door_tile_ind_off
WRITE_LONG 0x34 tile_lookup_off
FOR (i=0;i<width*height;i+=1) BEGIN
SET this_off=tile_lookup_off + 0x2*i
INSERT_BYTES this_off 2
WRITE_SHORT this_off i
END
SET sec_tile_lookup_off=tile_lookup_off + 2 * width * height
WRITE_LONG 0x4c other_tilemap_off
WRITE_LONG 0x64 other_tilemap_off
WRITE_LONG 0x7c other_tilemap_off
WRITE_LONG 0x94 other_tilemap_off
// find # wallgroups
SET num_wallgroups = (width / 10) * ( (2* height) / 15)
SET wallgroup_off=sec_tile_lookup_off
WRITE_LONG 0xa4 wallgroup_off
INSERT_BYTES wallgroup_off (0x4 * num_wallgroups)
SET polygon_off = wallgroup_off + (0x4 * num_wallgroups)
WRITE_LONG 0x9c polygon_off
SET polygon_ind_off=polygon_off
WRITE_LONG 0xa8 polygon_ind_off
SET vertex_off=polygon_ind_off
WRITE_LONG 0xa0 vertex_off
END
(Speaking of niche things to do, I worked up the WEIDU code to create a blank wed file, which CREATE can't do natively. You're welcome to it if you want it - though realistically the use case is so tiny that it might not be worth your time.)I'd be happy to take a look.