Difference between revisions of "FF7/Field/Script/Opcodes/79 MINUS2!"

From Final Fantasy Inside
< FF7‎ | Field‎ | Script‎ | Opcodes
Jump to navigation Jump to search
my_wiki>Halkun
 
m (5 revisions imported)
 
(4 intermediate revisions by 3 users not shown)
Line 8: Line 8:
 
! width="40" | ''D/S''
 
! width="40" | ''D/S''
 
! width="40" | ''Dest''
 
! width="40" | ''Dest''
! width="40" | ''Oper''
+
! width="80" | ''Oper''
 
|}
 
|}
  
Line 14: Line 14:
 
* '''const Bit[4]''' ''D'': Destination bank
 
* '''const Bit[4]''' ''D'': Destination bank
 
* '''const Bit[4]''' ''S'': Source bank
 
* '''const Bit[4]''' ''S'': Source bank
* '''const UByte''' ''Dest'': The destination variable, to which the operand is added.
+
* '''const UByte''' ''Dest'': The destination variable, to which the operand is subtracted.
* '''const UByte''' ''Oper'': The operand, added to the destination.
+
* '''const SWord''' ''Oper'': The operand to be subtracted from the destination.
  
 
==== Description ====
 
==== Description ====
Adds two numbers together and stores the result back into "Dest". The result of the addition is capped at 255.
+
Subtracts "Oper" from "Dest" and stores the result back into "Dest". The result of the subtraction is capped at -32768. The result is not capped at the positive end (32767), so subtracting a large negative number from a large positive number will still produce wrap-around.
If the Source Bank is 0 then the “Oper” is added to the destination value.
+
If the Source Bank is 0 then the “Oper” is subtracted from the destination value.
If the Source Bank is an 8 bit bank, then the “Oper” is the address in that bank where the operand is.
+
If the Source Bank is an 16 bit bank, then the “Oper” is the address in that bank where the operand is.

Latest revision as of 05:17, 23 May 2019

  • Opcode: 0x79
  • Short name: MINUS2!
  • Long name: Saturated Subtraction (16-bit)

Memory layout

0x79 D/S Dest Oper

Arguments

  • const Bit[4] D: Destination bank
  • const Bit[4] S: Source bank
  • const UByte Dest: The destination variable, to which the operand is subtracted.
  • const SWord Oper: The operand to be subtracted from the destination.

Description

Subtracts "Oper" from "Dest" and stores the result back into "Dest". The result of the subtraction is capped at -32768. The result is not capped at the positive end (32767), so subtracting a large negative number from a large positive number will still produce wrap-around. If the Source Bank is 0 then the “Oper” is subtracted from the destination value. If the Source Bank is an 16 bit bank, then the “Oper” is the address in that bank where the operand is.