Repository navigation
Conversation
Every cheat file a player adds is kept as one Mistel Native Cheat Format file (.mncf) for all of a game's builds. An Atmosphère, Eden, Yuzu or Ryujinx file is converted as it is added, with the game's own main from the pack: each patch names the original code at its place, and its place is found by a pattern, so a cheat keeps working after a game update and never writes into code that is not what it was made for. A cheat that cannot work here says why, in a sentence. - MncfBuild: a file made ready for the build that runs (Mistel's evaluator), kept per build, and written as Atmosphère code for the host's cheat engine, so the engine is unchanged. - MncfConvert: Atmosphère to .mncf with the game, the versions, the origin and the authors (the credits, else the player who adds it). - MncfMain: the game's own main from a pack (main.patched.bin with main.orig.bin back at main.changed.tsv's runs). - .mncf and .mncp files are added as they are; a signature stays good, and only a verified one gets a mark. - A value of an .mncf cheat (a number in an instruction too) gets the in-game number field; relations (requires, excludes, radio) apply. - Export writes .mncf (one source) or .mncp (several), with the cheats that are on and the numbers set. - Mistel's MIT library is copied unchanged under io/github/davdxpx/mistel (peanuts/scripts/mncf-vendor.sh, checked by test_mncf_vendor.py).
…it brings - Export sits in the bar beside Add on the Cheats tab, on the game page's Mods & Cheats area and on its own page, while there is a source to export. - The Add dialog of an .mncf opens with a card for the file (its name, who made it, who signed it when a trusted key did) and what the file brings, counted from it: its cheats and versions, the ones checked before they write, the ones that follow game updates, the numbers to set, the ones that say what they do. - An Atmosphère pick says it becomes a Mistel cheat file, and the wait while it is converted says what is being done. - After adding, a sheet says how many of the cheats work on the game's version, how many cannot (listed with the reason), and what the file brings, in place of a toast.
…owned upstream-update.sh --check flagged every hunk of the mod menu's CheatLoaderJvmTest (android/app/src/jvmtest/java/dev/peanuts) and of ModCheats.java (a Peanuts file in upstream's launcher package) since Part C. The JVM tests of dev.peanuts join the owned paths, as dev/peanuts does under main; ModCheats.java goes on the allow-list with its reason.
… the overlay check
…hat Peanuts cannot run yet The copy is of Mistel's branch mncf-1-peanuts-gaps (9280c89), the fixes of the gaps this PR found; mncf-vendor.sh copies it from Mistel's main once igawa6#11 is merged. - The evaluator refuses what Peanuts' engine lacks with the spec's runtime:unsupported:<part> (run once or for a time, toggle buttons, several conditions, ...), and a patch over a run Peanuts' rewriter changed with runtime:rewritten, so MncfBuild no longer checks those itself. - The converter reads notes, EdiZon's sections and two builds of one version itself, so MncfConvert passes each Atmosphère file as it is. - A number set in the game's tab reaches toAtmosphere as the player's value, checked: one a cheat cannot take leaves only that cheat out.
…e before the game is built is kept - A source whose file is not made ready for the build yet, or cannot be read, may name no other build: its line said "For another version" with the first of none, and the page closed. It now says what it is. - A file made ready while the pack has no main yet (a game not built) was not kept, so the page looked it up again on every redraw and stayed at "Looking up its cheats". It is kept now, marked, and made again once the pack has its main, so its patterns are searched then.
…ther emulator reads Export opens one dialog with two ways the cheats leave Peanuts: - Mistel cheat file, with a Recommended badge and picked: one .mncf (an .mncp for several sources) with every cheat for every version, the ones that are on and the numbers set, as before. - ZIP for other emulators: atmosphere/contents/<title ID>/cheats/<build ID>.txt, one file for each version, as Atmosphere, Eden, Yuzu and Ryujinx read them (MncfExport.zip). Each cheat is lowered with Mistel's toAtmosphere for every build its file names, and for the running build from the file made ready for it: the code Peanuts runs, else the file's own code for the build, else code made from its operations, with the number set in the game's tab. One master code a file, the groups between EdiZon's section markers, at most 127 cheats. What an Atmosphere file cannot hold (a monitor, toggle buttons, a run once or for a time, several conditions, a place found by a pattern in a version whose main Peanuts does not have) and what does not fit the game stay out. Picking the ZIP shows, before anything is written, how many cheats go in for which version and which stay out, each with its reason. CheatLoaderJvmTest: the ZIP's layout, its master, number and sections, what stays out and why, two builds, and the round trip: the ZIP added again gives the same cheats with the same code and groups.
…inst the game's main, with stable reasons The library is now davdxpx/mistel#11 at 797d095: toAtmosphereAll writes every build of a file, and with a build's main it finds the patterns and checks every patch and override stub against expect before writing, and Export.reasons() gives each cheat left out a stable reason (spec section 15). - MncfExport.zip lowers each source with toAtmosphereAll and gives it the game's own main for the build that runs, so a cheat whose place holds other code stays out of the ZIP (expect-mismatch); a build the game runs that the file does not name is written from the patterns with that main. - The dialog's list of what stays out words those reasons, never shows them. - MncfBuild reads the converter's codes instead of its English sentences, and maps them to Peanuts' reasons (runtime:unsupported:<part>, ...). - The dialog's ZIP is the one written, so the game's main is read once. CheatLoaderJvmTest: a patch made for other code stays out with its reason; without the game's main a pattern stays out with its own.
… Atmosphère's limits Mistel's library is copied from its main (76d283c), which has davdxpx/mistel#11 and igawa6#16. - Each source is lowered in one pass: its own raw code for the build first, code made from its operations for a cheat with a number set (the converter's preferCheats). - With the game's main, the pointer at the base of a pointer path is checked too: one past main's end stays out of the ZIP with its reason. - The ZIP keeps Atmosphère's limits across sources, past which a Switch refuses the whole file: one master code of at most 256 words (a master past it stays out, with the cheats of its source that need it), at most 127 entries, group entries counted, less than 64 KB, and names of at most 63 bytes. What goes past them is named in the dialog. - Groups are written as the spec writes them: the group's name as an empty entry, and an entry of only 20000001 where a cheat in no group follows. Where they would cost cheats, the file has no groups. - Peanuts' own engine is not held to Atmosphère's limits: each master keeps its own code, and a source of more than 127 cheats is lowered in parts, so every cheat still runs.
…r names them The one master entry of a file takes the first master's name, and a group entry its group's name as it is, cut only to what Atmosphère keeps (spec section 15).
davdxpx
marked this pull request as ready for review
November 25, 2026 07:41
This was referenced Nov 25, 2026
Fewer stutters from the second start on: what a game needed last time is ready before it starts
#710
Open
…page, and the ZIP words dmnt's size again - A cheat refused for a key the reader does not know is refused before its name is read, so it had no name, and CheatFile.fromMncf crashed the cheats page on it. It is listed by its id now. - Since davdxpx/mistel#17 Mistel's converter keeps dmnt's 64 KB itself and leaves such cheats out with atmosphere:too-big; the ZIP export had no words for that reason and said the Atmosphère file cannot say what the cheat does. CheatLoaderJvmTest's 64 KB check failed with Mistel's main for it.
…eds, shipped like upstream's other third-party code The library for .mncf cheat files was a full copy of Mistel's format/lib/java inside the launcher's own sources. It now sits where upstream keeps other people's code: dm/third_party/mistel/ with Mistel's format/LICENSE, a README and a row in dm/third_party/README.md, compiled with the app by one java.srcDirs line, nothing downloaded at build time. - Only the files the launcher needs, unmodified, from Mistel's main f25485c: 59 of its 64 files. The pass engine (Engine, Pass, Change, Shown) and CheatState are left out, as nothing here reaches them. The patch readers stay, because Mistel's Converter uses them. Mistel's main also brings the update keys of a cheat file (spec section 17), which its reader checks, and keeps dmnt's 64 KB itself (atmosphere:too-big, worded since the last commit). - peanuts/scripts/mncf-vendor.sh copies them from a Mistel checkout: the files MISTEL.sha256 lists, the ones Peanuts' code names, and every file those name in turn (a class a file declares itself is its own). It writes MISTEL.sha256, the README and the row's commit. - peanuts/tests/test_mncf_vendor.py fails when a file is changed, added or taken away. It also checks the MIT notice, the README, the row, the gradle line and the overlay check. With MISTEL set to a Mistel checkout, it compares every file with that commit. - android/NOTICE.md, PEANUTS.md, UPSTREAM-EDITS.md and upstream-update.sh name the new place. test_cheat_loader.py and test_mod_cheats.py compile the library from there.
…ckground, and the page says so The first look at a game after the update made its earlier cheat files .mncf on the main thread: the game's main is read and every cheat's place looked up in it, which took over a minute for Pokémon Legends: Z-A and ended in "Peanuts isn't responding" (an ANR in Mistel's pattern search). - The page, the game page's row and its tile start the conversion on a thread of its own (CheatsPage.convert, beside prepare) and no longer wait for it. - Meanwhile the row says "Making the cheats ready". The source's card shows a progress bar and that it becomes a Mistel cheat file once, after this update. Then the page, or else the game's page, is built again with its cheats. - A start and the page never convert the same files at once: CheatSources.upgrade and migrate take one lock, so a start right after opening the page waits for the page's conversion and finds it done. - A file that cannot be converted is tried again at the next run of the app, not in a loop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Today a cheat file is made for one build of a game. When the game is updated, its cheats either stop or, worse, write the bytes they were made for into places that now hold other code, which can crash the game or break a save. Nothing checks what is there before a cheat writes, a cheat that cannot run gives no reason, and a number inside a code cheat (an amount, a speed) can only be changed by editing hex.
This PR keeps every cheat a player adds as one file of the Mistel Native Cheat Format (
.mncf, an open format under the MIT License, spec). An Atmosphère, Eden, Yuzu or Ryujinx file (a zip, a text file, a folder) is converted as it is added, using the game's own code from the pack. What that gives players:movz) becomes a field in the game's Mods tab, with its range and unit..mncf, or an.mncppack for several sources), keeps every cheat for every version with the ones that are on and the numbers set, so another device starts the same way. Or a ZIP in Atmosphère's folders that every other emulator reads, one cheat file for each version; the dialog says before anything is written which cheats an Atmosphère file cannot hold, and why.Nothing changes in the host's cheat engine (Parts A and B): each file is made ready for the build that runs and handed to the engine as Atmosphère code, word for word the same code where the file has it.
Builds on main 0.1.8, which has the mod menu (#436 to #441), the user saves (#432, #442) and the game page (#445 to #447) this PR extends; the diff shows only its own commits.
1. Adding cheats
.mncf: the file and what it brings.mncfand.mncpbesides.zip,.txtand folders. An.mncfis kept byte for byte, so a signature stays good. Only a file signed by a key Peanuts trusts gets a mark ("Signed by ..."); an unsigned file is shown as any other. Peanuts trusts no key yet..mncfcounts what the file brings from the file itself: its cheats and versions, how many check the code before they write, how many follow game updates, the numbers to set, the ones that say what they do..mncffor all of its builds, with the game, each build's version, where it came from (the zip's name, the site its credits name) and its authors: the people its credits name, else the name of the player who adds it (Settings › Users), else none. Lines of the file that are not code are kept in its description. The wait says what is being done: with a large game, finding each cheat's place in the game's code takes a while (about 30 s for a 97 MB main on the AYN Thor).2. The list and the reasons
touches_saveandmay_crashshow as chips. Switching a cheat on switches on what it requires and off what it cannot be on with (itsexcludesand itsradio), on the page and in the game's tab.3. Export
.mncf, or an.mncpfor several sources, with every cheat for every version, the ones that are on asdefault = trueand the numbers set as their values' defaults.atmosphere/contents/<title ID>/cheats/<build ID>.txt, one file for each version, as Atmosphère, Eden, Yuzu and Ryujinx read them. Each source is lowered with Mistel'sConverter.toAtmosphereAllfor every build its file names, with the game's ownmainfor the build that runs: its patterns are found there, and every patch and override stub is checked againstexpectbefore it is written, so the ZIP never writes over other code. A build the game runs that the file does not name is written from the patterns with thatmain. Each cheat is the file's own code for that build, else code made from its operations, checked as the evaluator checks them, the pointer at the base of a pointer path too; one with a number set in the game's tab is made from its operations with that number, in the same pass as the others (the converter'spreferCheats).mainPeanuts does not have, and a cheat that does not fit the game (its place not found, other code at it). Picking the ZIP shows, before anything is written, how many cheats go in for which version, and calmly how many and which stay out, each with its reason in a sentence, from the converter's stable reason (spec section 15); the Mistel cheat file keeps them. A cheat Peanuts itself cannot run yet but Atmosphère code can say (code Peanuts' rewriter changed, raw code its host does not run) goes in. The ZIP the dialog worked out is the one written, so the game'smainis read once.20000001where a cheat in no group follows, as Mistel's converter writes and reads them; where those entries would cost cheats, the file has no groups. A source's names stay as its file has them, with the source's name after a name an earlier source has already. Whatever does not fit is named in the dialog. Peanuts' own engine is not held to these limits: it runs every cheat of a source, however many.4. In the game
.mncfcheat with one whole-number value gets Part F's field, with the file's range, step and unit; that works for a number in an instruction too. The number is kept for the next start and goes to the running game as before (the merged file's block, then Part B's reload).5. How a file runs
MncfMainreads the game's ownmainfrom the pack:main.patched.binwith the original words ofmain.orig.binback at the runs ofmain.changed.tsv(a pack withoutorig.binkeeps those runs out of every search).MncfBuildmakes a source ready for the build that runs with Mistel's evaluator: each pattern is searched once and the place written into a copy of the file (build/<build ID>.mncfbeside the source), with each cheat's state. A later start, the page and the game's tab read that copy without readingmainagain. The runs Peanuts' rewriter changed are given to the evaluator, which refuses a patch over one (runtime:rewritten, section 11.3) before the game starts.runtime:unsupported:<part>(section 11.1), a monitor withcapability-missing:display, each listed with its reason until Peanuts runs these itself.imported/files, become.mncfat the next start or when the page opens, with the game's main.Mistel's library
format/lib/java, Java 8, no dependencies), copied unchanged intoandroid/app/src/main/java/io/github/davdxpx/mistel/with its MIT notice and the commit it came from (MISTEL.sha256). The copy is of Mistel's main (76d283c), with Converted cheats keep working on new builds, and messy cheat files convert instead of failing davdxpx/mistel#11 and Can't hold controller inputs #16, which close the gaps this PR found in the spec and the library:runtime:unsupported:<part>andruntime:rewrittenin the evaluator, a converter that keeps a source's notes and EdiZon's sections and needs the master code only where a cheat depends on it, and the way back to Atmosphère:toAtmosphereAllfor every build, with the player's values, raw or core chosen for each cheat, checked against a build'smain(a pointer's base too), within Atmosphère's limits, with a stable reason for each cheat left out. Can't hold controller inputs #16 also finds patterns faster where many places look alike.peanuts/scripts/mncf-vendor.shcopies a newer one;peanuts/tests/test_mncf_vendor.pyfails on any change to the copy, so a fix goes to Mistel first. Only Mistel'sformat/folder is MIT; nothing of its GPL tools is here.android/NOTICE.mdnames it.Upstream files
GameActivity.java: inside Part C'sPEANUTS begin/endblock,ModCheats.installgets the game and its pack.android/NOTICE.md: one marked paragraph.peanuts/scripts/upstream-update.sh --checkflagged Part C's two Peanuts files (CheatLoaderJvmTest,ModCheats.java) since Part C: Peanuts' JVM tests underjvmtest/java/dev/peanutscount as Peanuts-owned now, andModCheats.javais onpeanuts/upstream-unmarked.txtwith its reason. All inpeanuts/UPSTREAM-EDITS.md.Tests
peanuts/tests/test_cheat_loader.py(CheatLoaderJvmTest, with the library compiled from the copy):mainwith the original words back, and withoutorig.binthe rewritten runs left out;main; on another build the place moved with the code;mainworks on the next build by its pattern;outside,pattern-not-found,capability-missing:display,runtime:unsupported:run.once,runtime:rewritten) and their words;.mncfvalue (the instruction made again for 300, the range kept, the kept number written at a start);.mncfwith the switches and the number; unchanged bytes when nothing changed; an.mncpwhose manifest reads back), a pack with a changed file, a bare.mncf, another game's, one of another format version;mainholds stays out, so does a pointer whose base lies past its end, and without the game'smaina pattern stays out with its own reason; added again, the ZIP gives the same cheats with the same code and the same groups.peanuts/tests/test_mod_cheats.py,peanuts/tests/test_mncf_vendor.py,peanuts/tests/test_separators.py.peanuts/scripts/check-min-api.pyon the APK: nothing newer than API 33..mncf, 60 of 60 cheats work on 2.0.2, 57 made from their operations with their original code checked against the game'smain, 3 run as their own code;movz) set from 50000 to 50001: kept, the merged file's block made again (movz w8, #50001), the game read the file again, and switched on, 1 code word written;.mncfwith the two cheats that were on asdefault = trueand the number as the value's default; that file added again gave a second source whose cheats were on as exported;.mncf(Example cheats.mncf: 4 of 7 work, 3 cannot with their reasons) and an Atmosphère zip.mainof the build ID): the export dialog (Bild 9 to 11), and a ZIP written through the system's file picker:atmosphere/contents/010093801237C000/cheats/646761F643AFEBB3.txtwith the 4 cheats, "Exported 4 cheats as a ZIP. 3 could not go in." With the library from Mistel's main the same stand-in gives the same 4 cheats and the same 3 reasons (checked on the JVM), so the pictures still hold; its file now has the groups as the spec writes them. A source made ready while the pack had nomainwas made again once it had one.Not in this PR
<mod>/cheats/*.txt) stay as the mod has them.