Repository navigation
feat: complete the BIOS for EmulatorJS - #1
Merged
Merged
Conversation
Fill the disk, file count, disk info, keyboard, and object stubs. Fix save and verify, VRAM loads, error unwinding, write mode, soft reset, and the A value GetHardCodedPointers passes in $02.
Start each written block with the $80 mark and rewrite $4025 for every written byte. FCEUmm, the EmulatorJS NES core, drops the first byte of a block and only signals the next byte to write after a $4025 write.
A byte written to $4024 leaves at the next byte event, so EndOfBlkWrite waits one more event before sending the CRC, then waits out the CRC with a delay because drives raise no IRQs during it. The write loop is inlined to stay ahead of the disk.
Games call VRAMStructWrite, WriteVRAMBuffers, and LoadTileset from their NMI handlers, so these routines must only touch the zero page bytes listed in their Affects lines. They used $02-$06 as scratch, which corrupted Zelda's state. They now keep the pointer in $00/$01 and use the stack.
The BIOS turned NMIs on at a random point in the frame, then jumped to the game. An NMI could fire before the game finished its setup, which crashed Zelda. The BIOS now waits for a vblank first, giving the game a whole frame before its first NMI. NMIs stay on at handoff because Metroid expects them.
The simulator now clears the vblank flag at the end of vblank, stops a transfer when it is reset, and has a controller on $4016.
The error path popped the API's return address with PLP, so the flags took its high byte ($E2 or $E3), which has Z set. Callers that check BNE after LoadFiles or WriteFile took a missing or write-protected disk as success.
VINTWait returns with IRQs masked, so games started with I set after the handoff change. Cold boots start with I clear again.
brandonocasey
commented
Nov 3, 2026
Author
|
✅ Nothing to fix at 5 🧪 QA checks · 3 🔍 closed findings
|
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.
FreeDiskSysROM stopped with most disk routines missing, and the yeah4578 fork filled in many of them but could not load or save reliably. This completes every BIOS entry point so the ROM can ship as
disksys.romfor EmulatorJS, and credits both original authors.GetHardCodedPointerspasses in$02.$80mark, its last byte goes out before the CRC, and every written byte rewrites$4025.tests/test_bios.py, 54 tests) that run the ROM against a real-timing drive and a model of FCEUmm's drive, plus CI that builds and tests the ROM and attachesdisksys.rom.tests/make_demo_disk.py) boots and prints text through BIOS routines in EmulatorJS with this ROM; without a BIOS, EmulatorJS falls back to the RetroArch menu.BNEmissed them.UploadObjecttreats its OAM index as a byte offset, which the docs leave unclear. There is no license screen check, and failed reads and writes are not retried.