apple2js/js
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
..
applesoft enforce indent case like vscode prefers 2020-11-25 17:28:37 -08:00
cards Convert cards/disk2.js to Typescript (#54) 2021-02-07 20:50:50 -08:00
formats Convert cards/disk2.js to Typescript (#54) 2021-02-07 20:50:50 -08:00
intbasic
roms Convert cards/disk2.js to Typescript (#54) 2021-02-07 20:50:50 -08:00
ui Convert cards/disk2.js to Typescript (#54) 2021-02-07 20:50:50 -08:00
apple2.ts lint 2020-11-24 08:53:43 -08:00
apple2io.ts enforce indent case like vscode prefers 2020-11-25 17:28:37 -08:00
base64.ts Convert cards/disk2.js to Typescript (#54) 2021-02-07 20:50:50 -08:00
canvas.ts lint 2020-11-24 08:53:43 -08:00
cpu6502.ts Minor type improvements (#50) 2020-12-29 06:40:58 -08:00
entry2.js Less ES6 2019-06-15 15:59:02 -07:00
entry2e.js Less ES6 2019-06-15 15:59:02 -07:00
main2.js enforce indent case like vscode prefers 2020-11-25 17:28:37 -08:00
main2e.js enforce indent case like vscode prefers 2020-11-25 17:28:37 -08:00
mmu.ts enforce indent case like vscode prefers 2020-11-25 17:28:37 -08:00
prefs.ts More typescript conversion (#46) 2020-11-24 08:48:14 -08:00
ram.ts More typescript conversion (#46) 2020-11-24 08:48:14 -08:00
symbols.ts More typescript conversion (#46) 2020-11-24 08:48:14 -08:00
types.ts Convert cards/disk2.js to Typescript (#54) 2021-02-07 20:50:50 -08:00
util.ts Convert cards/disk2.js to Typescript (#54) 2021-02-07 20:50:50 -08:00