Commit Graph

405 Commits

Author SHA1 Message Date
Will Scullin c6f5c9f504
Fix disable mouse joystick (#180) 2023-02-23 20:29:35 -08:00
Will Scullin eab02bff31
Fix scss linting (#178) 2023-01-31 17:49:07 -08:00
Will Scullin 031c278d57
Rearrange save buttons (#177) 2023-01-29 07:45:36 -08:00
Will Scullin 7a97414e5d
Fix disk format type checks (#176) 2023-01-28 09:06:03 -08:00
Will Scullin d042a5b319
Don't reload already loaded disk (#174) 2023-01-22 18:31:35 -08:00
Will Scullin 9173bff1ba
Switch to scss, better scope rules (#170)
Restrict element types and global styling to improve embedability
2023-01-11 18:14:44 -08:00
Will Scullin 3d59142ee9
audit fix 2022-12-30 19:41:56 -08:00
Will Scullin 4ffc47aa90
Fix build 2022-12-30 19:27:54 -08:00
Will Scullin 6bd550c985
Merge pull request #168 from whscullin/dependabot/npm_and_yarn/qs-and-express-6.11.0
Bump qs and express
2022-12-09 06:14:56 -08:00
dependabot[bot] 76d1f3775f
Bump qs and express
Bumps [qs](https://github.com/ljharb/qs) and [express](https://github.com/expressjs/express). These dependencies needed to be updated together.

Updates `qs` from 6.7.0 to 6.11.0
- [Release notes](https://github.com/ljharb/qs/releases)
- [Changelog](https://github.com/ljharb/qs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ljharb/qs/compare/v6.7.0...v6.11.0)

Updates `express` from 4.17.1 to 4.18.2
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/master/History.md)
- [Commits](https://github.com/expressjs/express/compare/4.17.1...4.18.2)

---
updated-dependencies:
- dependency-name: qs
  dependency-type: indirect
- dependency-name: express
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-09 07:14:22 +00:00
Will Scullin 887f8515e7
Merge pull request #167 from whscullin/dependabot/npm_and_yarn/decode-uri-component-0.2.2
Bump decode-uri-component from 0.2.0 to 0.2.2
2022-12-02 16:40:39 -08:00
dependabot[bot] 5e8da71e5e
Bump decode-uri-component from 0.2.0 to 0.2.2
Bumps [decode-uri-component](https://github.com/SamVerschueren/decode-uri-component) from 0.2.0 to 0.2.2.
- [Release notes](https://github.com/SamVerschueren/decode-uri-component/releases)
- [Commits](https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.2)

---
updated-dependencies:
- dependency-name: decode-uri-component
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-03 00:37:14 +00:00
Will Scullin 2d9968ee09
Merge pull request #166 from whscullin/dependabot/npm_and_yarn/loader-utils-2.0.4
Bump loader-utils from 2.0.0 to 2.0.4
2022-11-15 20:49:23 -06:00
dependabot[bot] a476d7da8e
Bump loader-utils from 2.0.0 to 2.0.4
Bumps [loader-utils](https://github.com/webpack/loader-utils) from 2.0.0 to 2.0.4.
- [Release notes](https://github.com/webpack/loader-utils/releases)
- [Changelog](https://github.com/webpack/loader-utils/blob/v2.0.4/CHANGELOG.md)
- [Commits](https://github.com/webpack/loader-utils/compare/v2.0.0...v2.0.4)

---
updated-dependencies:
- dependency-name: loader-utils
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-15 22:16:27 +00:00
Will Scullin 5bd51d64c5
Merge pull request #163 from iflan/split-drivers-into-files
Split drivers into files
2022-10-01 11:17:12 -07:00
Will Scullin 0be830784a
Merge pull request #161 from iflan/split-out-drivers
Split handling of nibble disks and WOZ disks into separate drivers
2022-10-01 11:16:14 -07:00
Will Scullin 2fcd6a377c
Revert "Minor cleanup (#162)" (#164)
This reverts commit 8c2299e43e.
2022-10-01 11:15:57 -07:00
Ian Flanigan 8c2299e43e
Minor cleanup (#162)
* Split handling of nibble disks and WOZ disks into separate drivers

Before, the `DiskII` object took care of both nibble disks and WOZ
disks at the same time. This made it hard to see which code affected
which disks.

Now, nibble disks are handled by the `NibbleDiskDriver` and WOZ disks
are handled by the `WozDiskDriver`. This separation of code should
lead to easeir testing and, perhaps, faster evolution of disk
handling.

An upcoming change will move the `NibbleDiskDriver` and the
`WozDiskDriver` to separate files.

This passes all tests, compiles, and runs both nibble disks and WOZ
disks.

* Rename drive number fields/variables/parameters to `driveNo`

Before, the naming of fields, variables, and parameters that took
`DriveNumber` was very inconsistent. This changes them all to
`driveNo`.

* Organize imports in `disk2.ts`

The imports were automatically organized using VS Code's organize
imports action.
2022-10-01 11:08:58 -07:00
Ian Flanigan a7bf5d025d
Split drivers into different files
Before, all of the disk drivers were in the `disk2.ts` file. With this
change, they are now in separate files with a common `types.ts` file
for shared types. Now, none of the drives depend on the `disk2.ts`
except the WOZ driver that needs access to the sequencer rom. (This
may be moved in a future refactoring.)
2022-09-24 09:51:40 +02:00
Ian Flanigan 630a3e9d38
Organize imports in `disk2.ts`
The imports were automatically organized using VS Code's organize
imports action.
2022-09-24 08:54:02 +02:00
Ian Flanigan 4bbfac5a5a
Rename drive number fields/variables/parameters to `driveNo`
Before, the naming of fields, variables, and parameters that took
`DriveNumber` was very inconsistent. This changes them all to
`driveNo`.
2022-09-24 08:53:48 +02:00
Ian Flanigan 51ba03ac28
Split handling of nibble disks and WOZ disks into separate drivers
Before, the `DiskII` object took care of both nibble disks and WOZ
disks at the same time. This made it hard to see which code affected
which disks.

Now, nibble disks are handled by the `NibbleDiskDriver` and WOZ disks
are handled by the `WozDiskDriver`. This separation of code should
lead to easeir testing and, perhaps, faster evolution of disk
handling.

An upcoming change will move the `NibbleDiskDriver` and the
`WozDiskDriver` to separate files.

This passes all tests, compiles, and runs both nibble disks and WOZ
disks.
2022-09-18 21:37:03 +02:00
Ian Flanigan e280c3d7b8
Add 13 sector disk support to `getBinary` (#159)
Before, `getBinary` did not work for 13 sector disks because it
assumed that all tracks had 16 sectors. On top of that, `readSector`
could not decode sectors with 5 and 3 encoding. And finally,
`findSector` couldn't even find sectors with DOS 3.2 address fields.

All of these have been fixed and some tests added to make sure that
they keep working.
2022-09-18 06:40:08 -07:00
Ian Flanigan 2793c25c9f
Split disk data out into its own record (#158)
* Harmonize drive and disk type hierarchies

Before, the `XXXDrive` and `XXXDisk` type hierarchies were similar,
but not exactly the same. For example, `encoding` and `format` were
missing on some `XXXDisk` types where they existed on the `XXXDrive`
type. This change attempts to bring the hierarchies closer together.

However, the biggest visible consequence is the introduction of the
`FLOPPY_FORMATS` array and its associated `FloppyFormat` type.  This
replaces `NIBBLE_FORMATS` in most places.  A couple of new type guards
for disk formats and disks have been added as well.

All tests pass, everything compiles with no errors, and both WOZ and
nibble format disks load in the emulator.

* Move disk data to a `disk` field in the drive

Before, disk data was mixed in with state about the drive itself (like
track, motor phase, etc.). This made it hard to know exactly what data
was necessary for different image formats.

Now, the disk data is in a `disk` field whose type depends on the
drive type.  This makes responisbility a bit easier.

One oddity, though, is that the `Drive` has metadata _and_ the `Disk`
has metadata.  When a disk is in the drive, these should be `===`, but
when there is no disk in the drive, obviously only the drive metadata
is set.

All tests pass, everything compiles, and both WOZ and nibble disks
work in the emulator (both preact and classic).

* Squash the `Drive` type hierarchy

Before, the type of the drive depended on the type of the disk in the
drive. Thus, `NibbleDrive` contained a `NibbleDisk` and a `WozDrive`
contained a `WozDisk`.  With the extraction of the disk data to a
single field, this type hierarchy makes no sense.  Instead, it
suffices to check the type of the disk.

This change removes the `NibbleDrive` and `WozDrive` types and type
guards, checking the disk type where necessary. This change also
introduces the `NoFloppyDisk` type to represent the lack of a
disk. This allows the drive to have metadata, for one.

All tests pass, everything compiles, and both WOZ and nibble disks
work locally.

* Use more destructuring assignment

Now, more places use constructs like:

```TypeScript
    const { metadata, readOnly, track, head, phase, dirty } = drive;
    return {
        disk: getDiskState(drive.disk),
        metadata: {...metadata},
        readOnly,
        track,
        head,
        phase,
        dirty,
    };
```

* Remove the `Disk` object from the `Drive` object

This change splits out the disk objects into a record parallel to the
drive objects. The idea is that the `Drive` structure becomes a
representation of the state of the drive that is separate from the
disk image actually in the drive. This helps in an upcoming
refactoring.

This also changes the default empty disks to be writable. While odd,
the write protect switch should be in the "off" position since there
is no disk pressing on it.

Finally, `insertDisk` now resets the head position to 0 since there is
no way of preserving the head position across disks. (Even in the real
world, the motor-off delay plus spindle spin-down would make it
impossible to know the disk head position with any accuracy.)
2022-09-17 06:41:35 -07:00
Ian Flanigan 41e0609f55
Floppy controller refactorings 1 (#155)
* Add `DiskMetada` to the `Disk` interface

Before, metadata about the image, such as name, side, etc. was mixed
in with actual disk image information.  This change breaks that
information into a separate structure called `DiskMetadata`.
Currently, the only two fields are `name` and `side`, but the idea is
that more fields could be added as necessary, like a description, a
scan of the disk or label, etc.  In a follow-on change, the default
write-protection status will come from the metadata as well.

The current implementation copies the metadata when saving/restoring
state, loading disk images, etc.  In the future, the metadata should
passed around until the format is required to change (like saving one
disk image format as another).  Likewise, in the future, in may be
desirable to be able to override the disk image metadata with
user-supplied metadata.  This could be use, for example, to
temporarily add or remove write-protection from a disk image.

All existing tests pass and the emulator builds with no errors.

* Rename `writeMode` to `q7`

Before, nibble disk emulation used the `writeMode` field to keep track
of whether the drive should be read from or written to, but the WOZ
emulation used `q7` to keep track of the same state.

This change renames `writeMode` to `q7` because it more accurately
reflects the state of the Disk II controller as specified in the
manuals, DOS source, and, especially, _Understanding the Apple //e_ by
Jim Sather.

* Remove the coil state

Before, `q` captured the state of the coils.  But it was never read.
This change just deletes it.

* Use the bootstrap and sequencer ROMs with indirection

Before, the contents of the bootstrap ROM and sequencer ROM were set
directly on fields of the controller.  These were not saved or
restored with the state in `getState` and `setState`.  (It would have
been very space inefficient if they had).

Now, these ROMs are used from constants indexed by the number of
sectors the card supports.  This, in turn, means that if the number of
sectors is saved with the state, it can be easily restored.

* Split out the Disk II controller state

This change factors the emulated hardware state into a separate
structure in the Disk II controller.  The idea is that this hardware
state will be able to be shared with the WOZ and nibble disk code
instead of sharing _all_ of the controller state (like callbacks and
so forth).

* Factor out disk insertion

Before, several places in the code essentially inserted a new disk
image into the drive, which similar—but not always exactly the
same—code.  Now there is an `insertDisk` method that is responsible
for inserting a new `FloppyDisk`.

All tests pass, everything compiles, manually tested nibble disks and
WOZ disks.
2022-08-31 18:55:01 -07:00
Ian Flanigan 5e224006e4
Make `DiskII.drives` a `Record` instead of an array (#154)
Before, the `drives` field was an `array[0..1]` of `Drive`, but all of
the methods took a `DriveNumber`, which was `[1..2]`.  This meant that
code everywhere was always subtracting 1 from the drive number.

Now, `drives` is a `Record<DriveNumber, Drive>`, which means tha it
has indexes `1, 2` and there's no need to subtract 1 everywhere.

This change updates the `DiskII` class and its tests.

The motivation for this change is to slowly split the WOZ disk
implementation from the nibble disk implementation.  I've tried twice,
but the change has always grown too big and hairy, so I'm starting
very small this time and working my way up.
2022-08-31 09:06:38 -07:00
Ian Flanigan 4688cae5b2
Refactor key handling to use `event.key` (#152)
Before, keyboard input used key codes to map events to Apple II keys.
This worked reasonably well, but `event.keyCode` was deprecated and
slated to be removed.

The refactored code now uses `event.key` which returns the localized,
keyboard-mapped key that the user pressed, which may be a letter or a
"symbolic" key.  This is then transformed into an Apple II key.

One side effect of the refactoring is that the keys now light up as
you type and that combinations of mouse clicks on modifiers and plain
keys will take the modifiers into account.
2022-08-24 18:23:22 -07:00
Ian Flanigan e1e8eec218
Make errors in the disk and audio workers not block the emulator (#150)
Before, if there was an error in the audio worker or in the disk
worker, the emulator would not start. This could happen, for example,
if the page is loaded directly from disk in Chrome instead of through
a server.

Now, even if there is an error, the emulator will start.
2022-08-21 12:41:19 -07:00
Ian Flanigan 62568d19f4
Prevent the default action when the Apple keyboard handles a key (#151)
Before, if the browser window wasn't tall enough to show the whole
keyboard, using the arrow keys in the window would cause the page
to move as well.  Now all key events that are sent to the keyboard
have `preventDefault()` called on them.
2022-08-21 12:37:03 -07:00
Will Scullin 89cf6aa17b
Add blank test disks 2022-08-20 08:33:09 -07:00
Will Scullin fec0e14465
Fix sector wrap issue, validate sector 2022-08-20 08:31:34 -07:00
Will Scullin 04ef236601
Double Hires preview 2022-08-05 20:32:55 -07:00
Will Scullin 22c651265e
Fix numbers 2022-07-26 18:46:39 -07:00
Will Scullin a5256ae134
More file modal fixes 2022-07-26 18:05:33 -07:00
Will Scullin ac336b3cce
Really relative this time 2022-07-25 19:41:03 -07:00
Will Scullin 52af193caa
Use fetch for relative path 2022-07-25 19:27:55 -07:00
Will Scullin a45eaeb193
Fix charset 2022-07-25 19:24:16 -07:00
Will Scullin c7f36596e3
lazy load file index 2022-07-24 13:53:06 -07:00
Will Scullin 468fad9385
Fix deleted file handling 2022-07-24 08:00:02 -07:00
Will Scullin ed9370fd21
More hires preview tweaks 2022-07-23 16:09:33 -07:00
Will Scullin c7e9598cc5
relax upper hires preview bound 2022-07-23 16:04:20 -07:00
Will Scullin bf789eb2fd
Add hires preview (#146) 2022-07-23 15:51:12 -07:00
Will Scullin 5170738ddc
Debugger off by default 2022-07-23 12:32:40 -07:00
Will Scullin e414f8d105
Debugger disk info groundwork (#145) 2022-07-23 12:00:38 -07:00
dependabot[bot] 9dcc741305
Bump terser from 5.6.1 to 5.14.2 (#144)
Bumps [terser](https://github.com/terser/terser) from 5.6.1 to 5.14.2.
- [Release notes](https://github.com/terser/terser/releases)
- [Changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md)
- [Commits](https://github.com/terser/terser/commits)

---
updated-dependencies:
- dependency-name: terser
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-19 18:31:03 -07:00
Will Scullin 087dbd3602
Fix copy paste outside of screen (#143) 2022-07-16 20:50:15 -07:00
Will Scullin c0ff1e8129
More debugger panels (#141) 2022-07-13 20:34:50 -07:00
Will Scullin fd5217158e
Add language card 2022-07-10 07:58:29 -07:00
Will Scullin e367d56bc3
Add copy/paste 2022-07-06 14:00:18 -07:00
Will Scullin 7774a2a14a
Fix http json loading 2022-07-04 15:49:52 -07:00