Difference between revisions of "Effect Files"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
(→‎More Sections 0xC8 long: added start location of later 0xc8 sections)
Line 498: Line 498:
 
==== Global Sound Effects Timing Sections ====
 
==== Global Sound Effects Timing Sections ====
 
Starts at 0xD28 in Misc Timing Section
 
Starts at 0xD28 in Misc Timing Section
 +
 
Six sections, each 0x1e long. For Global Sound Effects?
 
Six sections, each 0x1e long. For Global Sound Effects?
 
  
 
==== More Sections 0xC8 long ====
 
==== More Sections 0xC8 long ====

Revision as of 01:29, 21 May 2025

Effect files are within the Effect directory in an extracted ROM.

FFTPatcher's ability tab will show which effect file is used by which ability.

Effect Images can be found within Shishi Sprite Editor's more recent versions, in the Other images tab.

A video compilation of all effects can be found here: Special Effects Compilation Video Directory

Data related to Effects: Effect Data


Effect File Format

Info on this page is based on the following:

Glain's forum post on modifying effect data

Choto's Effect Editor and notes.

St4rw4k3r's post

Related Routines: Effect_Graphics and Emitter_Control_Routine

3D Model ASM Subroutine Section (Optional)

List of routines: EFFECT Routines

These routines seem to deal with drawing 3D models and/or 3D rotations. Some effects have multiple routines.

I'm not sure what data the models draw from, but they tend to be calculated rather than stated. Ex. rather than having every polygon and their position relative to the field, they have like, "here's 1 polygon, repeat this 128 times and curve it by this much going this way, and this much going this way" Unsure if effect 4's model is rotation around a single point, or rotation around another polygon's vertex each time -Talcall

Header Section

This section contains a list of 10 offsets (4 bytes each). Offsets are from the start of this section, not the start of the file.

BATTLE.BIN contains a table of offsets to where the section is in the effect file.

RAM offset to header = BATTLE.BIN location [0x0014D8D0 + (effect_id * 4)] (as uint32)

Local file offset for each effect file = RAM offset - 0x081c2500


For ID 0x155, the table location is: 0x155 * 4 + 0x801b48d0 = 0x801b4e24

The value at 0x801b4e24 is 0x801c3cfc, the RAM location where the header data starts.

Effect files are loaded into RAM at 0x801c2500, so this results in a file offset of 0x801c3cfc - 0x801c2500 = 0x17FC.


Offset Section
0x00 Frames Section (Always 0x28)
0x04 Animation/Motion Section
0x08 Effect Script Section
0x0C Emitter Motion and Control Section
0x10 Coordinate/Direction Data? Section
0x14 ? (Optional) In some effects its the same number repeated
0x18 Misc Timer Data and Camera Section Header
0x1C Misc Timer Data and Camera Section
0x20 Sound Effect Section
0x24 Palette and Image Section

Frames Section

Section 1: List of Frame Set Offsets

First 4 bytes: Number of half-words before frame offsets start. First of these half words is always(?) this number * 2, ex. the first 6 bytes are frequency 01 00 00 00 02 00

After that first word and half-words, each halfword (uint16) + 4 is an offset to each frame set. A frame set may have multiple frames.


Section 2: Frame Data, repeated for each frame

Each frame data section is 0x18 bytes long, except the first frame of each frame set which has an extra 4 bytes at the beginning relating to VRAM (ie. the first frame is 0x1c bytes long).

1st Frame first 4 bytes - VRAM 1 (Only exists for first frame of frame set) - If the leftmost bit (0x80) of the first byte is 0, the image color depth is 4bpp, otherwise the image is 8bpp.

 VRAM 1 byte 0x02 - how many frames in the frame set
   
 VRAM byte 0x00 bitflags:
   0x0F - Palette for 4bpp images?
   0x60 - semi-transparency mode? (see P00 GetTPage)
   0x80 - image color depth: 1 = 8bpp, 0 = 4bpp?
   
 VRAM byte 0x01 bitflags:
   0x02 - semi-transparency mode on/off for whole quad/polygon? Only off for some frames for Summons, meteor, a few geomancy (pitfall, carve model, local quake), small bomb, and empty 8x8 black squares on others
   0x10 - frame width is a signed value?
   0x20 - frame height is a signed value?
