Commit Graph

16 Commits

Author SHA1 Message Date
Will Scullin 1e79d9d59d
Prettier (#203)
* Enabled prettier

* Update lint, fix issues

* Restore some array formatting
2023-11-24 06:45:55 -08: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 41015864f2
Prohibit any 2022-05-17 19:08:28 -07:00
Will Scullin a46b0df970
Apply semi rule to interfaces (#109) 2022-05-10 08:04:20 -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
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
Ian Flanigan 4d7068208a
Typescriptify all of the UI peripherals (#73)
* Typescriptify all of the UI peripherals

This converts the audio, gamepad, keyboard, printer, and tape
peripherals into Typescript. This is a pretty mechanical change.

It does fix issue #72, though.

* Add  and  that were missing
2021-03-28 16:39:18 -07:00
Will Scullin ab3e97e8d1
Convert more cards to typescript (#63)
Convert more cards to typescript
2021-03-15 12:51:40 -07:00
Will Scullin a3c7dd136b
Port language card and smartport to TypeScript (#62)
Port language card and smartport to TypeScript.
2021-03-13 13:18:32 -08:00
Will Scullin 87b60d4eb4
Type restructuring 2021-03-06 15:07:06 -08:00
Will Scullin afc5280ac2
Flesh out some state stuff (#59)
Get save and restore state limping along to nearly as well as before I refactored and broke everything.
2021-02-27 19:17:36 -08:00
Will Scullin be35aa9315
NTSC shader (#58)
Incorporate a real NTSC shader.
2021-02-21 18:38:21 -08:00
Ian Flanigan 910238bf63
Convert `cards/disk2.js` to Typescript (#54)
* Convert `cards/disk2.js` to Typescript

This is mostly a straightforward conversion of `cards/disk2.js` to
Typescript, with the following exceptions:

*   `setState()` did not restore the drive light state correctly
    because the callback was called with the old `on` value.

*   `setPhase()` did not work for WOZ images.

*   `getBinary()` did not work for `nib` files.

*   `getBase64()` did not work for `nib` files and maybe didn't work
    right at all.

Even with these fixes, local storage still doesn't work correctly.

I have also added several TODOs where methods don't support WOZ disks.

* Convert most uses of `memory` to `Uint8Array`

There are many places in the existing code where we use `Uint8Array`
directly. This change merely makes the `memory` type equivalent to
`Uint8Array`.

This change also changes most ROM data to be read-only in Typescript
to ensure that it is not modified by mistake. This can't be done just
by applying `as const` to the declaration because `Uint8Array`s are
can not be expressed as literals. Instead, we create a new type,
`ReadonlyUint8Array` that drops the mutation methods and makes indexed
access read-only.

See
https://www.growingwiththeweb.com/2020/10/typescript-readonly-typed-arrays.html
for details.

* Tighten types and document `disk2.ts`

While trying to understand the Disk ][ emulation, I tighted the types
and documented the parts that I could, including references to other
sources, like _Understanding the Apple //e_ by Jim Sather.

The one functional change is the addition of the P6 ROM of DOS 3.2 and
earlier. This is automatically selected if the card is initialized for
13 sector disks.
2021-02-07 20:50:50 -08:00
Ian Flanigan b80436d99c
More typescript conversion (#46)
* Convert js/ram to a class

* Convert js/mmu to Typescript

* Convert js/apple2io to Typescript

* Convert js/canvas to Typescript

* Use new types in js/mmu

* Rename js/symbols.js to js/symbols.ts

* Remove the difference between readPages and writePages

As @whscullin said in PR #38, there's no need to have both readable
and writable pages since all implementations are currently both. This
change combines them into `Page`. Likewise, `PageHandler` now extends
`Page`.

`Apple2IO` now implements `PageHandler`. This caught a bug where `end`
had been renamed `endend` by mistake.

There are a few other formatting changes as well.

* Convert js/apple2 to Typescript

* Convert js/prefs to Typescript

* Convert all of the ROMs in js/roms to Typescript

Now all of the ROMs are classes that extend the ROM class. There is
some rudamentary checking to make sure that the length of the ROM
matches the declared start and end pages. (This caught what looks to
be an error in roms/apple2e, but it's hard for me to tell.)

The typing also caught an error where the character ROM was being
used for the main ROM for the apple2j version.

* Convert js/roms/cards/* to Typescript

* Convert js/formats/format_utils to Typescript

This change also seems to fix a bug with `.po` image files that
weren't being read correctly.
2020-11-24 08:48:14 -08:00
Will Scullin f600f7c6b4
typescript linting 2020-11-07 16:46:27 -08:00
Ian Flanigan c4df78cf06
Typescript conversion of several files, including js/cpu6502 (#38)
* Convert `js/util.js` to Typescript and add tests

Besides converting `js/util.js` to Typescript, this change also adds
`js/types.ts` that defines common types used in apple2js. Some of
these types, like `byte` and `word` are for information only.

* Convert `js/base64.js` to Typescript

This also adds a new type, `memory`, that is either an array of
numbers, or a Uint8Array.

* Convert `js/ram.js` to Typescript

This change does not convert `RAM` to a class; it just introduces types.

* Basic typing of cpu6502

This is a really rough first pass. There are some problems that can't
be fixed until this is turned into a real class, but at least all of
the function arguments are now typed. This caught a few cases where
extra arguments were being passed in.

* Convert `js/cpu6502` to a class

In theory, idiomatic classes should be better than the previous
closure-based classes. However, this conversion shows that the
instruction table does not fit well with idiomatic classes as method
referenced in the table need to be called with the correct `this`
everywhere.

This should, at best, be considered a first attempt.
2020-11-01 08:43:48 -08:00