/*
	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
*/



// --- Object --- //

define objA0.update_address		= u32[A0]
define objA0.render_flags		=  u8[A0 + 0x04]
define objA0.base_state			=  u8[A0 + 0x05]
define objA0.box_size.y			=  u8[A0 + 0x06]
define objA0.box_size.x			=  u8[A0 + 0x07]
define objA0.sprite_priority	= u16[A0 + 0x08]
define objA0.sprite_attributes	= u16[A0 + 0x0a]
define objA0.mapping_offset		= u32[A0 + 0x0c]
define objA0.position.x			= u32[A0 + 0x10]
define objA0.position.x.u16		= u16[A0 + 0x10]
define objA0.position.x.frac	= u16[A0 + 0x12]
define objA0.position.y			= u32[A0 + 0x14]
define objA0.position.y.u16		= u16[A0 + 0x14]
define objA0.position.y.frac	= u16[A0 + 0x16]
define objA0.velocity.x			= s16[A0 + 0x18]
define objA0.velocity.y			= s16[A0 + 0x1a]
define objA0.groundspeed		= s16[A0 + 0x1c]
define objA0.hitbox_extends.y	=  u8[A0 + 0x1e]
define objA0.hitbox_extends.x	=  u8[A0 + 0x1f]
define objA0.state				=  u8[A0 + 0x20]
define objA0.state.former		=  u8[A0 + 0x21]
define objA0.state.both			= u16[A0 + 0x20]
define objA0.animation.sprite	=  u8[A0 + 0x22]
define objA0.animation.frame	=  u8[A0 + 0x23]
define objA0.animation.timer	=  u8[A0 + 0x24]
define objA0.value26			=  u8[A0 + 0x26]

define objA0.collision_attributes	=  u8[A0 + 0x28]	// Determines the type of interactions the object will have with the player

	constant u8 collision_attributes.size	= 0x3f		// Mask for bits that store the entry ID of the object's collision box size from a set list
	constant u8 collision.size.4x4			= 0x00
	constant u8 collision.size.20x20		= 0x01
	constant u8 collision.size.12x20		= 0x02
	constant u8 collision.size.20x12		= 0x03
	constant u8 collision.size.4x16			= 0x04
	constant u8 collision.size.12x18		= 0x05
	constant u8 collision.size.16x16		= 0x06
	constant u8 collision.size.6x6			= 0x07
	constant u8 collision.size.24x12		= 0x08
	constant u8 collision.size.12x16		= 0x09
	constant u8 collision.size.16x8			= 0x0a
	constant u8 collision.size.8x8			= 0x0b
	constant u8 collision.size.20x16		= 0x0c
	constant u8 collision.size.20x8			= 0x0d
	constant u8 collision.size.14x14		= 0x0e
	constant u8 collision.size.24x24		= 0x0f
	constant u8 collision.size.40x16		= 0x10
	constant u8 collision.size.16x24		= 0x11
	constant u8 collision.size.8x16			= 0x12
	constant u8 collision.size.32x112		= 0x13
	constant u8 collision.size.64x32		= 0x14
	constant u8 collision.size.128x32		= 0x15
	constant u8 collision.size.32x32		= 0x16
	constant u8 collision.size.8x8_2		= 0x17		// Identical to 0x0b
	constant u8 collision.size.4x4_2		= 0x18		// Identical to 0x00
	constant u8 collision.size.32x8			= 0x19
	constant u8 collision.size.12x12		= 0x1a
	constant u8 collision.size.8x4			= 0x1b
	constant u8 collision.size.24x4			= 0x1c
	constant u8 collision.size.40x4			= 0x1d
	constant u8 collision.size.4x8			= 0x1e
	constant u8 collision.size.4x24			= 0x1f
	constant u8 collision.size.4x40			= 0x20
	constant u8 collision.size.24x24_2		= 0x21		// Identical to 0x0f
	constant u8 collision.size.24x24_3		= 0x22		// Identical to 0x0f
	constant u8 collision.size.12x24		= 0x23
	constant u8 collision.size.72x8			= 0x24
	constant u8 collision.size.24x40		= 0x25
	constant u8 collision.size.16x4			= 0x26
	constant u8 collision.size.32x2			= 0x27
	constant u8 collision.size.16x28		= 0x28
	constant u8 collision.size.12x36		= 0x29
	constant u8 collision.size.16x2			= 0x2a
	constant u8 collision.size.4x64			= 0x2b
	constant u8 collision.size.24x64		= 0x2c
	constant u8 collision.size.32x16		= 0x2d
	constant u8 collision.size.28x20		= 0x2e
	constant u8 collision.size.16x2_2		= 0x2f		// Identical to 0x2a
	constant u8 collision.size.16x1			= 0x30
	constant u8 collision.size.2x8			= 0x31
	constant u8 collision.size.16x64		= 0x32
	constant u8 collision.size.12x4			= 0x33
	constant u8 collision.size.8x12			= 0x34
	constant u8 collision.size.40x32		= 0x35
	constant u8 collision.size.64x2			= 0x36
	constant u8 collision.size.96x2			= 0x37
	constant u8 collision.size.40x40		= 0x38

	constant u8 collision_attributes.flags	= 0xc0		// Bit mask for type of collision box assigned to the object
	constant u8 collision_flag.DESTRUCTIBLE	= 0x00		// Deprecated, use the below define instead
	constant u8 collision.flag.DESTRUCTIBLE	= 0x00		// Enemies or objects that can be destroyed or hit
	constant u8 collision.flag.ITEM			= 0x40		// Rings or monitors
	constant u8 collision.flag.THREAT		= 0x80		// Harmful objects, usually spikes or objects with spikes
	constant u8 collision.flag.SPECIAL		= 0xc0		// Special interactions handled on a per object basis. e.g. checkpoints and bumpers