Offset Data
0x00 VRAM 2
0x04 Load Location Top Left X (unsigned)
0x05 Load Location Top Left Y (unsigned)
0x06 UV Width (pixels) (signed or unsigned) - A negative value will result in image being flipped left/right?
0x07 UV Height (pixels) (signed or unsigned) - A negative value will result in image being flipped up/down?
0x08 Display Top Left X (signed)
0x0a Display Top Left Y (signed)
0x0c Display Top Right X (signed)
0x0e Display Top Right Y (signed)
0x10 Display Bottom Left X (signed)
0x12 Display Bottom Left Y (signed)
0x14 Display Bottom Right X (signed)
0x16 Display Bottom Right Y (signed)

Choto's Effect Editor calculates rotation based on display top_left to top_right

Animation/Motion Section

Includes composite frame selection, density/number, and duration.

There will be multiple paremeters in between, but most seem to have the same function. Each different "motion" of an effect will have its own set.

This section starts with a unint32 defining How many parameter sets there are 'N'.

Followed by N offsets (unit16 each) to each paramter set.

Animation Parameter Sets

Each parameter set begins with 0x82 followed by X and Y screen space offset (uint16 each).

Followed by M sets of 3 bytes

0x00 - composite frame id taken from Frame Data or indicates special function if 0x80 bitflag is set (see below)
0x01 - Duration (frames).
0x02 - seemingly irrelevant? related to z coordinate pointer? frequently 0x00 or 0x01.
  0x00 - = Z / 4 (used in Stasis Sword E163 and Ice E024)
  0x01 - = Z / 4 - 8 (very common)
  0x02 - = 8 (used in Odin E072)
  0x03 - = 0x017e
  0x04 - = 0x10 (used in Titan E068)
  0x05 - = Z / 4 - 0x10

Ends with 0x81.

See Composite_frame_loading_for_parameter_sets for details on 0x81, 0x82, and 0x83 special functions (starts at 001aa2d8) and for details on byte 0x02 when loading a new frame (starting at 001aa524 and 001aa6a4).

0x82 sets screen space position offset of animation to XX XX, YY YY
0x83 moves screen space position of animation by XX, YY (signed bytes)
0x81 ends animation, resets counter to 0

Palette is decided by parameter set.


The following data is an example of one of the parameter sets from Cure: E001.bin

Effects moving around spiral:

0x08 (0x1fc)

82 00 00 00 00 - XX XX and YY YY offset

00 14 01 ---- the second byte of these two parameters seems to have a big control on the effect

01 02 01 ----- This is the big sparkle in cure that doesn't go away till the end.

00 00 01 81

Effect Script Section

A series of instructions that tell the effect how to animate.

Has 3 types of sections: Starting Section, Loop Section, and Ending Section. There may be a second Loop Section and Ending Section if effect is multi-target.

Script instructions are defined by 1 ID byte + additional bytes for data/parameters

See BATTLE.BIN_Routines#Effect.2C_Projectile.2C_.26_Particle_Handling starting at 001a2238 for routines.

ID Byte Total Bytes Description
0x00 4 Jump (unconditional)
0x04 2 End Effect
0x05 2 Begin Effect
0x06 4 Setup Custom Routine Pointer
0x16 6 Decision branch?
0x1d 4 Conditional branch (Timing, duration?)
0x1e 4 Conditional branch (multi-target?)
0x1f 4 Conditional branch (based on hit counter)?
0x25 2 Effect processing (advance frame)?
0x27 2 Store motion data?
0x28 2 Graphics (timing?)
0x29 4 Graphics (multi-target?), can branch
0x2a 2 Clear temp data?

Emitter Motion and Control Section

Emitter Control Section Header

20 (0x14) bytes long

0x02: Number of emitters
0x04: ?

Emitter Motion and Control Section

Each emitter has 196 (0xC4) bytes of data

0x00 always 0?
0x01 number of parameter set, animation index?
0x02 Type of motion?
  0x00 - ??
  0x02 - ?? (used in Chakra)
  0x60 - affects emitter moving to/from caster/target??
  0x80 - ??
0x03 Flag for animation target:
  0x01 - bitflag?? (used in Fort Zeakden Strong Explosion)
  0x02 - targeted panel
  0x04 - on/over source unit
  0x06 - each target unit?
  0x07 - each target unit?? (used in Throw Spirit)
  0x08 - somewhere very low?? (used in Throw Spirit, Cure)
  0x09 - ?? (used in Triple Thunder, Fort Zeakden Strong Explosion)
  0x0A - ?? (used in Fort Zeakden Strong Explosion)
  0x0B - ?? (used in Fort Zeakden Strong Explosion)
  0x26 - ?? (used in Truth and Un-Truth abilities)
0x04 ? Crashed game?
0x06 Color masking/motion flags?
  0x04 - flag to show particle trail during movement? (used in Throw Spirit)
  0x10 - particles move radially?
  0x20 - ??
  0x40 - sets color?
  0x80 - ??
