Format reference/end06

From Touhou Patch Center
Revision as of 13:36, 1 September 2019 by Egor (talk | contribs) (Use a template for (N/a))
Jump to navigation Jump to search

This is the ending script format for Touhou 06-09 (Icon th06.png Embodiment of Scarlet Devil, Icon th07.png Perfect Cherry Blossom, Icon th08.png Imperishable Night and Icon th09.png Phantasmagoria of Flower View).

Opcodes

As this is a text-based format, all parameters are given as ASCII strings. Each parameter is terminated with a null byte, each instruction with a line break1.

Opcode Mnemonic2 Parameter 1 Parameter 2 Parameter 3 Description
(empty) display String (N/a) (N/a) Display a line of text.
@b background .jpg file (N/a) (N/a) Displays the given file as background.
@a anm ??? Script index? Sprite index? Execute anm script
@V scrollbg Distance in pixels Duration in frames (N/a) Scrolls background up (i.e. the image moves downward)
@v setscroll Vertical coordinate of the new top border of the image (N/a) (N/a) Sets the background vertical scroll position
@F exec .end file (N/a) (N/a) Executes the ending script in the given file. This file is re-loaded from the archive.
@R staffroll Empty string? (N/a) (N/a) Unknown. Usually present at the beggining of staff .end files
@m musicplay .mid file3 (N/a) (N/a) Loads the given BGM and restarts playback.
@M musicfade Fade-out duration in seconds (N/a) (N/a) Fades out BGM.

Passing 0 will stop playback immediately - active MIDI notes are not stopped in this case.

@s setdelay Frames to wait after displaying line 2 and beyond Frames to wait after displaying the top line (N/a) Set line delays.

When holding the Skip key, parameter 1 is applied for every line.

@c color Color in 24-bit decimal BGR format.

e.g. #9370d8 → d87093 → 14184595

(N/a) (N/a) Changes the text color.
@r waitreset Maximum frames Minimum frames (N/a) Same as @w, but resets text display after wait.
@w wait Maximum frames Minimum frames (N/a) Waits for input and pauses script execution.

Parameter 2 is ignored if larger than parameter 1.

@0 (N/a) Frames (N/a) (N/a) Unused
@1 (N/a) Frames (N/a) (N/a) Unused
@2 fadein Frames (N/a) (N/a) Displays a white quad on top of the screen and fade it out in the given time.
@3 fadeout Frames (N/a) (N/a) Fades the screen to white.
@z end (N/a) (N/a) (N/a) Ends script execution. Not calling this at the end will cause the game to crash!

Limitations

  • Text lines are limited to 64 bytes.
    • Icon th06.png th06: Like all longer text in this game, these are split on the 32th byte and rendered as a left and right half.
  • A maximum of 6 lines can be displayed at once. Everything after that will be invisible, and the 10th line crashes the game.

Patching approach

Firstly, I'd really like to have the layout engine done before doing this. Aligning text and character names with full-width spaces is silly.
Also, EoSD requires its separate beautification treatment.

Each contiguous block of text, delimited by @c, @w or @r, counts as one translation unit/template. Then, we simply replace the entire block with the new translated text.

Line count doesn't matter at all - it's highly unlikely to crash the game, and there's always one additional line available. Empty lines do matter, though.