DragonMinded / libdragon

Open source library for N64 development.
https://libdragon.dev
The Unlicense
722 stars 105 forks source link

Add an assertion when using old-school sprite loading with compressed sprites #512

Open rasky opened 7 months ago

rasky commented 7 months ago

Some examples on trunk still use the old-school sprite loading instead of sprite_load:

    fp = dfs_open("/background1.sprite");
    sprite_t *background1 = malloc( dfs_size( fp ) );
    dfs_read( background1, 1, dfs_size( fp ), fp );
    dfs_close( fp );

This is compatible with sprites created with mksprite with the old syntax. When switching to the new syntax, mksprite compresses sprites by default so they're not compatible anymore. Instead, users get random crashes.

We could try and add an assertion here, maybe in __sprite_upgrade().

rasky commented 6 months ago

Fixed in preview: https://github.com/DragonMinded/libdragon/commit/c1a13d9b05b71465d82ad41e07edfb5c688dd9df