0x07 ??
  0x01 end emitter at target position? (used in Throw Spirit)
0x08 through 0x0f Special Functions that use below data

Coordinate Data Section

Coordinate stuff for main motion tweens?

goes by each nibble. each nibble corresponds to different additional data in the emitter's section)

0x10 - color masking?

0x14 - X coordinate to start effect
0x16 - Y coordinate to start effect
0x18 - upper right/lower left displacement

0x1A - Target Z? coordinate for end of effect
0x1C - Target Y coordinate for end of effect (spot it moves to )
0x1E - Target X? coordinate for end of effect 

0x20 - upper left/lower right spread
0x22 - vertical spread
0x24 - upper right/lower left spread
0x26 - horizontal spread

0x2D - 0x0F - direction of motion ( follows like a clock, 00 is 6 o clock, 08 is 12 o clock, 04 is 3 o clock) 

0x2c - 
0x30 - direction of motion? tied to 

0x32 - 
0x36

0x34 - Randomness?
0x36 - Randomness?
0x38 - Randomness?
0x3A - Randomness?

Linked (0x0a)
0x44
0x46 
0x48
0x4a


0x4c 
0x4e
0x50
0x52

Linked (0x0b)
0x54 -
0x56
0x58
0x5a

0x5C - controlled vertical motion upward
0x5E - also controleed vertical motion upward

0x0C linked - low nibble
64
66
68
6a
6c
6e
70
72
74
76
78
7a

0x0c linked - high nibble
7c
7e
80
82
84
86
88
8a
8c
8e
90
92


Fade of effect? - each half based on time (0x0c dependent)
0x94 - fade of effect?
0x96 -
0x98 -
0x9a -

0x0c dependent
0x9c - directional deviation from target (?? direction)
0x9e - directional deviation from target (Z direction?)
0xa0 - directional deviation from target (?? direction)
0xa2

0xb0 - controlled number of particles
0xb2

dependent on 0x0f (halves)
0xb4 - also controlled number of particles (multiplied by a ton for 1, then tapered out with higher values)
0xb6 - b6-b4

0x0c dependent
0xb8 - controls speed of propogation for motion effect (early)
0xba
0xbC - controls speed of propogation for motion effect (late)
0xbe

0xc0

Coordinate/Direction Data

Each section controls a direction for the effect? Starts with 0F 00 00 00. Always 0x964 total length?

0xf sections, each 0xA0 long. Some sections may not be used and will only be 0s.

1st subsection: 0x3c long, controls horizontal movement
2nd subsection: 0x3c long, ????
3rd subsection: 0x28 long, ????
4th section: 0x2a-?? long, controls vertical movement

not sure what the other sections control. I'm assuming it controls movement of the other sets of frames.

Misc Timer Data and Camera Section

Section is 0x18a0 long

Effect_code_script_28_-_huge_big_ol'_routine uses a lot of this data

Misc Timer Data and Camera Section Header

0x18 long

0x00 - effect type? loaded as word
  0x08 bitflag - used as r4 parameter in Get Effect Screen Location Data From Unit Data
0x04 - effect type? frequently 00 00 00 00
0x08 - effect type? frequently 00 01 00 00
0x0c - ? 00 02 00 00 in every effect?
0x10 - ? 00 03 00 00 in every effect?
0x14 - ? 00 04 00 00 in every effect?

Misc Timer Data and Camera Sections

initial data, 0x0C long

0x00 - ?
0x02 - ? used in Effect_code_script_1E_-_check_all_timing_bytes
0x04 - Time taken before effect display 
0x06 - Time in between target switching 
0x08 - ?
0x0a - Effect duration? (cuts effect off if set too low)

0x0c: Start of individual emitter timing sections (0x80 each), always 5 sections?

0x00 though 0x19? - up to 0x10? times (frames) until start and end of emitter? uint16 each. Always starts with 0x0000? Frequently ends with 0x256, 0x257, 0x258, or 0x259. Does 0x200 indicate a special function? Effects that show post action display for each target, but vfx only once (ex. Summons, Draw Out, Ice 4, etc.) seem to only use the special codes except for the post action display timing. Fort Zeakden Strong Explosion uses 0x256
0x20 through 0x31 - ??
0x32 through 0x42? - Emitter id (1 indexed) to display at the corresponding time index?

0x4c\ Control display timing for damage/status/transformation/target animation
0x50/ 0x0000 - none
      0x0007 - ???
      0x0010 - runs post action display
      0x0020 - sprite/transformation/status
      0x0040 - set target animation based on attack
      0xFF00 - store animation/facing
