Repository navigation
Correct what had drifted, name the boards, widen CI, and split the window - #74
Merged
Merged
Conversation
Four numbers had drifted from what the program does. EmulationSpeed said an unpaced loop runs at "around ten times" on the machine this was written on; benchmarked during real gameplay rather than on a title screen -- which draws far fewer sprites and is not representative -- it is four. Super Mario Bros. is 3.9x, Super Mario Bros. 3 is 4.4x, Contra and Mega Man 5 are 4.2x, with no pacing, no frame hashing and no picture drawn. That matters beyond the comment: it means Fast Forward's 8x is above the ceiling and comes out wherever Unlimited does, which is now said out loud. Options.DEFAULT_FRAMES carried the same stale figure from the other end -- 600 frames is two or three seconds of real time rather than "about a second". CLAUDE.md's 3.7ms a frame was already right and agrees with four times, so the two had been contradicting each other. The README contradicted itself twice. "Not there yet: a second player" sat one section below the paragraph describing two players on one keyboard, and the build section counted four modules and then a fifth when there are seven. CLAUDE.md's layout still said mappers 0 to 4, which was true for five of the twelve boards ago. The rest is the javadoc that restates the signature, which is the sweep 0fa6621 started and did not finish: five blocks left, all in core's oldest classes. Cart's said a cart contains PRG-ROM, CHR-ROM and a mapper, which the record components already say; what is worth knowing is that the header is kept beside the mapper rather than thrown away once read, because the two disagree -- ram() is what the header claimed and Mapper.prgRAM() is what the board got, and mapperNumber() parts company with the class of mapper() since 1 and 155 build one class between them. Controller's said it represents a joypad; what is worth knowing is that the interface is shaped like a shift register and a strobe rather than like eight button getters, which is why getButtons() and read() answer differently for most of a frame and why serialize saves one and not the other. InvalidNesFileException listed four bullet points restating its own throw sites; what is worth knowing is where the line between it and its sibling falls, since one means somebody's file is wrong and the other means this emulator is unfinished. And CPU.loadState said it is "primarily for testing purposes", which is true and says nothing: nothing in a running console reaches a state except by running to it, and it is there for the Tom Harte fixtures. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ception A mapper number names a circuit rather than a chip, and there are hundreds of them where this runs twelve, so the number on its own is the least useful half of the answer: somebody told their file wants mapper 69 has to go and look up what 69 is before they know whether it is a famous board, a pirate multicart or a header somebody filled in wrongly. Told it wants Sunsoft FME-7, they already know. So twenty-six boards are named -- not the tail of bootleg conversions nobody loads on purpose, but every one a real release shipped on, which is the set a collection can actually hand this. The names are the ones NESdev's list prints, checked against it rather than written from memory, because a table of wrong board names would be worse than no table. Only unsupported boards are in it. The twelve this runs never reach the exception, and an entry for one of them would be a second place to update when a thirteenth is written. The headless refusal printed the exception object rather than its message, so an unsupported cartridge came back as /tmp/vrc6.nes is not a cartridge this can run: com.github.dimiro1.mynes.UnsupportedMapperException: Mapper 24 is not supported in file: /tmp/vrc6.nes -- the file named twice with a package-qualified class name between them, which is the one part of it nobody running a script can use. It is now the message alone, which already names the file. The framing is kept for the third way Cart.load fails: a truncated image runs the buffer out and whatever the array threw may carry no message at all. Exit 5 is unchanged, since all of these are still one answer to a script. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The README tells somebody on macOS, Windows or Linux to download one zip and run one launcher, and CI proved that on Linux alone. The console is the same bytes on all three -- nothing in mynes-core knows what a file separator is -- so what the second and third runner buy is everything that is not the console: the Swing panels every desktop test builds without a display, the sound card, the config file under a home directory, and the saves filed beside a ROM. Those are exactly the places a Java program still manages to be platform-specific. fail-fast is off, because one runner failing is a fact about that runner and stopping the other two would throw away the thing worth knowing, which is whether it failed everywhere or only there. Two steps stay on Linux for reasons rather than for cost alone. The 1.4GB of Tom Harte fixtures exercise the 6502, which is the one part of this that cannot tell which machine it is running on, so fetching them three times would spend three times the bandwidth on the same answer -- and the committed subset covers every opcode everywhere, which is why that download is allowed to fail at all. The distribution smoke test checks that the launcher came out of the zip still executable, and a file mode is a question about the machine that wrote the zip rather than the one reading it, so Windows has no answer to give and asking it would be a step that either fails for no reason or passes for none. The desktop tests were run here under -Djava.awt.headless=true first, which is the condition a macOS runner presents, and they pass. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…he frame
GameUIFrame was the largest file in the program at 3210 lines and the least
documented of the large ones -- 37% prose against PPU's and EmulatorRunner's
47-49% -- with 134 fields and 91 methods. Three things came out of it, chosen
because each owns a decision that could not be tested while it lived there, and
all three now are. What stayed is wiring, which is long by nature.
BatterySaves is the .sav file. The rule in it is that the file is written when
the game has changed the chip and not otherwise, which needs a memory of its own
-- the shadow copy is the whole reason it is an object rather than three
methods. Its tests are all about a file that should not appear, since a timer
that wrote 8KB every minute of every game would pass any test asking whether
saving works.
SaveSlots is the nine slots and the two quick items. The part with a decision in
it is the labelling: nine numbered items are a guessing game unless each says
what is in it, and that answer comes off the disk every time the menu is pulled
down. Which slot is current stays one setting rather than two, so picking from
either submenu moves both quick keys, and there is now a test that says so.
MachineDescription is the sentence the window says about itself, which it was
saying in three places that each worked it out separately. state() is written
once and the three callers dress it differently -- the status bar as it is, the
title bar in brackets in lower case, the dashboard dropping it where it would
repeat the word already there. A record rather than a describer, so it holds no
reference to the runner or the machine.
Two smaller things came with them. applyCrop and applyTvAspect had written out
the same measure-change-measure-repack arithmetic twice, and the javadoc said so
in prose ("applyCrop down to the arithmetic"); repackAround is that arithmetic
named once, so the comment is now the code. And moving the autosave surfaced a
latent race: the timer read the machine on the event dispatch thread and the
path on the emulation thread, so a cartridge swapped between the two could file
one game's RAM under another's name. Both are read together on the thread that
writes them.
3210 lines to 2933, 1514 lines of code to 1361, 134 fields to 120, and 23 tests
that did not exist. Verified past the test suite by driving the real window
through mynes-shots, which exercises the menus, Quick Load, the title bar and
the packing, and photographs the result: the pictures match the checked-in ones.
The remaining bulk is init(), startMachine and the movie session. Movies thread
pendingMovie through startMachine and read the runner, the cartridge, the codes
and the overclock, so pulling that out would mean passing the frame around,
which is not an improvement; init() is menu construction interleaved with action
wiring, and splitting it means a callback for everything it captures. Both are
worth doing and neither is a defect, so they are left where somebody can decide
about them.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The first thing the new matrix caught, and it is the test rather than the
program. RomHackTests asserted the report's patch path against the string that
went in on the command line, forward slashes and all; the report writes what
Path.toString() gives, which on Windows is src\test\resources\hello-world\
mynes.ips. That is the same path -- Path.of("a/b") on Windows is a\b -- rendered
the way that machine writes one, which is what a report describing a run on a
machine should say, and is what cart.file, the dumps and host.workingDirectory
all already do.
So the fix is to compare through Path, the way HeadlessRunTests and ReplTests
already do at the three other places a path is asserted. Asserting the string
that went in was asserting that the test had been run on a platform whose
separator is a slash, which is a different claim and one nobody wants to make.
The only other hard-coded separator in a test is ArchiveTests' "roms/game.nes",
and that one is right: a zip entry name is forward-slash by the format's own
spec on every platform, which is why mynes-archive passed on Windows.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Windows got past mynes-headless this time and ran mynes-desktop for the first time ever, which turned up three tests that had quietly assumed the machine they were written on. All three are the tests; the program is right in every case. aTabInAPathSurvivesTheRoundTrip said in its own javadoc that "a filename may hold one on every platform this runs on", and that was simply false: Windows forbids a tab in a filename outright, so Path.of refuses the name before any of the escaping is reached. The case cannot arise there, which is a different thing from arising and being mishandled, so it is assumed away with the reason written down rather than worked around. Config still escapes a tab, since what it escapes is a value rather than a filename, and the round trip still runs everywhere a filename can hold one. aSaveWritesEverySection compared the raw text of the properties file against Path.toString(). Properties reads a backslash as an escape, so Config doubles them on the way out -- which is the whole point of the test two above it -- and a Windows path therefore goes into the file doubled and comes out of toString() single. Comparing the two was asserting that the separator is a slash. It now asks what that test is actually for, which is whether the section was written at all; how the value is encoded already has an owner, and one rule wants one. theWindowRemembersWhereItWasAndWhatWasInFront asked a real window for 1200x800 and asserted it got it. A window manager is entitled to clamp a window to the display it is on, and a runner's is smaller than that: it came back 1044x788. currentLayout() reads getBounds(), so the claim worth making is that it reports the window rather than the request -- which is what it now compares against, and which holds on a screen of any size. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
The numbers:
EmulationSpeedclaimed an unpaced loop runs at "around ten times" and it is four — benchmarked during real gameplay rather than on a title screen — which also means Fast Forward's 8x is above the ceiling and lands wherever Unlimited does;Options.DEFAULT_FRAMEScarried the same stale figure from the other end, the README contradicted itself on player two and on the module count, CLAUDE.md still said mappers 0 to 4, and five javadoc blocks still restated their own signatures.The refusals: an unsupported cartridge now names its board —
mapper5.nes wants mapper 5, MMC5, which this does not run.— from a table of twenty-six checked against NESdev's list rather than written from memory, and the headless one prints the message rather than the exception object, which had been putting a package-qualified class name and the filename twice in front of it.CI: macOS and Windows join Linux, since the README hands all three the same zip and only the Linux half was ever proven; the Harte fixtures and the distribution smoke test stay on one runner for reasons given in the workflow.
The window:
GameUIFrame— the largest file in the program and the least documented of the large ones — losesBatterySaves,SaveSlotsandMachineDescription, each chosen because it owned a decision that could not be tested while it lived there, going from 3210 lines to 2933 and 134 fields to 120, with 23 new tests, the duplicated repack arithmetic named once, and a latent autosave race fixed on the way (a cartridge swapped between two reads could file one game's RAM under another's name).2399 tests green, and the split was verified past the suite by driving the real window through
mynes-shots— menus, Quick Load, title bar and packing — whose pictures match the checked-in ones.🤖 Generated with Claude Code