Format reference/end06: Difference between revisions

From Touhou Patch Center
Jump to navigation Jump to search
(Reordered the instructions according to the order seen in th06 through th08 switch cases (baVvFRmMscrw0123z). Th09 uses a slightly different order (bzaVvFRmMsc0123rw).)
m (Use a template for (N/a))
Line 9: Line 9:
! (empty)
! (empty)
! display
! display
| String || style="text-align:center;color:gray;font-size:smaller" | (N/a) || style="text-align:center;color:gray;font-size:smaller" | (N/a) || Display a line of text.
| String || {{/na}} || {{/na}} || Display a line of text.
|-
|-
! @b
! @b
! background
! background
| .jpg file || style="text-align:center;color:gray;font-size:smaller" | (N/a) || style="text-align:center;color:gray;font-size:smaller" | (N/a) || Displays the given file as background.
| .jpg file || {{/na}} || {{/na}} || Displays the given file as background.
|-
|-
! @a
! @a
Line 21: Line 21:
! @V
! @V
! scrollbg
! scrollbg
| Distance in pixels || Duration in frames || style="text-align:center;color:gray;font-size:smaller" | (N/a) || Scrolls background up (i.e. the image moves downward)
| Distance in pixels || Duration in frames || {{/na}} || Scrolls background up (i.e. the image moves downward)
|-
|-
! @v
! @v
! setscroll
! setscroll
| Vertical coordinate of the new top border of the image || style="text-align:center;color:gray;font-size:smaller" | (N/a) || style="text-align:center;color:gray;font-size:smaller" | (N/a) || Sets the background vertical scroll position
| Vertical coordinate of the new top border of the image || {{/na}} || {{/na}} || Sets the background vertical scroll position
|-
|-
! @F
! @F
! exec
! exec
| .end file || style="text-align:center;color:gray;font-size:smaller" | (N/a) || style="text-align:center;color:gray;font-size:smaller" | (N/a) || Executes the ending script in the given file. This file is re-loaded from the archive.
| .end file || {{/na}} || {{/na}} || Executes the ending script in the given file. This file is re-loaded from the archive.
|-
|-
! @R
! @R
! staffroll
! staffroll
| Empty string? || style="text-align:center;color:gray;font-size:smaller" | (N/a) || style="text-align:center;color:gray;font-size:smaller" | (N/a) || Unknown. Usually present at the beggining of staff .end files
| Empty string? || {{/na}} || {{/na}} || Unknown. Usually present at the beggining of staff .end files
|-
|-
! @m
! @m
! musicplay
! musicplay
| .mid file<sup>3</sup> || style="text-align:center;color:gray;font-size:smaller" | (N/a) || style="text-align:center;color:gray;font-size:smaller" | (N/a) || Loads the given BGM and restarts playback.
| .mid file<sup>3</sup> || {{/na}} || {{/na}} || Loads the given BGM and restarts playback.
|-
|-
! @M
! @M
! musicfade
! musicfade
| Fade-out duration in seconds || style="text-align:center;color:gray;font-size:smaller" | (N/a) || style="text-align:center;color:gray;font-size:smaller" | (N/a) || Fades out BGM.
| Fade-out duration in seconds || {{/na}} || {{/na}} || Fades out BGM.


Passing 0 will stop playback immediately - active MIDI notes are ''not'' stopped in this case.
Passing 0 will stop playback immediately - active MIDI notes are ''not'' stopped in this case.
Line 47: Line 47:
! @s
! @s
! setdelay
! setdelay
| Frames to wait after displaying line 2 and beyond || Frames to wait after displaying the top line || style="text-align:center;color:gray;font-size:smaller" | (N/a) || Set line delays.
| Frames to wait after displaying line 2 and beyond || Frames to wait after displaying the top line || {{/na}} || Set line delays.


When holding the <code>Skip</code> key, parameter 1 is applied for every line.
When holding the <code>Skip</code> key, parameter 1 is applied for every line.
Line 56: Line 56:


e.g. <code style="color:#9370d8;">#9370d8</code> → d87093 → 14184595
e.g. <code style="color:#9370d8;">#9370d8</code> → d87093 → 14184595
| style="text-align:center;color:gray;font-size:smaller" | (N/a) || style="text-align:center;color:gray;font-size:smaller" | (N/a) || Changes the text color.
| {{/na}} || {{/na}} || Changes the text color.
|-
|-
! @r
! @r
! waitreset
! waitreset
| Maximum frames || Minimum frames || style="text-align:center;color:gray;font-size:smaller" | (N/a) || Same as <code>@w</code>, but resets text display after wait.
| Maximum frames || Minimum frames || {{/na}} || Same as <code>@w</code>, but resets text display after wait.
|-
|-
! @w
! @w
! wait
! wait
| Maximum frames || Minimum frames || style="text-align:center;color:gray;font-size:smaller" | (N/a) || Waits for input and pauses script execution.
| Maximum frames || Minimum frames || {{/na}} || Waits for input and pauses script execution.


Parameter 2 is ignored if larger than parameter 1.
Parameter 2 is ignored if larger than parameter 1.
|-
|-
! @0
! @0
! style="text-align:center;color:gray;font-size:smaller" | (N/a)
! {{/na}}
| Frames || style="text-align:center;color:gray;font-size:smaller" | (N/a) || style="text-align:center;color:gray;font-size:smaller" | (N/a) || Unused
| Frames || {{/na}} || {{/na}} || Unused
|-
|-
! @1
! @1
! style="text-align:center;color:gray;font-size:smaller" | (N/a)
! {{/na}}
| Frames || style="text-align:center;color:gray;font-size:smaller" | (N/a) || style="text-align:center;color:gray;font-size:smaller" | (N/a) || Unused
| Frames || {{/na}} || {{/na}} || Unused
|-
|-
! @2
! @2
! fadein
! fadein
| Frames || style="text-align:center;color:gray;font-size:smaller" | (N/a) || style="text-align:center;color:gray;font-size:smaller" | (N/a) || Displays a white quad on top of the screen and fade it out in the given time.
| Frames || {{/na}} || {{/na}} || Displays a white quad on top of the screen and fade it out in the given time.
|-
|-
! @3
! @3
! fadeout
! fadeout
| Frames || style="text-align:center;color:gray;font-size:smaller" | (N/a) || style="text-align:center;color:gray;font-size:smaller" | (N/a) || Fades the screen to white.
| Frames || {{/na}} || {{/na}} || Fades the screen to white.
|-
|-
! @z
! @z
! end
! end
| style="text-align:center;color:gray;font-size:smaller" | (N/a) || style="text-align:center;color:gray;font-size:smaller" | (N/a) || style="text-align:center;color:gray;font-size:smaller" | (N/a) || Ends script execution. Not calling this at the end will cause the game to crash!
| {{/na}} || {{/na}} || {{/na}} || Ends script execution. Not calling this at the end will cause the game to crash!
|}
|}



Revision as of 13:36, 1 September 2019

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.