/*
	This script file is part of the Sonic 3 A.I.R. script software distribution.
	Copyright (C) 2017-2024 by Eukaryot

	Published under the GNU GPLv3 open source software license, see license.txt
	or https://www.gnu.org/licenses/gpl-3.0.en.html
*/



//-------------------------------------------------------//
// C++ bindings that got removed or renamed              //
//-------------------------------------------------------//

function void Renderer.drawVdpSpriteWithTint(s16 px, s16 py, u8 encodedSize, u16 patternIndex, u16 renderQueue, u32 tintColor, u32 addedColor)
{
	// Convert colors from 0xAABBGGRR to 0xRRGGBBAA
	tintColor = convertColors32(tintColor)
	addedColor = convertColors32(addedColor)
	Renderer.drawVdpSpriteTinted(px, py, encodedSize, patternIndex, renderQueue, tintColor, addedColor)
}

function void Renderer.drawCustomSprite(u64 key, s16 px, s16 py, u8 atex, u8 flags, u16 renderQueue, u8 angle, u32 tintColor, s32 scale)
{
	// Convert color from 0xAABBGGRR to 0xRRGGBBAA
	tintColor = convertColors32(tintColor)
	Renderer.drawCustomSpriteTinted(key, px, py, atex, flags, renderQueue, angle, tintColor, scale)
}

function void Renderer.drawCustomSpriteWithTransform(u64 key, s16 px, s16 py, u8 atex, u8 flags, u16 renderQueue, u32 tintColor, s32 transform11, s32 transform12, s32 transform21, s32 transform22)
{
	// Convert color from 0xAABBGGRR to 0xRRGGBBAA
	tintColor = convertColors32(tintColor)
	Renderer.drawCustomSpriteTransformed(key, px, py, atex, flags, renderQueue, tintColor, transform11, transform12, transform21, transform22)
}

function void Renderer.enforceClearScreen(u8 enabled)
{
	// Obsolete as the screen gets cleared each frame now anyways
}

function void debugDrawRect(s32 px, s32 py, s32 width, s32 height)
{
	Renderer.drawRect(px, py, width, height, 0xff00ffc0, 0xffff, true)
}

function void debugDrawRect(s32 px, s32 py, s32 width, s32 height, u32 color)
{
	// Convert color from 0xAABBGGRR to 0xRRGGBBAA
	color = convertColors32(color)
	Renderer.drawRect(px, py, width, height, color, 0xffff, true)
}

function void Debug.drawRect(s32 px, s32 py, s32 width, s32 height)
{
	Renderer.drawRect(px, py, width, height, 0xff00ffc0, 0xffff, true)
}

function void Debug.drawRect(s32 px, s32 py, s32 width, s32 height, u32 color)
{
	Renderer.drawRect(px, py, width, height, color, 0xffff, true)
}

function void Game.onScreenFadedOutBeforeDataSelect()
{
	Game.returnToMainMenu()
}

function bool Game.isModdedSound(u64 sfxId)
{
	return (Audio.getAudioKeyType(sfxId) == AudioKeyType.MODDED)
}



// These are still actively used in the scripts, for compatibility with mods that overwrite these variants of the functions

function void Renderer.setPaletteEntry(u8 index, u32 color)
{
	Renderer.setPaletteColor(u16(index), color)
}

function void Renderer.setPaletteEntryPacked(u8 index, u16 color)
{
	Renderer.setPaletteColorPacked(u16(index), color)
}

function void Renderer.setSecondaryPaletteEntryPacked(u8 index, u16 color)
{
	Renderer.setSecondaryPaletteColorPacked(u16(index), color)
}

function void Renderer.drawCustomSprite(u64 key, s16 px, s16 py, u8 atex, u8 flags, u16 renderQueue)
{
	Renderer.drawSprite(key, px, py, u16(atex), flags, renderQueue)
}

function void Renderer.drawCustomSprite(u64 key, s16 px, s16 py, u8 atex, u8 flags, u16 renderQueue, u8 angle, u8 alpha)
{
	Renderer.drawSprite(key, px, py, u16(atex), flags, renderQueue, angle, alpha)
}

function void Renderer.drawCustomSpriteTinted(u64 key, s16 px, s16 py, u8 atex, u8 flags, u16 renderQueue, u8 angle, u32 tintColor, s32 scale)
{
	Renderer.drawSpriteTinted(key, px, py, u16(atex), flags, renderQueue, angle, tintColor, scale)
}

function void Renderer.drawCustomSpriteTransformed(u64 key, s16 px, s16 py, u8 atex, u8 flags, u16 renderQueue, u32 tintColor, s32 transform11, s32 transform12, s32 transform21, s32 transform22)
{
	Renderer.drawSpriteTransformed(key, px, py, u16(atex), flags, renderQueue, tintColor, transform11, transform12, transform21, transform22)
}

function void Standalone.setFastMusicFlagWithSpeedup(u8 flag, u32 relativeSpeed)
{
	Standalone.setFastMusicFlagWithSpeedup(flag, float(relativeSpeed) / 65536.0f)
}