0x7e - number of uint16 'times' stored starting at 0x00 in emitter timing section. This value * 2 = offset to first special value of 0x0257, 0x0258, 0x0259, etc.?

0x28c: start of sound effect section, 0x34 long for sound effect sections?

0x00 - Start time of sound effect


0xC8 long section for forground color tinting and recovery or sprite flash? 0x130 long section for background tint/flash section?

Code script 29 001a4838_-_001a4c40 uses the following timing data bytes:

0x082a, 0x0aaa - used as r5 in Effect_Related_(0x1a4000)
0x0dde, 0x1162 - used as r4 in 001a41a0_-_001a4368
0x0ea6, 0x122a - used as r4 in 001a436c_-_001a4448
0x0f6e, 0x12f2 - used as r4 in 001a444c_-_001a45c4
0x1036, 0x13ba - used as r4 in 001a45c8_-_001a4788
0x0d2a, 0x0d48, 0x0d66, 0x0d84, 0x0da2, 0x0dc0 - used as r4 in 001a478c_-_001a4834


Sound Timing Section

Starts at 0x28c within Misc. Timing Section?

0x34 long?

value of 0x0243 is special function?

??


Color Shifting Sections

Starts at 0x32c in Misc Timing Section

There are three sections 0xc8 long and 1 section 0x130 long


Camera Control Sections

Starts at 0x6b4 within Misc Timing Section? 0x178 bytes long

0x00 - 0x20? - timing for each camera script

0x26 - vertical tilt
0x2a - camera face tilt left

0x48 - vertical map rotation
0x4a - horizontal map rotation

0xF2 - parameters for zoom functions start?

0xF8 - Zoom Parameters - X, Y, and Z parameters
	0x00 - 
	0x02 -
	0x04 -


0x154 - 0x174? - Camera control scripts
 0xC704 - stop camera rotation?
 0x4404 - zoom change?
 0x2104 - change tilt?
 0x04xx - huge zoom out?
 0x0304 - focus on target
 0x0204 - focus on target
 0x0104 - rotate battlefield

bitwise-and with 0x01e0 with each value (2 bytes) at the following offsets

0x0806 - 1 value

0x168a - 2 values (after the first 2 bytes that are zero)

0x185a - 2 values (after the first 2 bytes that are zero)


Command based on result:

0x01c0 Rotate (or center) toward target panel?

0x0140 Rotate (or center) toward source unit?

0x0100 Rotate (or center) back to original point?


Global Sound Effects Timing Sections

Starts at 0xD28 in Misc Timing Section

Six sections, each 0x1e long. For Global Sound Effects?

More Sections 0xC8 long

Starts at 0xddc within Misc Timing Section Full screen color shifting?

Sound Effect Section

0x00 - word of some header
0x04 - Length of sound effect section
0x08 - number of ?? bytes before first sound?
0x0a - ???
0x0C - ???
0x10 - ???

0x18 - start of offsets (uint16 each) to each sound effect section

3 bytes - 50 54 54

Sound Effect Sections

0x00 - ?
0x04 - length of sound effect section starting from previous line

Palette Section and Image Data

512 colors, 2 bytes per color.

If the image is 8bpp, the first set of 256 colors is used.

If the image is 4bpp, the second set of 256 colors is used (16 palettes of 16 colors each).

The unused color data will be all zeros.

The image format is defined within the Frames section of the file.


Image data

Starts 1024 bytes after the start of palette data. The first 4 bytes identify the dimensions of the image. 4bpp images are 256 pixels wide while 8bpp images are 128 pixels wide (unless it is identified as a full 256 x 256 sheet)

0x01 Height of image / 2, unless the image is a full 8bpp 256 x 256 sheet.

Examples of dimensions:

E001 - 00 80 00 00 - 8bpp - 128 x 256

E004 - 00 00 01 01 - 8bpp - 256 x 256

E016 - 00 3c 00 00 - 8bpp - 128 x 120

E341 - 00 40 00 00 - 8bpp - 128 x 128

E343 - 00 40 00 00 - 4bpp - 256 x 128

E356 - 00 20 00 00 - 4bpp - 256 x 64

E398 - 00 80 00 00 - 4bpp - 256 x 256


0x04 Start of pixel color data. May be 8bpp format (each full byte is color index in palette), or 4bpp Multi-CLUT (each half-byte is color index in palette)


Related Routines

https://ffhacktics.com/wiki/BATTLE.BIN_Routines#Effect.2C_Projectile.2C_.26_Particle_Handling

Effect_Graphics

Effect_Related_(0x1a4000)