kirjavascript / Flex2

sega megadrive sprite editor
MIT License
55 stars 4 forks source link

Add support for static mappings #74

Open kuroya2mouse opened 2 months ago

kuroya2mouse commented 2 months ago

Does Flex2 have static mapping support? S1-S3K have some objects in this format and Flex2 cannot open them

We also actively use static mappings for our objects and we don't have the opportunity to view them in Flex 2

As an example of static mapping: Map_LConv_Wheel: dc.b $F0, $F, 0, 0, $FF, $F0

There is no offset table and only one tile to display in the game

As a result, we made own js-file for Flex 2 and now it works

mappings([
    [
        () => {
            const quantity = 1;
            return quantity > 0 && (({ mapping }, frameIndex) => {
                mapping.top = read(dc.b, signed);
                read(nybble);
                mapping.width = read(2) + 1;
                mapping.height = read(2) + 1;
                mapping.priority = read(1);
                mapping.palette = read(2);
                mapping.vflip = read(1);
                mapping.hflip = read(1);
                mapping.art = read(11);
                mapping.left = read(dc.w, signed);
                if (frameIndex === quantity - 1) return endFrame;
            });
        },
        ({ sprite }) => {
            return ({ mapping }) => {
                // top
                write(dc.b, mapping.top);
                write(nybble, 0);
                // size
                write(2, mapping.width - 1);
                write(2, mapping.height - 1);
                // 1 player
                write(1, mapping.priority);
                write(2, mapping.palette);
                write(1, mapping.vflip);
                write(1, mapping.hflip);
                write(11, mapping.art);
                // left
                write(dc.w, mapping.left);
            };
        },
    ],
]);

It would be great to see official support for this format.

Maybe you can add a checkbox so that you don't have to do a bunch of mapping for each game? flex2

kirjavascript commented 2 months ago

I added support for checkboxes in mapping scripts, so I can do this. I'll put it in the next version!