Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Suggestion] Sonic Crackers mapping/DPLC support #63

Open
MDTravisYT opened this issue Oct 31, 2023 · 5 comments
Open

[Suggestion] Sonic Crackers mapping/DPLC support #63

MDTravisYT opened this issue Oct 31, 2023 · 5 comments

Comments

@MDTravisYT
Copy link

Sonic Crackers is an extremely early prototype of Chaotix, which still runs primarily on the Mega Drive, Investigating its mappings/DPLC format, it's very different from what the main classics use, which makes sense as it runs on a completely new engine.
I may not have the skill to add a custom script to Flex 2 for Crackers currently, if that's even possible, but I hope support for it gets added to the main program someday. Documentation is present in Markey Jester's disassembly.

Mappings documentation from disassembly:
; Guide as Documented by Hivebrain ; ; Each mappings block consists of six bytes: ; ; dc.b $SS,$YY,$TT,$TT,$XX,$ZZ ; ; $SS = Shape and size of sprite piece ; $YY = Y position of sprite piece ; $TTTT = Tile to read in VRam ; $XX = X position of sprite piece ; $ZZ = whether it's the last map to use in the sprite or not (00 Include next map in sprite/FF End of sprite) ;
DPLC documentation from disassembly:
; --------------------------------------------------------------------------- ; PLC and Mapping Main Index Block - Sonic ; --------------------------------------------------------------------------- ; An Example of the setout: ; ; vvMapping Pointersvv vvPLC Pointersvv ; ; dc.w "Location"-Map_Sonic, "Location"-PLC_Sonic ; dc.w "Location"-Map_Sonic, "Location"-PLC_Sonic ; dc.w "Location"-Map_Sonic, "Location"-PLC_Sonic ; etc, etc ; ---------------------------------------------------------------------------

@kirjavascript
Copy link
Owner

flexcrackers

I managed to read the crackers mapping data

However, each sprite image seems to use a label that I need to retain if I want to support writing

@MDTravisYT
Copy link
Author

Awesome! I may not need writing just yet, but reading will absolutely help me work with this stuff. Thanks for this!

@kirjavascript
Copy link
Owner

kirjavascript commented Nov 1, 2023

in that case you can use this script for reading only;

// Flex 2 Mapping Definition - Sonic Crackers

const {
    mappings,
    dplcs,
    offsetTable,
    write,
    read,
    dc,
    nybble,
    endFrame,
    skipFrame,
    signed,
    asm,
} = Flex2;

mappings([
    [
        () => {
            return (({ mapping }) => {
                read(nybble);
                mapping.width = read(2) + 1;
                mapping.height = read(2) + 1;
                mapping.top = read(dc.b, signed);
                mapping.art = read(dc.w) - 1692;
                mapping.left = read(dc.b, signed);
                mapping.palette = 0;
                mapping.priority = 0;
                mapping.vflip = 0;
                mapping.hflip = 0
                if (read(dc.b) === 0xFF) return endFrame;
            });
        },
        ({ sprite }) => {
            return ({ mapping }, frameIndex) => {
                write(nybble, 0);
                write(2, mapping.width - 1);
                write(2, mapping.height - 1);
                write(dc.b, mapping.top);
                write(dc.w, mapping.art + 1692);
                write(dc.b, mapping.left);
                // 0 or FF depending on last one
            };
        },
    ],
]);

dplcs([
    [
        () => {
            return (({ mapping }) => {
                const tiles = read(dc.w);
                read(dc.w); // dma src
                const addr = read(12);
                read(4);
                read(dc.w); // dma dst
                read(dc.w); // end of plc

                const swapped = (tiles >> 8) + ((tiles & 0xFF) << 8);
                mapping.size = swapped / 0x10;
                mapping.art = addr;
                return endFrame;
            });
        },
        ({ sprite }) => {
        },
    ],
]);

@MDTravisYT
Copy link
Author

It appears that each map has its own tile offset. Instead of manually modifying the script each time, it'd be neat to have some form of way to edit the tile offset the art is loaded to/read from.

@kirjavascript
Copy link
Owner

I have added an extra input for the tile offset and it'll be available in the next version!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants