List of Opcodes: Difference between revisions

m Just adding Adex's comment
RRad (talk | contribs)
 
(16 intermediate revisions by 3 users not shown)
Line 3,376: Line 3,376:
|}
|}
=== 0xd0 - ResetFunctionAttribute ===
=== 0xd0 - ResetFunctionAttribute ===
Sets certain bits of an entity's (i.e., an actor, object, or performer) "function" attribute to 0.
Enables bits that change properties of entities, namely how they follow other actors and how their talk script can be triggered, to 0. Is only intended to disable bits of a shared "attribute" bitfield on the range [0,5], but larger values seem to affect other bitfields. Skytemple accepts binary inputs for params, it is recommended you use them for this opcode!


{| class="wikitable"
{| class="wikitable"
Line 3,384: Line 3,384:
!Type
!Type
!Name
!Name
!Index
! colspan="2" |Bit value
!Description
!Description
|-
|-
| rowspan="6" |1
| rowspan="6" |bitfield
| rowspan="6" |function_bitfield
|0
|0b000001
|1
|1
|bitfield
|Must be OFF for an actor to follow. Potentially signals leader?
|function_bitfield
|-
|Most bits' purposes are unknown. Bit 1 appears to be the bit used for allowing an entity to follow a Type 1 actor, like the actor ACTOR_ATTENDANT1 in the overworld.
|1
|0b000010
|2
|Must be ON for an actor to follow. Potentially signals follower?
|-
|2
|0b000100
|4
|Unknown.
|-
|3
|0b001000
|8
|Unknown. Seems to prevent the actor from turning to face you if disabled. May be interfering with assignment of ACTOR_TALK_SUB or ACTOR_TALK_MAIN, or just preventing movement?
|-
|4
|0b010000
|16
|Unknown.
|-
|5
|0b100000
|32
|Related to follower status and shadow. If a follower has it enabled, output 8 will be enabled.
|}
|}
=== 0xd1 - ResetHitAttribute ===
=== 0xd1 - ResetHitAttribute ===
Sets certain bits of an entity's (i.e., an actor, object, or performer) "hit" attribute to 0.
Resets bits that change properties of entities, namely how their collision works, to 0. Is only intended to disable bits of a shared "attribute" bitfield on the range [6,10], but larger values seem to affect other bitfields. Skytemple accepts binary inputs for params, it is recommended you use them for this opcode!


{| class="wikitable"
{| class="wikitable"
Line 3,400: Line 3,430:
!Type
!Type
!Name
!Name
!Index
! colspan="2" |Bit value
!Description
!Description
|-
| rowspan="5" |1
| rowspan="5" |bitfield
| rowspan="5" |hit_bitfield
|0
|0b00001
|1
|Must be enabled for the entity to interact with layer 1 of map collision.
|-
|-
|1
|1
|bitfield
|0b00010
|hit_bitfield
|2
|Most bits' purposes are unknown.
|Must be enabled for the entity to interact with layer 2 of map collision.
 
|-
* 2: Entity collision.
|2
* 6: Talk Script upon collision.
|0b00100
* 7: Talk Script upon pressing the A Button near the entity.
|4
|Must be enabled for actor collisions to be recognized (GetCollidingActorID).
|-
|3
|0b01000
|8
|Must be enabled for object collisions to be recognized (GetCollidingObjectID).
|-
|4
|0b10000
|16
|Must be enabled for event (trigger) collisions to be recognized (GetCollidingEventID).
|}
|}
=== 0xd2 - ResetOutputAttribute ===
=== 0xd2 - ResetOutputAttribute ===
Sets certain bits of an entity's (i.e., an actor, object, or performer) "output" attribute to 0.
Resets certain bits of an entity's (i.e., an actor, object, or performer) "output" attribute to 0. Is only intended to disable bits of a shared "attribute" bitfield on the range [16,31]. Skytemple accepts binary inputs for params, it is recommended you use them for this opcode!


{| class="wikitable"
{| class="wikitable"
Line 3,420: Line 3,471:
!Type
!Type
!Name
!Name
!Id
! colspan="2" |Bit value
!Description
!Description
|-
| rowspan="16" |1
| rowspan="16" |bitfield
| rowspan="16" |output_bitfield
|0
|0b0000000000000001
|1
|Unknown.
|-
|-
|1
|1
|bitfield
|0b0000000000000010
|output_bitfield
|2
|
|Underlay below entities.
# Underlay below entities.
# Overlay above entities.
# Overlay above the current Map Background's Layer 2.
# Overlay above the game's canvas system, which includes the textbox, portrait, and some <code>screen_</code> commands that do not end in <code>All</code>.
# Flicker.
# Transparency.
# Invisibility.
# Displays shadow.
|}
=== 0xd3 - ResetReplyAttribute ===
Sets certain bits of an entity's (i.e., an actor, object, or performer) "reply" attribute to 0.
 
{| class="wikitable"
|+Parameters
|-
|-
!#
|2
!Type
|0b0000000000000100
!Name
|4
!Description
|Overlay above entities.
|-
|-
|1
|3
|bitfield
|0b0000000000001000
|reply_bitfield
|8
|Most bits' purposes are unknown.
|Overlay above the current Map Background's Layer 2.
 
|-
* 1: Talk Script upon collision.
|4
* 2: Talk Script upon pressing the A Button near the entity.
|0b0000000000010000
* 6: Underlay below entities.
|16
* 7: Overlay above entities.
|Overlay above the game's canvas system, including textbox, portrait, and some screen_ commands not ending in <code>All</code>.
|}
|-
=== 0xd4 - ResumeEffect ===
|5
|0b0000000000100000
|32
|Flicker.
|-
|6
|0b0000000001000000
|64
|Transparency.
|-
|7
|0b0000000010000000
|128
|Invisibility.
|-
|8
|0b0000000100000000
|256
|Displays shadow.
|-
|9
|0b0000001000000000
|512
|Unknown.
|-
|10
|0b0000010000000000
|1024
|Always render, regardless of distance from the screen.
|-
|11
|0b0000100000000000
|2048
|Makes coordinates relative to the screen rather than the map. (Likely only for rendering and not collision, untested.)
|-
|12
|0b0001000000000000
|4096
|Unknown.
|-
|13
|0b0010000000000000
|8192
|Unknown.
|-
|14
|0b0100000000000000
|16384
|Unknown.
|-
|15
|0b1000000000000000
|32768
|In 0x22F655C [EU], determines the first bit of alloc_flags for <code>LoadWanTableEntryFromPack</code>. Seems to be enabled in 0x22F8818 [EU] if its fifth param is true.
|}
=== 0xd3 - ResetReplyAttribute ===
Resets bits that change properties of entities, namely how their talk script is triggered, to 0. Is only intended to enable bits of a shared "attribute" bitfield on the range [11,15], but larger values seem to affect other bitfields. Skytemple accepts binary inputs for params, it is recommended you use them for this opcode!
{| class="wikitable"
|+Parameters
|-
!#
!Type
!Name
!Index
! colspan="2" |Bit value
!Description
|-
| rowspan="5" |1
| rowspan="5" |bitfield
| rowspan="5" |reply_bitfield
|0
|0b00001
|1
|Unknown.
|-
|1
|0b00010
|2
|If enabled, plays talk script if colliding with entity.
|-
|2
|0b00100
|4
|If enabled, plays talk script when pressing A near the entity.
|-
|3
|0b01000
|8
|Unknown.
|-
|4
|0b10000
|16
|Unknown.
|}
=== 0xd4 - ResumeEffect ===
Resumes the current graphical effect of an entity (i.e., an actor, object, or performer) that has been paused with <code>PauseEffect</code> prior to using this opcode.
Resumes the current graphical effect of an entity (i.e., an actor, object, or performer) that has been paused with <code>PauseEffect</code> prior to using this opcode.


Line 4,482: Line 4,624:
|uint
|uint
|pan
|pan
|The panning of the SE. This parameter gets recalculated internally as  <code>((''pan'' * 0x3f + ((''pan'' * 0x3f >> 7) >> 0x18)) >> 8) + 0x40</code>, which is eventually split up into two halfwords, then recalculated further into a signed byte.
|The panning of the SE. Has an intended range of -260 (left) to 260 (right), with 0 being the center.
 
