Commit Graph

63 Commits

Author SHA1 Message Date
Will Scullin 7c2c2a3e6d
Fix active key state 2023-12-28 17:43:36 -08:00
Will Scullin 184a102877
de-prettier keyboard layouts 2023-12-03 18:26:33 -08:00
Kaloyan Tenchov 9d536ae367
Add Pravetz 82 support (#204)
* Initial support for Pravetz 82

* Add character ROM for Pravetz 82 (#2)

* Initial working Pravetz 82 keyboard (#3)

* Fix row1 wrapping
2023-11-26 11:40:22 -08:00
Will Scullin aaca31f96b
VS Code and prettier are fighting... 2023-11-24 16:30:59 -08:00
Will Scullin 45a5e63cf9
Use debugger from submodule 2023-11-24 10:12:19 -08:00
Will Scullin 1e79d9d59d
Prettier (#203)
* Enabled prettier

* Update lint, fix issues

* Restore some array formatting
2023-11-24 06:45:55 -08:00
Will Scullin e7891114c6
Use submodules for apple2shader and cpu6502 (#202)
* Use submodules for apple2shader and cpu6502

* Update instructions
2023-11-22 16:28:40 -08:00
Ian Flanigan 0047b9dbb3
Improve FileChooser behavior with file input element (#197)
Before, the `FileChooser` could create a malformed `accept` parameter
by repeating extensions if they were specified by several MIME types.
This no longer happens and there is a test for it.
2023-08-12 15:49:46 -07:00
Will Scullin eab02bff31
Fix scss linting (#178) 2023-01-31 17:49:07 -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 4ffc47aa90
Fix build 2022-12-30 19:27:54 -08: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 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 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 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 04ef236601
Double Hires preview 2022-08-05 20:32:55 -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 c7f36596e3
lazy load file index 2022-07-24 13:53:06 -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
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
Will Scullin c2b78951a7
Add load binary file (#140)
* Add load binary file

* Add some validity indicators

* cleanup
2022-07-04 13:10:47 -07:00
Will Scullin c5faad2f9f
Add stylelint (#139) 2022-06-25 17:40:47 -07:00
Will Scullin f283dae7e1
2IMG Download support. (#137)
* 2IMG Download support.

* Use string encoder/decoder
2022-06-21 20:34:19 -07:00
Will Scullin 466a7eed78
Cheap and cheerful debugger (#135)
* Cheap and cheerful debugger

* Try to manage focus
2022-06-19 19:42:34 -07:00
Will Scullin c7a7bcd19b
Simple Preact download (#134)
* Simple Preact download
2022-06-19 09:01:44 -07:00
Will Scullin efe8594845
Preact Videoterm 2022-06-15 18:44:58 -07:00
Will Scullin f3f470ffc1
Fix iOS Safari iCloud 2022-06-13 19:58:21 -07:00
Will Scullin cc46d040ca
Add drag and drop for disks (#130)
* Add drag and drop for disks

* Simplify storage state

* Switch to spawn, add abort signal to loads
2022-06-12 09:42:01 -07:00
Ian Flanigan 3048ec52e1
Interruptable spawn (#132)
* Add `spawn` as a way of calling promise-returning blocks

This change adds `spawn` which takes a no-argument, promise-returning
function, calls it, and returns `void`.  This makes it easy to call
async blocks from `useEffect` and other places that don't take async
functions, but also makes such calls explicit.

* Adds interruptability to `spawn`

Now, the task function passed to `spawn` can take an `Interrupted`
argument, which is merely a method that returns `true` if the task
should stop doing work. Likewise, `spawn` returns an `Interrupt`
function that causes the `Interrupted` function to return `true`.

* Change to using `AbortController` and `AbortSignal`

Before, `spawn` used functions to interrupt and determine interruption
state.  Now, based on feedback from @whscullin, it uses
`AbortController` and `AbortSignal`.

Tests now show how the controller can be used to abort long-running
tasks and API calls in the `spawn`.  The also show how signals can be
chained using `addEventListener`.

* Fix `Apple2.tsx`

Forgot to change it to use `AbortController` and `AbortSignal`.

Co-authored-by: Will Scullin <scullin@scullin.com>
2022-06-12 09:06:58 -07:00
Ian Flanigan d7cb6997d1
Add `spawn` as a way of calling promise-returning blocks (#131)
This change adds `spawn` which takes a no-argument, promise-returning
function, calls it, and returns `void`.  This makes it easy to call
async blocks from `useEffect` and other places that don't take async
functions, but also makes such calls explicit.
2022-06-12 09:05:01 -07:00
Will Scullin 6f804758f1
Fix preact apple keys 2022-06-10 19:53:40 -07:00
Will Scullin 9686eda3a8
Preact printer (#129) 2022-06-09 12:22:59 -07:00
Will Scullin 66f3e04d8e
Preact mass storage (#125)
The major impetus for rewriting in UI, at least. Still some ironing to do, but much nicer than my attempt to do this using the old UI "framework".
2022-06-05 10:57:04 -07:00
Will Scullin 15b7f1e123
Fix mouse mode cursor 2022-06-04 18:39:04 -07:00
Will Scullin dd10d490f0
Fix some buttons 2022-06-04 14:31:57 -07:00
Will Scullin 72cfbe9062
Fix reset button size 2022-06-04 12:04:47 -07:00
Will Scullin 9628b437b1
Fix drive light state 2022-06-04 11:38:59 -07:00
Will Scullin 451b2f1c31
Push some pixels 2022-06-04 11:07:40 -07:00
Will Scullin cb615ce995
Fix file name display 2022-06-04 11:06:38 -07:00