define objA0.flags2a			=  u8[A0 + 0x2a]

	constant u8 object.flag.P1_ON_OBJECT	= 0x08		// Player 1 on the object (platform, bridge, corkscrew, monitor, etc.)
	constant u8 object.flag.P2_ON_OBJECT	= 0x10		// Player 2 on the object (platform, bridge, corkscrew, monitor, etc.)
	constant u8 object.flag.P1_PUSHING		= 0x20		// Player 1 pushing against the wall or object
	constant u8 object.flag.P2_PUSHING		= 0x40		// Player 2 pushing against the wall or object


define objA0.flags2b				 =  u8[A0 + 0x2b]	// See char.bonus.* in "defines_character.lemon"
define objA0.subtype2c				 =  u8[A0 + 0x2c]
define objA0.countdown_value		 = s16[A0 + 0x2e]
define objA0.flags2e				 =  u8[A0 + 0x2e]
define objA0.value2f				 =  u8[A0 + 0x2f]
define objA0.value32				 = u16[A0 + 0x32]
define objA0.countdown_callback		 = u32[A0 + 0x34]
define objA0.flags38				 =  u8[A0 + 0x38]
define objA0.value39				 =  u8[A0 + 0x39]
define objA0.value3a				 =  u8[A0 + 0x3a]
define objA0.value3b				 =  u8[A0 + 0x3b]
define objA0.value3e				 = u16[A0 + 0x3e]
define objA0.child_attributes_offset = u32[A0 + 0x3e]
define objA0.value42				 = u16[A0 + 0x42]
define objA0.respawn_entry			 = u16[A0 + 0x48]	// RAM address of this object's respawn flags

define objA0.compound.count						= u16[A0 + 0x16]
define objA0.compound.sprite1.position.x		= u16[A0 + 0x18]
define objA0.compound.sprite1.position.y		= u16[A0 + 0x1a]
define objA0.compound.sprite1.animation.sprite	=  u8[A0 + 0x1d]
define objA0.compound.sprite2.position.x		= u16[A0 + 0x1e]
define objA0.compound.sprite2.position.y		= u16[A0 + 0x20]
define objA0.compound.sprite2.animation.sprite	=  u8[A0 + 0x23]


define objA1.update_address			 = u32[A1]
define objA1.render_flags			 =  u8[A1 + 0x04]
define objA1.base_state				 =  u8[A1 + 0x05]
define objA1.box_size.y				 =  u8[A1 + 0x06]
define objA1.box_size.x				 =  u8[A1 + 0x07]
define objA1.sprite_priority		 = u16[A1 + 0x08]
define objA1.sprite_attributes		 = u16[A1 + 0x0a]
define objA1.mapping_offset			 = u32[A1 + 0x0c]
define objA1.position.x				 = u32[A1 + 0x10]
define objA1.position.x.u16			 = u16[A1 + 0x10]
define objA1.position.x.frac		 = u16[A1 + 0x12]
define objA1.position.y				 = u32[A1 + 0x14]
define objA1.position.y.u16			 = u16[A1 + 0x14]
define objA1.position.y.frac		 = u16[A1 + 0x16]
define objA1.velocity.x				 = s16[A1 + 0x18]
define objA1.velocity.y				 = s16[A1 + 0x1a]
define objA1.groundspeed			 = s16[A1 + 0x1c]
define objA1.hitbox_extends.y		 =  u8[A1 + 0x1e]
define objA1.hitbox_extends.x		 =  u8[A1 + 0x1f]
define objA1.state					 =  u8[A1 + 0x20]
define objA1.state.former			 =  u8[A1 + 0x21]
define objA1.state.both				 = u16[A1 + 0x20]
define objA1.animation.sprite		 =  u8[A1 + 0x22]
define objA1.animation.frame		 =  u8[A1 + 0x23]
define objA1.animation.timer		 =  u8[A1 + 0x24]
define objA1.value26				 =  u8[A1 + 0x26]
define objA1.collision_attributes	 =  u8[A1 + 0x28]
define objA1.flags2a				 =  u8[A1 + 0x2a]
define objA1.flags2b				 =  u8[A1 + 0x2b]		// See char.bonus.* in "defines_character.lemon"
define objA1.subtype2c				 =  u8[A1 + 0x2c]
define objA1.flags2e				 =  u8[A1 + 0x2e]
define objA1.value2f				 =  u8[A1 + 0x2f]
define objA1.value32				 = u16[A1 + 0x32]
define objA1.countdown_callback		 = u32[A1 + 0x34]
define objA1.flags38				 =  u8[A1 + 0x38]
define objA1.value39				 =  u8[A1 + 0x39]
define objA1.value3a				 =  u8[A1 + 0x3a]
define objA1.value3b				 =  u8[A1 + 0x3b]
define objA1.value3e				 = u16[A1 + 0x3e]
define objA1.child_attributes_offset = u32[A1 + 0x3e]
define objA1.value42				 = u16[A1 + 0x42]
define objA1.respawn_entry			 = u16[A1 + 0x48]

define objA1.compound.count						= u16[A1 + 0x16]
define objA1.compound.sprite1.position.x		= u16[A1 + 0x18]
define objA1.compound.sprite1.position.y		= u16[A1 + 0x1a]
define objA1.compound.sprite1.animation.sprite	=  u8[A1 + 0x1d]
define objA1.compound.sprite2.position.x		= u16[A1 + 0x1e]
define objA1.compound.sprite2.position.y		= u16[A1 + 0x20]
define objA1.compound.sprite2.animation.sprite	=  u8[A1 + 0x23]