This parameter gets recalculated internally as  <code>((''pan'' * 0x3f + ((''pan'' * 0x3f >> 7) >> 0x18)) >> 8) + 0x40</code>, which is eventually split up into two halfwords, then recalculated further into a signed byte.
What this means is that:
What this means is that:


* A ''pan'' parameter of 260 will result in sound panning only to the right channel.
* A ''pan'' parameter of 260 will result in sound panning only to the right channel.
* A ''pan'' parameter of 261 will result in sound panning only to the left channel.
* A ''pan'' parameter of 261 will result in sound panning only to the left channel.
More research on this parameter may be needed.
|}
|}
=== 0xf6 - se_ChangeVolume ===
=== 0xf6 - se_ChangeVolume ===
Line 4,577: Line 4,719:
|uint
|uint
|pan
|pan
|The panning of the SE. This parameter gets recalculated internally as  <code>((''pan'' * 0x3f + ((''pan'' * 0x3f >> 7) >> 0x18)) >> 8) + 0x40</code>, which is eventually split up into two halfwords, then recalculated further into a signed byte.
|The panning of the SE. Has an intended range of -260 (left) to 260 (right), with 0 being the center.
 
This parameter gets recalculated internally as  <code>((''pan'' * 0x3f + ((''pan'' * 0x3f >> 7) >> 0x18)) >> 8) + 0x40</code>, which is eventually split up into two halfwords, then recalculated further into a signed byte.
What this means is that:
What this means is that:


* A ''pan'' parameter of 260 will result in sound panning only to the right channel.
* A ''pan'' parameter of 260 will result in sound panning only to the right channel.
* A ''pan'' parameter of 261 will result in sound panning only to the left channel.
* A ''pan'' parameter of 261 will result in sound panning only to the left channel.
More research on this parameter may be needed.
|}
|}
=== 0xfa - se_PlayPan ===
=== 0xfa - se_PlayPan ===
Line 4,604: Line 4,746:
|uint
|uint
|pan
|pan
|The panning of the SE. This parameter gets recalculated internally as  <code>((''pan'' * 0x3f + ((''pan'' * 0x3f >> 7) >> 0x18)) >> 8) + 0x40</code>, which is eventually split up into two halfwords, then recalculated further into a signed byte.
|The panning of the SE. Has an intended range of -260 (left) to 260 (right), with 0 being the center.
 
This parameter gets recalculated internally as  <code>((''pan'' * 0x3f + ((''pan'' * 0x3f >> 7) >> 0x18)) >> 8) + 0x40</code>, which is eventually split up into two halfwords, then recalculated further into a signed byte.
What this means is that:
What this means is that:


* A ''pan'' parameter of 260 will result in sound panning only to the right channel.
* A ''pan'' parameter of 260 will result in sound panning only to the right channel.
* A ''pan'' parameter of 261 will result in sound panning only to the left channel.
* A ''pan'' parameter of 261 will result in sound panning only to the left channel.
More research on this parameter may be needed.
|}
|}
=== 0xfb - se_PlayVolume ===
=== 0xfb - se_PlayVolume ===
Line 4,763: Line 4,905:
|position_marker_id?
|position_marker_id?
|Set to one of the following character sprite offsets:
|Set to one of the following character sprite offsets:
0: Head<br>1: Right Hand<br>2: Left Hand<br>3: Center<br>4: No offset (bottom of sprite)
# <li value="0">Head</li>
# Right Hand
# Left Hand
# Center
# No offset (bottom of sprite)
|}
|}


=== 0x103 - SetFunctionAttribute ===
=== 0x103 - SetFunctionAttribute ===
<TO DO: Opcode description>
Enables bits that change properties of entities, namely how they follow other actors and how their talk script can be triggered, to 1. Is only intended to enable bits of a shared "attribute" bitfield on the range [0,5], but larger values seem to affect other bitfields. Skytemple accepts binary inputs for params, it is recommended you use them for this opcode!


{| class="wikitable"
{| class="wikitable"
Line 4,775: Line 4,921:
!Type
!Type
!Name
!Name
!Index
! colspan="2" |Bit value
!Description
!Description
|-
|-
| rowspan="6" |1
| rowspan="6" |bitfield
| rowspan="6" |func_bitfield
|0
|0b000001
|1
|1
|bitfield
|Must be OFF for an actor to follow. Potentially signals leader?
|unk0
|-
|
|1
|0b000010
|2
|Must be ON for an actor to follow. Potentially signals follower?
|-
|2
|0b000100
|4
|Unknown.
|-
|3
|0b001000
|8
|Unknown. Seems to prevent the actor from turning to face you if disabled. May be interfering with assignment of ACTOR_TALK_SUB or ACTOR_TALK_MAIN, or just preventing movement?
|-
|4
|0b010000
|16
|Unknown.
|-
|5
|0b100000
|32
|Related to follower status and shadow. If a follower has it enabled, output 8 will be enabled.
|}
|}
=== 0x104 - SetHeight ===
=== 0x104 - SetHeight ===
Line 4,799: Line 4,975:
|}
|}
=== 0x105 - SetHitAttribute ===
=== 0x105 - SetHitAttribute ===
<TO DO: Opcode description>
Sets bits that change properties of entities, namely how their collision works, to 1. Is only intended to enable bits of a shared "attribute" bitfield on the range [6,10], but larger values seem to affect other bitfields. Skytemple accepts binary inputs for params, it is recommended you use them for this opcode!


{| class="wikitable"
{| class="wikitable"
Line 4,807: Line 4,983:
!Type
!Type
!Name
!Name
!Index
! colspan="2" |Bit value
!Description
!Description
|-
| rowspan="5" |1
| rowspan="5" |bitfield
| rowspan="5" |hit_bitfield
|0
|0b00001
|1
|Must be enabled for the entity to interact with layer 1 of map collision.
|-
|-
|1
|1
|bitfield
|0b00010
|unk0
|2
|
|Must be enabled for the entity to interact with layer 2 of map collision.
|-
|2
|0b00100
|4
|Must be enabled for actor collisions to be recognized (GetCollidingActorID).
|-
|3
|0b01000
|8
|Must be enabled for object collisions to be recognized (GetCollidingObjectID).
|-
|4
|0b10000
|16
|Must be enabled for event (trigger) collisions to be recognized (GetCollidingEventID).
|}
|}
=== 0x106 - SetMoveRange ===
=== 0x106 - SetMoveRange ===
Line 4,841: Line 5,042:
|}
|}
=== 0x107 - SetOutputAttribute ===
=== 0x107 - SetOutputAttribute ===
Sets certain bits of an entity's (i.e., an actor, object, or performer) "output" attribute to 1.
Sets certain bits of an entity's (i.e., an actor, object, or performer) "output" attribute to 1. Is only intended to enable bits of a shared "attribute" bitfield on the range [16,31]. Skytemple accepts binary inputs for params, it is recommended you use them for this opcode!
{| class="wikitable"
{| class="wikitable"
|+Parameters
|+Parameters
Line 4,848: Line 5,049:
!Type
!Type
!Name
!Name
!Id
! colspan="2" |Bit value
!Description
!Description
|-
|-
| rowspan="16" |1
| rowspan="16" |bitfield
| rowspan="16" |output_bitfield
|0
|0b0000000000000001
|1
|1
|bitfield
|Unknown.
|output_bitfield
|
# Underlay below entities.
# Overlay above entities.
# Overlay above the current Map Background's Layer 2.
# Overlay above the game's canvas system, which includes the textbox, portrait, and some <code>screen_</code> commands that do not end in <code>All</code>.
# Flicker.
# Transparency.
# Invisibility.
# Displays shadow.
|}
=== 0x108 - SetPosition ===
<TO DO: Opcode description>
 
{| class="wikitable"
|+Parameters
|-
|-
!#
|1
|0b0000000000000010
|2
|Underlay below entities.
|-
|2
|0b0000000000000100
|4
|Overlay above entities.
|-
|3
|0b0000000000001000
|8
|Overlay above the current Map Background's Layer 2.
|-
|4
|0b0000000000010000
|16
|Overlay above the game's canvas system, including textbox, portrait, and some screen_ commands not ending in <code>All</code>.
|-
|5
|0b0000000000100000
|32
|Flicker.
|-
|6
|0b0000000001000000
|64
|Transparency.
|-
|7
|0b0000000010000000
|128
|Invisibility.
|-
|8
|0b0000000100000000
|256
|Displays shadow.
|-
|9
|0b0000001000000000
|512
|Unknown.
|-
|10
|0b0000010000000000
|1024
|Always render, regardless of distance from the screen.
|-
|11
|0b0000100000000000
|2048
|Makes coordinates relative to the screen rather than the map. (Likely only for rendering and not collision, untested.)
|-
|12
|0b0001000000000000
|4096
|Unknown.
|-
|13
|0b0010000000000000
|8192
|Unknown.
|-
|14
|0b0100000000000000
|16384
|Unknown.
|-
|15
|0b1000000000000000
|32768
|In 0x22F655C [EU], determines the first bit of alloc_flags for <code>LoadWanTableEntryFromPack</code>. Seems to be enabled in 0x22F8818 [EU] if its fifth param is true. (Further detail is not currently known)
|}
=== 0x108 - SetPosition ===
<TO DO: Opcode description>
 
{| class="wikitable"
|+Parameters
|-
!#
!Type
!Type
!Name
!Name
Line 4,963: Line 5,236:
|}
|}
=== 0x10e - SetReplyAttribute ===
=== 0x10e - SetReplyAttribute ===
<TO DO: Opcode description>
Sets bits that change properties of entities, namely how their talk script is triggered, to 1. Is only intended to enable bits of a shared "attribute" bitfield on the range [11,15], but larger values seem to affect other bitfields. Skytemple accepts binary inputs for params, it is recommended you use them for this opcode!
 
