Crate wafel_api

Source
Expand description

The main SM64 API for Wafel.

This crate provides two simulation APIs: Game and Timeline.

  • The Game API uses a traditional frame advance / save state model.

  • The Timeline API is higher level and manages save states internally. It allows accessing arbitrary frames in any order. This is the API used by the Wafel application for its rewind functionality.

For now, I recommend using the Game API for brute forcing purposes. The Timeline API works, but the algorithm is currently optimized for Wafel’s UI, so it may not be as fast in a brute forcing setting.

The Emu API attaches to a running emulator and allows reading/writing to its process memory. Similarly, the RemoteDll API attaches to a running instance of libsm64 in another process.

§Data paths

Many API methods take in a string path parameter. This string uses a C-like syntax to denote a location in memory.

The following are all valid syntax:

  • gMarioState.pos
  • gObjectPool[12].oPosX
  • gMarioState[0].wall?.normal
  • gMarioState.action & ACT_ID_MASK

Note:

  • p.x automatically dereferences a pointer p. The syntax p->x can also be used.
  • * is not used for pointer dereferencing. Instead you can use [0], ->, or ..
  • A mask can be applied using &. The mask must be an integer literal or constant name.
  • Array indices must be an integer literal or constant name.
  • ? denotes that a pointer may be null. If so, the entire expression returns Value::None. If ? is not used, an error is thrown instead.

Variable and constant names are automatically pulled from the decomp source code. However, the names may be different if Wafel is out of date from decomp.

Object fields such as oPosX are supported and can be accessed using the regular . syntax.

Structs§

  • A raw pointer value that can be stored in memory.
  • An SM64 API that attaches to a running emulator and can read/write to its memory.
  • An SM64 API that uses a traditional frame advance / save state model.
  • A set of inputs for a given frame.
  • Metadata for a .m64 TAS.
  • Hitbox information for an SM64 object.
  • An SM64 API that attaches to a running instance of libsm64 in a different process and can read/write to its memory.
  • A save state used by Game.
  • An SM64 surface (currently missing several fields).
  • An SM64 API that allows reads and writes to arbitrary frames without frame advance or save states.

Enums§

Functions§

Type Aliases§