Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Floppy eject/insert #897

Merged
merged 6 commits into from
Aug 26, 2023
Merged

Floppy eject/insert #897

merged 6 commits into from
Aug 26, 2023

Conversation

JoeOsborn
Copy link
Contributor

This patch implements two new methods on FloppyController, eject_fda and insert_fda. These are not exposed to the UI yet, but from the browser console in debug mode they work for removing and inserting floppies in MS-DOS at least.

Caveats:

  1. FloppyController does not implement the format track command, so you need to give it a pre-formatted disk image.
  2. FloppyController does not seem to emulate all the relevant internal controller state, so I made a best-effort patch here (references: this website , osdev ). I did what I could around reset behavior, extending existing commands, and reporting errors on seeks and reads, but this is pretty far outside my wheelhouse.

So, please see this PR as a request for testing and review towards part of #54 .

@JoeOsborn JoeOsborn changed the title Floppy eject insert Floppy eject/insert Aug 16, 2023
@JoeOsborn
Copy link
Contributor Author

The first failing test is an openbsd floppy test that tests fdb behavior. Arguably the test should never have passed since fdb was never used in floppycontroller.

@copy
Copy link
Owner

copy commented Aug 21, 2023

Thanks! This works pretty well so far. I've left a few comments above, but in general there's nothing major in the way of merging.

A few notes:

  • A couple of tests fail with "Unimplemented floppy command call" (Windows XP, React OS). I'm going to improve the command parser a bit and turn this into a warning (the commands executed by these OSes don't always make sense)
  • Currently the floppy disk is only really tested for OSes that boot from it (plus the one test for MS-DOS hard drive + floppy). It would be nice to survey which existing OSes support the current implementation, and make sure this PR doesn't break any of them. I can take care of that.
  • A test would be nice that demonstrates ejecting/inserting (i.e., boot MS-DOS, run dir A:, insert, run dir A:, eject, run dir A:)

Few stylistic things:

  1. { after function/if/else should go on its own line
  2. Use === and !== over == and !=

src/floppy.js Outdated Show resolved Hide resolved
src/floppy.js Outdated Show resolved Hide resolved
src/floppy.js Outdated Show resolved Hide resolved
src/floppy.js Outdated Show resolved Hide resolved
@JoeOsborn
Copy link
Contributor Author

Thanks for the review. I’ll address the style issues and wrong flag sets, and try to add an automated test using eject and insert.

@JoeOsborn
Copy link
Contributor Author

I ended up adding an “extra_images” config option (and field on V86Starter) so that the starter can download/initialize all the floppies or CDs or whatever that will be necessary. This way it’s easy to code up something to swap disks by name (as I do in the integration tests).

src/browser/starter.js Outdated Show resolved Hide resolved
@JoeOsborn
Copy link
Contributor Author

I've added an async function on V86 to load an image file description as an image description, which I use from run.js. In the future, this could be used to refactor continue_init (( settings["hda"] = this.disk_images["hda"] = await this.load_images(this.disk_images["hda"]); )) and allow for loading all the image files in parallel (using e.g. Promise.all).

@JoeOsborn
Copy link
Contributor Author

I went ahead and slightly refactored continue_init in the way I described, just so we have only one code path for loading image files. I left the put_on_settings function intact and did not use Promise.all since I thought it would complicate the progress bar-related code even more.

@JoeOsborn
Copy link
Contributor Author

Sorry for the spam--if you don't want the last commit, feel free to just use the preceding one and keep the code duplication. I thought adding the async function to load an image would be a smoother, nicer change than exposing v86util or the buffer types as exports of the library, since they kind of feel like implementation details.

@copy
Copy link
Owner

copy commented Aug 25, 2023

I've refactored the tests and buffer loading. Also improved the command parser and implemented port 3F4 reset (for ReactOS and winxp, previously this code was never hit because we didn't run it without a floppy disk).

Will merge when tests pass.

@copy
Copy link
Owner

copy commented Aug 25, 2023

Also pushed another change to expose it in the UI.

@copy copy merged commit 8c04489 into copy:master Aug 26, 2023
2 checks passed
@copy
Copy link
Owner

copy commented Aug 26, 2023

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants