Expand description
BizHawk .bk2 movie interop.
Import + export of the text payload of a .bk2 archive (the
Header.txt + Input Log.txt members) to and from the native Movie
type. It mirrors the FCEUX crate::movie_interop .fm2 design, with one
structural difference: a .bk2 is a ZIP archive, not a flat text file.
§no_std and the ZIP split
The rustynes-core chip stack is #![no_std] (core + alloc only), so it
does not open or write ZIP containers — that needs std + a zip crate.
Instead, the core handles the part that is no_std-clean and shared across
every frontend: parsing / emitting the two text members. The frontend reads
the two members out of the .bk2 ZIP (and writes them back into one) and
hands their string contents here. The split is the same reason .fm2’s text
parse lives in core while file I/O lives in the frontend.
§The .bk2 text format (the subset we model)
Header.txt—Key Valuelines (space-separated). The keys we read:Platform(must be an NES family token),rerecordCount,Author,GameName,SHA1(stored verbatim; the authoritative SHA-256 ROM identity is supplied separately by the caller, exactly like.fm2’s MD5), and the region flagPAL. AStartsFromSavestate/StartsFromSaveRammovie is rejected (cross-emulator save blobs are not portable — same policy as.fm2).Input Log.txt— a[Input]…[/Input]block. The first line is aLogKey:declaration listing the|-separated controller column groups; subsequent lines are per-frame input, each|-delimited, every button rendered as its mnemonic letter (pressed) or.(released). The first group is the console-buttons group (Reset / Power); then one group per controller port.
§The NES gamepad mnemonic order
BizHawk’s NES standard-controller mnemonics are U D L R S s B A
(Up, Down, Left, Right, Start, select, B, A — note the lower-case s for
Select, distinct from the upper-case S for Start). Any non-./non-space
character in a column means that button is pressed; the column’s position
(not the specific letter) selects the button, so we tolerate either the
canonical mnemonic letter or any other pressed marker.
§Deliberate limitations (mirroring .fm2)
- Standard gamepads, players 1 and 2 only.
FrameInputmodels two ports; extra controller groups are parsed but dropped (their presence is not silently misleading — only P1/P2 are mapped). The console Reset bit is parsed but not represented onFrameInput(it has no reset bit), exactly as in.fm2. - Power-on start only. See above.
This module is no_std-clean: it uses only core + alloc.
Structs§
- Bk2Export
Opts - Options the caller supplies on export that the
Moviedoes not carry. Mirrors the extra header fields surfaced byBk2Metaon import. - Bk2Meta
- Header metadata parsed from a
.bk2that has no home onMovie. - Bk2Text
- The two text members of a
.bk2ZIP, returned byexport_bk2for the frontend to pack into the archive (and accepted byimport_bk2).
Enums§
- Bk2Error
- Errors produced by
.bk2text import / export.
Constants§
- BK2_
HEADER_ MEMBER - The filename of the header member inside a
.bk2ZIP. - BK2_
INPUT_ LOG_ MEMBER - The filename of the input-log member inside a
.bk2ZIP.
Functions§
- export_
bk2 - Serialize a
Movieinto the two text members of a.bk2ZIP. - import_
bk2 - Parse the
Header.txt+Input Log.txttext of a.bk2into aMovieplus the leftover headerBk2Meta.