Commit Graph

25 Commits

Author SHA1 Message Date
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
Will Scullin
d042a5b319
Don't reload already loaded disk (#174) 2023-01-22 18:31:35 -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
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
Ian Flanigan
d67f3d8086
Applesoft compiler fixes (#98)
* Add tests for Applesoft compiler in preparation for refactoring

While refactoring the compiler, I found several small bugs:

*   Lower-case letters in strings and REM statements were converted
    to upper-case.
*   Lines are stored in the order received, not sorted by line number.
*   Does not prefer `ATN` to `AT`.
*   Does not prefer `TO` to `AT`.
*   `DATA` statements don't preserve spaces.
*   `DATA` statements don't preserve lowercase.

These will be fixed in the upcoming refactoring.

* Refactor the Applesoft Compiler

Before, the compiler had a few bugs that were not trivial to solve
because the implementation was in one heavily-nested function.

In this refactoring of the compiler, things like tokenization have
been split into separate methods which makes them a bit easier to
understand.

This refactoring also passes all of the tests.

* Set `PRGEND` when compiling to memory

Before, `PRGEND` was not adjusted which made round-tripping from
the Applesoft compiler to the decompiler not work.  This change
now updates `PRGEND` with the end-of-program + 2 bytes which seems
to be the most frequent value that I have observed.

* Fix two compiler bugs

In debugging the decompiler, I noticed two bugs in the compiler:
*   The first character after a line number was skipped.
*   `?` was not accepted as a shortcut for `PRINT`.

This change fixes these two problems and adds tests.

* Ignore spaces more aggressively

It turns out that Applesoft happily accepts 'T H E N' for `THEN`
but the parser did not. This change fixes that and adds tests for
some odd cases.

Interestingly, this means that there are some valid statements
that Applesoft can never parse correctly because it is greedy
and ignores (most) spaces. For example, `NOT RACE` will always
parse as `NOTRACE` even though `NOT RACE` is a valid expression.

* Move tokens into a separate file

Because the token lists are just maps in opposite directions, put
them in the same file. In the future, maybe we can build one
automatically.

* Fix `apple2.ts`

I had neglected to actually update `apple2.ts` to use the new
compiler and decompiler. They now do.

Also, the decompiler can be created from `Memory`. It assumes,
though, that the zero page pointers to the start and end of the
program are correct.

* Address comments

*   No more `as const` for tokens.
*   Extracted zero page constants to their own file.

Co-authored-by: Will Scullin <scullin@scullin.com>
2022-06-23 20:41:45 -07:00
Will Scullin
c7a7bcd19b
Simple Preact download (#134)
* Simple Preact download
2022-06-19 09:01:44 -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
3bbc77049d
Type touchups (#122)
* Type touchups

* Fix some type handling
2022-06-01 06:28:05 -07:00
Ian Flanigan
04ae0327c2
Add the recommended eslint plugins for TypeScript (#121)
This adds both the recommended TypeScript checks, plus the recommended
TypeScript checks that require type checking.  This latter addition
means that eslint essentially has to compile all of the TypeScript in
the project, causing it to be slower. This isn't much of a problem in
VS Code because there's a lot of caching being done, but it's clearly
slower when run on the commandline.

All of the errors are either fixed or suppressed.  Some errors are
suppressed because fixing them would be too laborious for the little
value gained.

The eslint config is also slightly refactored to separate the strictly
TypeScript checks from the JavaScript checks.
2022-05-31 08:38:40 -07:00
Will Scullin
2bd7fa59b7
Enforce strict equality (#115) 2022-05-18 08:19:45 -07:00
Will Scullin
d44cae76a7
Turn on exactOptionalPropertyTypes (#110)
Turn on exactOptionalPropertyTypes
2022-05-11 17:20:49 -07:00
Will Scullin
a46b0df970
Apply semi rule to interfaces (#109) 2022-05-10 08:04:20 -07:00
Will Scullin
4a188a9a5c
Preact UI (#106)
First pass at a Preact UI, still short some major features but full proof of concept.
2022-05-10 06:52:06 -07:00
Will Scullin
7ceacec28e
Full page improvements (#96)
* Full page improvements

* Update fullscreen api calls, save fullpage state
2021-12-25 07:24:59 -08:00
Will Scullin
ba203498f4
TypeScript remnants (#94)
* Clean up remaining Javascript
* ProDOS to TypeScript.
* NSC to TypeScript
2021-12-22 10:37:21 -08:00
Will Scullin
8ab5faee8e
Consistenly use hup to read hash 2021-10-03 11:08:46 -07:00
Will Scullin
2daef8040f
Keep track of disk sides (#87)
Disk side information was being dropped and thus not displayable in the UI. This plumbs the value through various formats and adds some light testing.

Also fixes an issue where URL encoded hashes were not properly interpreted.
2021-10-02 11:45:09 -07:00
Will Scullin
ce3631f3a2
Refactor disk parsing into webworker (#83)
* Refactor disk handling to allow disk processing to happen in a worker
* Type cleanup
* Convert format handlers to TypeScript
* Convert CFFA to TypeScript
2021-07-06 17:04:02 -07:00
Will Scullin
b4c13d7620
Use AudioWorklet where available (#82)
Use AudioWorklet where available
2021-06-25 15:38:35 -07:00
Will Scullin
8087294456
Lazy load ROMs (#81)
* Switch modules to `esnext` to allow `webpack` to see import statements
* Pass rom names into Apple2 class
* Move ROMs into `system` and `character` directories to allow webpack bundle appropriate ROMs.
* Wait for ROMs to load before completing initialization.
2021-06-13 17:06:16 -07:00
Will Scullin
66d8fdc2c2
Allow address input (#78)
Allow address input
2021-04-25 09:37:55 -07:00
Will Scullin
09c6d6fbb1
Options modal (#75)
Refactor Options modal, webgl scanline, restore `Apple2.apple2`, other minor fixes.
2021-04-20 17:42:32 -07:00
Ian Flanigan
207bed3d27
Typescriptify ui/apple2.js (#74)
This is mostly a mechanical change; there are still lots of things
about `ui/apple2` that could be improved.  The change also converts a
few dependencies of `ui/apple2`, like `applesoft/compiler`.

Besides the straight conversions, some other packages have changes to
make all of the typing work out.

Lastly, `@types/micromodal` has been added as a development
dependency.
2021-03-30 17:27:44 -07:00