// Best Ending
function bool Standalone.onWriteToSpriteTable(s16 px, s16 py, u16 renderQueue)
{
    if((objA0.update_address == 0x05e18a)   && (outro.ending_type >= 0)  && (global.characters == CHARS_TAILS_ALONE)) 
    {
        bool prioFlag = (objA0.sprite_attributes & 0x8000) != 0
        u64 key = ""        
        key = stringformat("end_0x%02x", objA0.animation.sprite)

        if(Renderer.hasCustomSprite(key))
        {
	Renderer.drawCustomSprite(key, px, py, 0x20, objA0.render_flags | (prioFlag ? SPRITE_FLAG_PRIO : 0), renderQueue)
            return true
        }
    }
 
    return base.Standalone.onWriteToSpriteTable(px, py, renderQueue)
}

// Good Ending
function bool Standalone.onWriteToSpriteTable(s16 px, s16 py, u16 renderQueue)
{
    if((objA0.update_address == 0x05e18a)   && (outro.ending_type == 0)  && (global.characters == CHARS_TAILS_ALONE)) 
    {
        bool prioFlag = (objA0.sprite_attributes & 0x8000) != 0
        u64 key = ""        
        key = stringformat("supend_0x%02x", objA0.animation.sprite)

        if(Renderer.hasCustomSprite(key))
        {
	Renderer.drawCustomSprite(key, px, py, 0x20, objA0.render_flags | (prioFlag ? SPRITE_FLAG_PRIO : 0), renderQueue)
            return true
        }
    }
 
    return base.Standalone.onWriteToSpriteTable(px, py, renderQueue)
}
