HSP

From OHRRPGCE-Wiki
Jump to: navigation, search

The .HSP lump is identical to the .HS file imported into an .RPG file, but with a different extension. (HSpeak saves its output as an .HS file, which is given the .HSP extension when imported.)

It is actually a lumped file itself, and is unlumped to PLAYING.TMP upon loading a game. See RPG format#Lump Format for details.

HS[edit]

The lump of filename "HS" contains the header. It is always the first lump in the file so that its filename followed by the length can also be used to identify an HSP/HS file. That is, the first four bytes will be "HS\0\0". The length could change in future, but won't become long enough to change the first four bytes.

Formal Specs[edit]

About Formal Specs

Data Meaning
STR (12) Header text "HamsterSpeak"
INT Compiler major version (currently 3)
STR (2) Compiler minor version, eg "Gd" or "H ". This field is not added by versions earlier than 3H

SCRIPTS.TXT[edit]

This lump is a plain text file and contains the name, id, and number of args of all scripts in the .HSP file. It is processed when a .HS file is imported via custom.exe to produce PLOTSCR.LST

For each script (in any order) this file contains, each on a new line

  • The name of the script
  • The decimal id number of the script
  • The number of arguments of the script
  • For each argument, a number is printed to a line

The list of numbers is nothing but garbage in old versions of HSpeak. Since HSpeak 2I, the numbers are the default arguments of the script, but you need to confirm HSpeak 2I or greater was used before considering using them (they are not used anywhere within the the current engine). 2I was the version that added the script argument number to HSZ lump headers, so you could check the length of the header of any HSZ lump.

walkherotox
32767
2
1
2

The text file ends on a newline.

SCRIPTS.BIN[edit]

Scripts.bin is a replacement for scripts.txt that contains similiar data in a 16-bit binary format, also holds trigger type info. It contains a header and a record for each script, which are in arbitrary order.

Header[edit]

Offset Data Meaning
0 INT Header size in bytes (currently 4)
1 INT Record size in bytes (currently 42)

The header size is read to determine whether the file format is supported; it'll be changed next time the file format changes (which will happen).

Record[edit]

Offset Data Meaning
0 INT Script ID number
1 INT Script trigger type:
-1 = 'subscript'
0 = 'script'
1 = 'plotscript'
2-20 FVSTR(1i+36b=19i) Script name (lowercase, whitespace trimmed)

COMMANDS.BIN[edit]

This lump commands the names of functions defined in define function blocks. It has three parts: header, offset table to find function records, and the function records.

Header[edit]

Offset Data Meaning
0 INT Header size in bytes (currently 6), ie position of the offset table
1 INT File format version (currently 0)
2 INT Number of records in Offset Table

Offset Table[edit]

This is a simple array of 16-bit INTs, indexed by function id number, containing the absolute file position for the record for a function, or 0 if that function id wasn't declared. Always starts at id 0.

Function Record[edit]

Offset Data Meaning
0 INT Number of arguments, or -1 if variable
1+ VSTR(1i+b..) Function name

#.HSX or #.HSZ[edit]

Each script is separately compiled into a binary lump composed of a binary header followed by raw script data. The name of the file is the id number of the script with extension .hsx or .hsz, which are equivalent.

The format of this lump is documented at HSZ

SOURCE.TXT[edit]

This optional lump added by HSpeak 3I to 3Ja inclusive (unless run with the -n option) is just the script source preprocessed to inline included files, except for plotscr.hsd. It is not used by Game or Custom, but purely for backup.

SOURCE.LUMPED[edit]

This is an optional lump added by 3K onwards (unless run with the -n option). It is a lumped file of all the script source files (including plotsrc.hsd), with files renamed to avoid collisions, and newlines changed to LF (Unix).

SRCFILES.TXT[edit]

Wip.png
This article discusses a brand new feature which is not included in the latest stable version, and may not even be in the next stable version. It can, however, be found in a nightly build, which can be found on the Downloads page. If you wish to discuss this feature, feel free to use the talk page.

This optional lump (currently only created by HSpeak if outputting debug info) contains information on the original script files, and in particular is used to map the source markers used in debugging info source markers to files and file positions in source.lumped. It is a text file and all the lines in the file are of the form "tag=data". Unrecognised tags will be ignored. A file tag starts the entry for a new file. Global data may appear before the first file entry (none defined yet). Aside from file the appearance of each tag in a particular file entry is optional.

Tag Meaning
file The original (absolute) path and name of the file.
lump The name of this file as lumped in source.lumped.
offset A value used when decoding a srcpos source marker.
length The length of the file. Required if offset is present.