{| class="wikitable"
{| class="wikitable"
|+Parameters
|+Parameters
Line 4,971: Line 5,243:
!Type
!Type
!Name
!Name
!Index
! colspan="2" |Bit value
!Description
!Description
|-
| rowspan="5" |1
| rowspan="5" |bitfield
| rowspan="5" |reply_bitfield
|0
|0b00001
|1
|Unknown.
|-
|-
|1
|1
|bitfield
|0b00010
|unk0
|2
|
|If enabled, plays talk script if colliding with entity.
|-
|2
|0b00100
|4
|If enabled, plays talk script when pressing A near the entity.
|-
|3
|0b01000
|8
|Unknown.
|-
|4
|0b10000
|16
|Unknown.
|}
|}
=== 0x10f - SetupOutputAttributeAndAnimation ===
=== 0x10f - SetupOutputAttributeAndAnimation ===
Line 5,587: Line 5,884:
No parameters.
No parameters.
=== 0x129 - StopAnimation ===
=== 0x129 - StopAnimation ===
<TO DO: Opcode description>
Stops a sprite's current animation, freezing it to its first frame.
 
This opcode does not have a parameter for an entity, as it must be used in a with-statement or a targeted routine.


No parameters.
No parameters.
Line 5,648: Line 5,947:
|uint
|uint
|script_sector
|script_sector
|The "sector" of the script, and the value <code>switch(sector())</code> will return in def 0. Often used to determine whether a cutscene should be played as a flashback or not.
|The "sector" of the script, and the value <code>switch(sector())</code> will return in def 0. Often used to determine whether a cutscene should be played as a flashback or not. Sector ids above a certain threshold do not function. Perhaps 100, or 127?
|}
|}


Line 5,675: Line 5,974:
|uint
|uint
|script_sector
|script_sector
|The "sector" of the script, and the value <code>switch(sector())</code> will return in def 0. Often used to determine whether a cutscene should be played as a flashback or not.
|The "sector" of the script, and the value <code>switch(sector())</code> will return in def 0. Often used to determine whether a cutscene should be played as a flashback or not. Note: Sector ids above a certain threshold do not function. Perhaps 100, or 127?
|}
|}


Line 6,356: Line 6,655:
=== 0x15d - WaitBgmSignal ===
=== 0x15d - WaitBgmSignal ===
Pauses the routine until a DSE event with ID 0xF6 on the current BGM track is triggered. This can be used to sync certain parts of the scene to the background music.
Pauses the routine until a DSE event with ID 0xF6 on the current BGM track is triggered. This can be used to sync certain parts of the scene to the background music.
Also unpauses if there is no BGM playing, making it a general purpose WaitBgm.


No parameters.
No parameters.
Line 6,781: Line 7,082:


== Other Opcodes ==
== Other Opcodes ==
These opcodes cannot be directly called from ExplorerScript, since they are represented as higher-level constructs.
These opcodes cannot be directly called from ExplorerScript, since they are represented as higher-level constructs, but are present in [[SSBScript]].


=== 0x28 - Branch ===
=== 0x28 - Branch ===
Line 7,080: Line 7,381:
|}
|}
=== 0x33 - BranchSum ===
=== 0x33 - BranchSum ===
<TO DO: Opcode description>
Calculates the sum of an indexed variable, compares it against a value, and jumps to a relative address if a certain condition is met (e.g., equal).


{| class="wikitable"
{| class="wikitable"
Line 7,091: Line 7,392:
|-
|-
|1
|1
|uint
|GameVar
|unk0
|var
|
|One of the 115 possible script variables. Specifically, an indexed variable is expected.
|-
|-
|2
|2
|uint
|uint
|unk1
|operator
|
|Comparison operator used when comparing variable sum against a value.
# <li value="0">Always true</li>
# Always false
# Equal
# Greater than
# Less than
# Greater than or equal
# Less than or equal
# Not equal
# Bitwise AND
# Bitwise XOR
# Test specific bit
|-
|-
|3
|3
|uint
|uint
|unk2
|value
|
|Value used in comparison.
|-
|-
|4
|4
|uint
|uint
|jump_address
|jump_address
|
|Address to jump to if the comparison meets the condition.
|}
|}
=== 0x34 - BranchValue ===
=== 0x34 - BranchValue ===
Line 7,761: Line 8,073:
Same as _SwitchMonologue, but typically uses <code>$PARTNER_TALK_KIND</code> as an argument, and the cases used vary.
Same as _SwitchMonologue, but typically uses <code>$PARTNER_TALK_KIND</code> as an argument, and the cases used vary.


Of the vanilla game partner options:
Of the game's partner options:


<code>case 1:</code> used if Squirtle, Tododile, Chimchar, Meowth, or Munchlax
<code>case 1:</code> used if male Squirtle, Totodile, Chimchar, Meowth, or Munchlax


<code>case 2:</code> used for all other male partners
<code>case 2:</code> default (all other male partners in vanilla)


<code>case 3:</code> used for all female partners
<code>case 3:</code> used if female Vulpix, Eevee, Chikorita, Torchic or Skitty (all female partners in vanilla)


<code>default:</code> used when <code>$PARTNER_TALK_KIND</code>'s Talk Group has a value other than 1, 2, or 3
<code>default:</code> used when <code>$PARTNER_TALK_KIND</code>'s Talk Group has a value other than 1, 2, or 3
Line 7,786: Line 8,098:
|<code>$x_TALK_KIND</code>, contains Talk Group number
|<code>$x_TALK_KIND</code>, contains Talk Group number
|}
|}
=== 0xc9 - object ===
=== 0xc9 - object ===
<TO DO: Opcode description>
<TO DO: Opcode description>
Line 7,987: Line 8,300:
|}
|}
=== 0x149 - SwitchSector ===
=== 0x149 - SwitchSector ===
<TO DO: Opcode description>
Returns the currently-loaded "sector" for a given routine. When used in targeted routines, this returns the sector the entity is loaded on. When used in the main routine, this returns a value passed in to load the scene, e.g., the final parameter of <code>supervision_ExecuteActingSub</code>. Most often used in Enter scenes to mark a Cutscene -> Overworld transition, but can also be checked within Acting scenes.
 
In ExplorerScript, this can be simply represented as <code>switch(sector())</code>.


No parameters.
No parameters.
Note: Sector ids above a certain threshold do not function. Perhaps 100, or 127?
=== 0x14a - SwitchValue ===
=== 0x14a - SwitchValue ===
<TO DO: Opcode description>
<TO DO: Opcode description>