diff --git a/package-lock.json b/package-lock.json
index 816cf13..fcb345f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -11,6 +11,7 @@
"@emotion/react": "^11.14.0",
"@emotion/styled": "^11.14.1",
"@fontsource/noto-sans-jp": "^5.3.1",
+ "@fontsource/roboto": "^5.3.0",
"@mui/icons-material": "^7.3.1",
"@mui/material": "^7.3.1",
"clsx": "^2.1.1",
@@ -498,6 +499,15 @@
"url": "https://github.com/sponsors/ayuhito"
}
},
+ "node_modules/@fontsource/roboto": {
+ "version": "5.3.0",
+ "resolved": "https://registry.npmjs.org/@fontsource/roboto/-/roboto-5.3.0.tgz",
+ "integrity": "sha512-BapRJOWYP+LZ21zp+wBQjfpPYKRoxc4LspJ/RLuI+HSMBD5u/X4O+ESDrSvEqDSy0rAl7GwBJ+09mdc16cVQ1Q==",
+ "license": "OFL-1.1",
+ "funding": {
+ "url": "https://github.com/sponsors/ayuhito"
+ }
+ },
"node_modules/@jridgewell/gen-mapping": {
"version": "0.3.13",
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
diff --git a/package.json b/package.json
index 5353b46..ce6abf5 100644
--- a/package.json
+++ b/package.json
@@ -17,6 +17,7 @@
"@emotion/react": "^11.14.0",
"@emotion/styled": "^11.14.1",
"@fontsource/noto-sans-jp": "^5.3.1",
+ "@fontsource/roboto": "^5.3.0",
"@mui/icons-material": "^7.3.1",
"@mui/material": "^7.3.1",
"clsx": "^2.1.1",
diff --git a/src/components/TruthTableView.tsx b/src/components/TruthTableView.tsx
index cd6a15c..2cf6288 100644
--- a/src/components/TruthTableView.tsx
+++ b/src/components/TruthTableView.tsx
@@ -1,20 +1,17 @@
import { Box, type Theme } from "@mui/material";
import { useContext } from "react";
-import { bitDigit, bitLabel } from "../common/bitLabel";
import { useMessages } from "../i18n";
import type { TruthTable } from "../store/intrinsics/truthTable";
import type { SimulationValue } from "../store/simulation";
-import { theme } from "../style";
import { BitNotationContext } from "./bitNotation";
import { truthTableColumnsOf, truthTableLinesOf } from "./truthTableLayout";
+import { ValueView } from "./ValueView";
const divider = (muiTheme: Theme) => `1px solid ${muiTheme.palette.divider}`;
-const onSx = { color: theme.colors.primary, fontWeight: "bold" } as const;
export function TruthTableView({ table }: { table: TruthTable }) {
const messages = useMessages();
- const singleBitLabel =
- useContext(BitNotationContext) === "digits" ? bitDigit : bitLabel;
+ const notation = useContext(BitNotationContext);
const columns = truthTableColumnsOf(table, messages.truthTable.timeStep);
const cellSx = (column: number) =>
({
@@ -23,17 +20,9 @@ export function TruthTableView({ table }: { table: TruthTable }) {
textAlign: "center",
...(columns[column]?.startsGroup && { borderLeft: divider }),
}) as const;
- const valueCell = (value: SimulationValue) =>
- value.map((bit, index) => (
-
- {value.length === 1 ? singleBitLabel(bit) : bitDigit(bit)}
-
- ));
+ const valueCell = (value: SimulationValue) => (
+
+ );
return (
(
+
+ {value.length === 1 ? singleBitLabel(bit) : bitDigit(bit)}
+
+ ));
+}
diff --git a/src/components/controlLooks.ts b/src/components/controlLooks.ts
new file mode 100644
index 0000000..0d44078
--- /dev/null
+++ b/src/components/controlLooks.ts
@@ -0,0 +1,40 @@
+import type {
+ ButtonProps,
+ SxProps,
+ Theme,
+ ToggleButtonProps,
+} from "@mui/material";
+import { theme } from "../style";
+
+// The looks of controls a stage text draws too, so that the two cannot drift apart
+
+export const checkButtonLook = {
+ variant: "contained",
+ sx: { background: theme.colors.tutorial },
+} as const satisfies ButtonProps;
+
+export const valueApplyButtonLook = {
+ variant: "outlined",
+ size: "small",
+ sx: { py: 0.25 },
+} as const satisfies ButtonProps;
+
+export const pinApplyButtonLook = {
+ variant: "contained",
+ size: "small",
+} as const satisfies ButtonProps;
+
+export const autoToggleButtonLook = {
+ size: "small",
+} as const satisfies Partial;
+
+const sxList = (sx: SxProps | undefined) =>
+ sx === undefined ? [] : Array.isArray(sx) ? sx : [sx];
+
+/** The `sx` of `look` with `sx` after it, so that neither is dropped */
+export function withLookSx(
+ look: ButtonProps | Partial,
+ sx: SxProps,
+): SxProps {
+ return [...sxList(look.sx), ...sxList(sx)];
+}
diff --git a/src/i18n/en.ts b/src/i18n/en.ts
index 41adf8b..1f61cc1 100644
--- a/src/i18n/en.ts
+++ b/src/i18n/en.ts
@@ -11,79 +11,108 @@ const bitCount = (count: number) => (count === 1 ? "1 bit" : `${count} bits`);
const themOf = (names: readonly string[]) =>
names.length === 1 ? "it" : "them";
-type StageTexts = { title: string; goal: string; steps: readonly string[] };
+type StageTexts = {
+ title: string;
+ /** paragraphs */
+ goal: readonly string[];
+ steps: readonly string[];
+};
const stageTexts: Record = {
and: {
title: "Both switches",
- goal: "Make the lamp Out turn ON only when both switches A and B are ON. The stage is cleared when the circuit works as in the table below.",
+ goal: [
+ "Make the lamp {Out} turn [ON] only when both switches {A} and {B} are [ON]. The stage is cleared when the circuit works as in the table below.",
+ ],
steps: [
"Pick a part in the Parts list and drag it onto the editor on the right.",
- "The small squares on the edges of a part are its pins. A pin on the left side is an input, which receives ON or OFF, and a pin on the right side is an output, which sends ON or OFF. Drag between an output pin and an input pin to connect them with a wire.",
- "Once Out and every input pin of the parts you placed are connected, the play button at the bottom right can be pressed. It cannot be pressed while a part has a free input pin.",
- "After pressing it, click the switches A and B to turn them ON and OFF, and watch the lamp Out. To fix the circuit, the pencil button in the same place takes you back to editing.",
- "When it works as in the table, press Check.",
+ "The small squares on the edges of a part are its pins. A pin on the left side is an input, which receives [ON] or [OFF], and a pin on the right side is an output, which sends [ON] or [OFF]. Drag between an output pin and an input pin to connect them with a wire.",
+ "Once {Out} and every input pin of the parts you placed are connected, the play button at the bottom right can be pressed. It cannot be pressed while a part has a free input pin.",
+ "After pressing the play button , click the switches {A} and {B} to turn them [ON] and [OFF], and watch the lamp {Out}. To fix the circuit, the pencil button in the same place takes you back to editing.",
+ "When it works as in the table, press .",
],
},
"a-only": {
title: "Only switch A",
- goal: "Make the lamp Out turn ON only when switch A is ON and B is OFF. This time, one part alone is not enough.",
+ goal: [
+ "Make the lamp {Out} turn [ON] only when switch {A} is [ON] and {B} is [OFF]. This time, one part alone is not enough.",
+ ],
steps: [],
},
xor: {
title: "Only one switch",
- goal: 'Make the lamp Out turn ON when exactly one of the switches A and B is ON. It stays OFF when both are ON. "Only switch A" is ready to use as a part.',
+ goal: [
+ 'Make the lamp {Out} turn [ON] when exactly one of the switches {A} and {B} is [ON]. It stays [OFF] when both are [ON]. "{Only switch A}" is ready to use as a part.',
+ ],
steps: [],
},
"half-adder": {
title: "Adding one digit",
- goal: "From here on, think of ON as 1 and OFF as 0, and the tables write them that way too. Then A + B is 0, 1 or 2. Binary writes numbers with only 0 and 1: just as 9 + 1 carries over and becomes 10 in everyday numbers, 1 + 1 carries over and becomes 10 in binary. So 0, 1 and 2 are 00, 01 and 10 in two digits. A digit of a binary number is called a bit. Output the left digit (the twos digit) to C and the right digit (the ones digit) to S. C is called the carry and S the sum, and this circuit is called a half adder.",
+ goal: [
+ "From here on, think of [ON] as [1] and [OFF] as [0], and the tables write them that way too. Then {A} + {B} is 0, 1 or 2. Binary writes numbers with only 0 and 1: just as 9 + 1 carries over and becomes 10 in everyday numbers, 1 + 1 carries over and becomes 10 in binary. So 0, 1 and 2 are [00], [01] and [10] in two digits. A digit of a binary number is called a bit.",
+ "Output the left digit (the twos digit) to {C} and the right digit (the ones digit) to {S}. {C} is called the carry and {S} the sum, and this circuit is called a half adder.",
+ ],
steps: [],
},
"full-adder": {
title: "Adding with a carry",
- goal: 'Output A + B + Cin as a two-digit binary number to C and S. Cin is the carry coming up from the next lower digit. The answer is 0 to 3, and 3 is 11 in binary. "Adding one digit" is ready to use as a part: add A and B with one, then add Cin to its S with another. This circuit is called a full adder.',
+ goal: [
+ 'Output {A} + {B} + {Cin} as a two-digit binary number to {C} and {S}. {Cin} is the carry coming up from the next lower digit. The answer is 0 to 3, and 3 is [11] in binary. "{Adding one digit}" is ready to use as a part: add {A} and {B} with one, then add {Cin} to its {S} with another. This circuit is called a full adder.',
+ ],
steps: [],
},
"four-bit-adder": {
title: "Adding four digits",
- goal: "A and B are four-digit binary numbers. Output A + B in four digits to S, and its fifth digit, the sixteens digit, to C: C is 1 when A + B is 16 or more. The table shows some examples.",
+ goal: [
+ "{A} and {B} are four-digit binary numbers. Output {A} + {B} in four digits to {S}, and its fifth digit, the sixteens digit, to {C}: {C} is [1] when {A} + {B} is 16 or more. The table shows some examples.",
+ ],
steps: [
- 'Place four "Adding with a carry". From the top, the pins on the right of Decompose and on the left of Aggregate are the eights, fours, twos and ones digits.',
- "For each digit, connect that digit's pin on the upper Decompose, which A goes into, and on the lower one, which B goes into, to the A and B of one \"Adding with a carry\". Connect the S of that adder to the same digit's pin of Aggregate.",
- "Connect the C of each digit's adder to the Cin of the adder one digit up. The ones digit's adder gets False on its Cin, and the C of the eights digit's adder goes to the output C on the right.",
- "While playing, click a digit of A or B to switch it between 0 and 1. The sum S is shown as one character on the Display at the top right. The 7seg before it turns the binary number into the shape of a numeral. To write 10 to 15 with one character, A (10), b (11), C (12), d (13), E (14) and F (15) are used. This way of writing is called hexadecimal.",
+ 'Place four "{Adding with a carry}". From the top, the pins on the right of {Decompose} and on the left of {Aggregate} are the eights, fours, twos and ones digits.',
+ "For each digit, connect that digit's pin on the upper {Decompose}, which {A} goes into, and on the lower one, which {B} goes into, to the {A} and {B} of one \"{Adding with a carry}\". Connect the {S} of that adder to the same digit's pin of {Aggregate}.",
+ "Connect the {C} of each digit's adder to the {Cin} of the adder one digit up. The ones digit's adder gets {False} on its {Cin}, and the {C} of the eights digit's adder goes to the output {C} on the right.",
+ "While playing, click a digit of {A} or {B} to switch it between [0] and [1]. The sum {S} is shown as one character on the {Display} at the top right. The {7seg} before it turns the binary number into the shape of a numeral. To write 10 to 15 with one character, A (10), b (11), C (12), d (13), E (14) and F (15) are used. This way of writing is called hexadecimal.",
],
},
counter: {
title: "Counter",
- goal: "After pressing the play button, a number with an arrow button on each side appears at the bottom. The number is called the time step, and the right arrow goes to the next one. The circuit runs one time step at a time. Make Count go up by 1 at each time step, and go back to 0000 after 1111. 0000 to 1111 are 0 to F in hexadecimal.",
+ goal: [
+ "After pressing the play button , a number with an arrow button on each side appears at the bottom. The number is called the time step, and the right arrow goes to the next one. The circuit runs one time step at a time.",
+ "Make {Count} go up by 1 at each time step, and go back to [0000] after [1111]. [0000] to [1111] are 0 to F in hexadecimal.",
+ ],
steps: [
- "Place a FlipFlop. A FlipFlop outputs what it received at the time step before, and 0 at the first time step. Connect its output to Count and to the 7seg at the top right.",
- 'Place a Const. A Const always outputs the value written in it. Change 00000000 in its box to 0001 and press Apply (four bits, to match the B it connects to). The "4 bits" below the box is the number of bits of the value.',
- 'Place "Adding four digits". Connect the output of the FlipFlop to its A, the Const to its B, and its S to the input of the FlipFlop. Then the number the FlipFlop outputs plus 1 comes out of the FlipFlop at the next time step. C is not used.',
- 'Press the play button and go through the time steps with the right arrow. Press "Auto" to go on by itself, one time step a second. The circuit works when the Display at the top right shows 0 to F in turn.',
+ "Place a {FlipFlop}. A {FlipFlop} outputs what it received at the time step before, and [0000] at the first time step. Connect its output to {Count} and to the {7seg} at the top right.",
+ 'Place a {Const}. A {Const} always outputs the value written in it. Change [00000000] in its box to [0001] and press (four bits, to match the {B} it connects to). The "4 bits" below the box is the number of bits of the value.',
+ 'Place "{Adding four digits}". Connect the output of the {FlipFlop} to its {A}, the {Const} to its {B}, and its {S} to the input of the {FlipFlop}. Then the number the {FlipFlop} outputs plus 1 comes out of the {FlipFlop} at the next time step. {C} is not used.',
+ "Press the play button and go through the time steps with the right arrow . Press to go on by itself, one time step a second. The circuit works when the {Display} at the top right shows 0 to F in turn.",
],
},
"decimal-digit": {
title: "One decimal digit",
- goal: "Writing numbers with 0 to 9, carrying over after 9 as everyday numbers do, is called decimal. Make Count go up by 1 only at the time steps when Up is ON, and go back to 0000 after 1001. 1001 is 9, 8 plus 1. At a time step when Count is 1001 and Up is ON, make Carry turn ON: it tells the digit above to go up. Check turns Up ON until Count reaches 1001, then OFF for two time steps to see that Count stays at 1001 and Carry stays OFF, and then ON again to see that Count goes back to 0000.",
+ goal: [
+ "Writing numbers with 0 to 9, carrying over after 9 as everyday numbers do, is called decimal.",
+ "Make {Count} go up by 1 only at the time steps when {Up} is [ON], and go back to [0000] after [1001]. [1001] is 9, 8 plus 1. At a time step when {Count} is [1001] and {Up} is [ON], make {Carry} turn [ON]: it tells the digit above to go up.",
+ " turns {Up} [ON] until {Count} reaches [1001], then [OFF] for two time steps to see that {Count} stays at [1001] and {Carry} stays [OFF], and then [ON] again to see that {Count} goes back to [0000].",
+ ],
steps: [
- 'The Const, Broadcast and And on the left send 0001 to B of "Adding four digits" when Up is ON, and 0000 when it is OFF. A Broadcast spreads a one-bit value over several bits: 1111 for ON, 0000 for OFF. An And given values of several bits makes each bit 1 only where both are 1.',
- "Make Carry. From 0000 to 1001, only 1001 has 1 in both the eights and the ones digit. Join the top pin (eights) and the bottom pin (ones) on the right of the Decompose at the bottom with an And, join its output and Up with another And, and connect that to Carry.",
- "Place a Broadcast and click the pin on its right. The box that appears is the bit width, the number of bits of the output. Change its 1 to 4 and press Apply, and the output has four bits. Do this before connecting it.",
- "Go back to 0000 when Carry is ON. S is not connected to the FlipFlop yet. Connect the output of the And that goes to Carry to a Not as well to turn it over, spread it to four bits with that Broadcast, join it and S with an And, and connect the And to the input of the FlipFlop.",
- "While playing, click Up to switch it ON and OFF, and go through the time steps with the right arrow. The circuit works when the number on the Display goes up only while Up is ON, and goes back to 0 after 9.",
+ 'The {Const}, {Broadcast} and {And} on the left send [0001] to {B} of "{Adding four digits}" when {Up} is [ON], and [0000] when it is [OFF]. A {Broadcast} spreads a one-bit value over several bits: [1111] for [ON], [0000] for [OFF]. An {And} given values of several bits makes each bit [1] only where both are [1].',
+ "Make {Carry}. From [0000] to [1001], only [1001] has [1] in both the eights and the ones digit. Join the top pin (eights) and the bottom pin (ones) on the right of the {Decompose} at the bottom with an {And}, join its output and {Up} with another {And}, and connect that to {Carry}.",
+ "Place a {Broadcast} and click the pin on its right. The box that appears is the bit width, the number of bits of the output. Change its 1 to 4 and press , and the output has four bits. Do this before connecting it.",
+ "Go back to [0000] when {Carry} is [ON]. {S} is not connected to the {FlipFlop} yet. Connect the output of the {And} that goes to {Carry} to a {Not} as well to turn it over, spread it to four bits with that {Broadcast}, join it and {S} with an {And}, and connect the {And} to the input of the {FlipFlop}.",
+ "While playing, click {Up} to switch it [ON] and [OFF], and go through the time steps with the right arrow . The circuit works when the number on the {Display} goes up only while {Up} is [ON], and goes back to 0 after 9.",
],
},
stopwatch: {
title: "Stopwatch",
- goal: "Finally, a stopwatch counting minutes and seconds like 12:34. It goes on by one second at each time step when Start is ON. The Display at the top right shows, from the left, the tens digit of the minutes (M10), the ones digit of the minutes (M1), a colon, the tens digit of the seconds (S10) and the ones digit of the seconds (S1). M10 and S10 count 0 to 5, and M1 and S1 count 0 to 9. After 59:59 it goes back to 00:00. The 7segs, Const, Decompose and Aggregate left of the Display put the four numerals and the colon side by side on that one Display. Check keeps Start ON until 59:59 has gone back to 00:00, then turns it OFF for two time steps to see that the stopwatch stops, and ON again to see that it goes on.",
+ goal: [
+ "Finally, a stopwatch counting minutes and seconds like 12:34. It goes on by one second at each time step when {Start} is [ON]. The {Display} at the top right shows, from the left, the tens digit of the minutes ({M10}), the ones digit of the minutes ({M1}), a colon, the tens digit of the seconds ({S10}) and the ones digit of the seconds ({S1}). {M10} and {S10} count 0 to 5, and {M1} and {S1} count 0 to 9. After 59:59 it goes back to 00:00.",
+ "The {7seg}s, {Const}, {Decompose} and {Aggregate} left of the {Display} put the four numerals and the colon side by side on that one {Display}.",
+ " keeps {Start} [ON] until 59:59 has gone back to 00:00, then turns it [OFF] for two time steps to see that the stopwatch stops, and [ON] again to see that it goes on.",
+ ],
steps: [
- 'Place two "One base-6 digit" and two "One decimal digit". "One base-6 digit" is built like "One decimal digit", but counts 0 to 5 and carries over after 5, as decimal does after 9.',
- 'Give each of the four parts one of M10, M1, S10 and S1: "One base-6 digit" for M10 and S10, and "One decimal digit" for M1 and S1. Connect the Count of each to the output on the right named after its digit, and to the 7seg of that digit. The 7segs are, from the top, for M10, M1, S10 and S1.',
- "Connect Start to Up of the part connected to S1. Then connect Carry of the part for S1 to Up of the part for S10, Carry for S10 to Up for M1, and Carry for M1 to Up for M10. A digit then goes on only when the digit one lower goes back to 0.",
- 'Press the play button. If Start is OFF at the first time step, click it to turn it ON. Press "Auto", and the Display goes on like a clock, one time step a second. To see what comes after 59:59, stop Auto, click the number at the bottom, enter 3600 and press the Enter key. It goes to that time step at once and shows 59:59, and the right arrow shows 00:00.',
+ 'Place two "{One base-6 digit}" and two "{One decimal digit}". "{One base-6 digit}" is built like "{One decimal digit}", but counts 0 to 5 and carries over after 5, as decimal does after 9.',
+ 'Give each of the four parts one of {M10}, {M1}, {S10} and {S1}: "{One base-6 digit}" for {M10} and {S10}, and "{One decimal digit}" for {M1} and {S1}. Connect the {Count} of each to the output on the right named after its digit, and to the {7seg} of that digit. The {7seg}s are, from the top, for {M10}, {M1}, {S10} and {S1}.',
+ "Connect {Start} to {Up} of the part connected to {S1}. Then connect {Carry} of the part for {S1} to {Up} of the part for {S10}, {Carry} for {S10} to {Up} for {M1}, and {Carry} for {M1} to {Up} for {M10}. A digit then goes on only when the digit one lower goes back to 0.",
+ "Press the play button . If {Start} is [OFF] at the first time step, click it to turn it [ON]. Press , and the {Display} goes on like a clock, one time step a second. To see what comes after 59:59, stop , click the number at the bottom, enter 3600 and press the key. It goes to that time step at once and shows 59:59, and the right arrow shows 00:00.",
],
},
};
diff --git a/src/i18n/ja.ts b/src/i18n/ja.ts
index 259c4bd..f177ca7 100644
--- a/src/i18n/ja.ts
+++ b/src/i18n/ja.ts
@@ -150,74 +150,98 @@ export const ja: Messages = {
stageTexts: {
and: {
title: "両方のスイッチ",
- goal: "スイッチ A と B が両方 ON のときだけ、ランプ Out が ON になるようにしましょう。下の表のとおりに動けばクリアです。",
+ goal: [
+ "スイッチ {A} と {B} が両方 [ON] のときだけ、ランプ {Out} が [ON] になるようにしましょう。下の表のとおりに動けばクリアです。",
+ ],
steps: [
"「部品」の一覧から部品を選び、右のエディタにドラッグして置きます。",
- "部品の端にある小さな四角を「ピン」といいます。左側のピンは ON か OFF を受け取る「入力」、右側のピンは ON か OFF を送り出す「出力」です。出力のピンと入力のピンのあいだをドラッグして、線でつなぎます。",
- "Out と、置いた部品の入力のピンがすべてつながると、右下の再生ボタンが押せるようになります。入力のピンが空いている部品が残っていると押せません。",
- "再生ボタンを押したら、スイッチ A と B をクリックして ON と OFF を切り替え、ランプ Out を見ます。回路を直すときは、同じ場所の鉛筆のボタンで編集に戻ります。",
- "表のとおりに動いたら、「確かめる」を押します。",
+ "部品の端にある小さな四角を「ピン」といいます。左側のピンは [ON] か [OFF] を受け取る「入力」、右側のピンは [ON] か [OFF] を送り出す「出力」です。出力のピンと入力のピンのあいだをドラッグして、線でつなぎます。",
+ "{Out} と、置いた部品の入力のピンがすべてつながると、右下の再生ボタンが押せるようになります。入力のピンが空いている部品が残っていると押せません。",
+ "再生ボタンを押したら、スイッチ {A} と {B} をクリックして [ON] と [OFF] を切り替え、ランプ {Out} を見ます。回路を直すときは、同じ場所の鉛筆のボタンで編集に戻ります。",
+ "表のとおりに動いたら、を押します。",
],
},
"a-only": {
title: "A だけのスイッチ",
- goal: "スイッチ A が ON で、B が OFF のときだけ、ランプ Out が ON になるようにしましょう。今度は、部品を1つ置くだけではできません。",
+ goal: [
+ "スイッチ {A} が [ON] で、{B} が [OFF] のときだけ、ランプ {Out} が [ON] になるようにしましょう。今度は、部品を1つ置くだけではできません。",
+ ],
steps: [],
},
xor: {
title: "片方だけのスイッチ",
- goal: "スイッチ A と B のどちらか片方だけが ON のときに、ランプ Out が ON になるようにしましょう。両方 ON のときは OFF です。「A だけのスイッチ」を部品として使えます。",
+ goal: [
+ "スイッチ {A} と {B} のどちらか片方だけが [ON] のときに、ランプ {Out} が [ON] になるようにしましょう。両方 [ON] のときは [OFF] です。「{A だけのスイッチ}」を部品として使えます。",
+ ],
steps: [],
},
"half-adder": {
title: "1桁の足し算",
- goal: "ここからは ON を 1、OFF を 0 と考え、表もそう書きます。すると、A+B は 0、1、2 のどれかです。2進数では、0 と 1 だけで数を書きます。ふだんの数で 9+1 が繰り上がって 10 になるように、2進数では 1+1 が繰り上がって 10 になります。そのため、0、1、2 は2桁で 00、01、10 です。2進数の1桁を「ビット」といいます。左の桁(2の位)を C に、右の桁(1の位)を S に出しましょう。C を「桁上がり」、S を「和」といい、この回路を「半加算器」といいます。",
+ goal: [
+ "ここからは [ON] を [1]、[OFF] を [0] と考え、表もそう書きます。すると、{A}+{B} は 0、1、2 のどれかです。2進数では、0 と 1 だけで数を書きます。ふだんの数で 9+1 が繰り上がって 10 になるように、2進数では 1+1 が繰り上がって 10 になります。そのため、0、1、2 は2桁で [00]、[01]、[10] です。2進数の1桁を「ビット」といいます。",
+ "左の桁(2の位)を {C} に、右の桁(1の位)を {S} に出しましょう。{C} を「桁上がり」、{S} を「和」といい、この回路を「半加算器」といいます。",
+ ],
steps: [],
},
"full-adder": {
title: "桁上がりつきの足し算",
- goal: "A+B+Cin の答えを、2桁の2進数で C と S に出しましょう。Cin は、下の桁から来る桁上がりです。答えは 0 から 3 で、3 は2進数で 11 です。「1桁の足し算」を部品として使えます。1つで A と B を足し、もう1つでその S と Cin を足します。この回路を「全加算器」といいます。",
+ goal: [
+ "{A}+{B}+{Cin} の答えを、2桁の2進数で {C} と {S} に出しましょう。{Cin} は、下の桁から来る桁上がりです。答えは 0 から 3 で、3 は2進数で [11] です。「{1桁の足し算}」を部品として使えます。1つで {A} と {B} を足し、もう1つでその {S} と {Cin} を足します。この回路を「全加算器」といいます。",
+ ],
steps: [],
},
"four-bit-adder": {
title: "4桁の足し算",
- goal: "A と B は4桁の2進数です。A+B を4桁で S に、5桁目(16の位)を C に出しましょう。A+B が 16 以上なら、C は 1 です。表はその例です。",
+ goal: [
+ "{A} と {B} は4桁の2進数です。{A}+{B} を4桁で {S} に、5桁目(16の位)を {C} に出しましょう。{A}+{B} が 16 以上なら、{C} は [1] です。表はその例です。",
+ ],
steps: [
- "「桁上がりつきの足し算」を4つ置きます。Decompose の右側のピンと Aggregate の左側のピンは、どちらも上から8の位・4の位・2の位・1の位です。",
- "桁ごとに、A につないだ上の Decompose と、B につないだ下の Decompose から、その桁のピンを1つの「桁上がりつきの足し算」の A と B につなぎます。その足し算の S は、Aggregate の同じ桁のピンにつなぎます。",
- "それぞれの桁の足し算の C を、1つ上の桁の足し算の Cin につなぎます。1の位の足し算の Cin には False を、8の位の足し算の C は右の出力 C につなぎます。",
- "再生中は、A と B の桁をクリックして 0 と 1 を切り替えられます。答えの S は、右上の Display に1文字で表示されます。その手前の 7seg が、2進数を数字の形に変えています。10 から 15 は1文字で書くために、A(10)、b(11)、C(12)、d(13)、E(14)、F(15)を使います。この書き方を16進数といいます。",
+ "「{桁上がりつきの足し算}」を4つ置きます。{Decompose} の右側のピンと {Aggregate} の左側のピンは、どちらも上から8の位・4の位・2の位・1の位です。",
+ "桁ごとに、{A} につないだ上の {Decompose} と、{B} につないだ下の {Decompose} から、その桁のピンを1つの「{桁上がりつきの足し算}」の {A} と {B} につなぎます。その足し算の {S} は、{Aggregate} の同じ桁のピンにつなぎます。",
+ "それぞれの桁の足し算の {C} を、1つ上の桁の足し算の {Cin} につなぎます。1の位の足し算の {Cin} には {False} を、8の位の足し算の {C} は右の出力 {C} につなぎます。",
+ "再生中は、{A} と {B} の桁をクリックして [0] と [1] を切り替えられます。答えの {S} は、右上の {Display} に1文字で表示されます。その手前の {7seg} が、2進数を数字の形に変えています。10 から 15 は1文字で書くために、A(10)、b(11)、C(12)、d(13)、E(14)、F(15)を使います。この書き方を16進数といいます。",
],
},
counter: {
title: "カウンタ",
- goal: "再生ボタンを押すと、下に数字と、その左右に矢印のボタンが出ます。この数字を「ステップ」といい、右の矢印を押すと次のステップに進みます。回路はステップごとに動きます。Count が 1 ステップごとに 1 ずつ増え、1111 の次は 0000 に戻るようにしましょう。0000 から 1111 は、16進数の 0 から F です。",
+ goal: [
+ "再生ボタンを押すと、下に数字と、その左右に矢印のボタンが出ます。この数字を「ステップ」といい、右の矢印を押すと次のステップに進みます。回路はステップごとに動きます。",
+ "{Count} が 1 ステップごとに 1 ずつ増え、[1111] の次は [0000] に戻るようにしましょう。[0000] から [1111] は、16進数の 0 から F です。",
+ ],
steps: [
- "FlipFlop を置きます。FlipFlop は、1つ前のステップで受け取った値を出します。最初のステップでは 0 を出します。FlipFlop の出力を、Count と、右上の 7seg につなぎます。",
- "Const を置きます。Const は、中に書いた値をいつも出します。欄の 00000000 を 0001 に書きかえて、「適用」を押します(つなぐ先の B に合わせて、4ビットで書きます)。欄の下の「4 ビット」は、書いた値のビット数です。",
- "「4桁の足し算」を置き、FlipFlop の出力を A に、Const を B に、S を FlipFlop の入力につなぎます。こうすると、FlipFlop が出している数に 1 を足した数が、次のステップで FlipFlop から出てきます。C は使いません。",
- "再生ボタンを押し、右の矢印でステップを進めます。「自動」を押すと、1秒に1ステップずつひとりでに進みます。右上の Display に 0 から F が順に出れば、うまく動いています。",
+ "{FlipFlop} を置きます。{FlipFlop} は、1つ前のステップで受け取った値を出します。最初のステップでは [0000] を出します。{FlipFlop} の出力を、{Count} と、右上の {7seg} につなぎます。",
+ "{Const} を置きます。{Const} は、中に書いた値をいつも出します。欄の [00000000] を [0001] に書きかえて、を押します(つなぐ先の {B} に合わせて、4ビットで書きます)。欄の下の「4 ビット」は、書いた値のビット数です。",
+ "「{4桁の足し算}」を置き、{FlipFlop} の出力を {A} に、{Const} を {B} に、{S} を {FlipFlop} の入力につなぎます。こうすると、{FlipFlop} が出している数に 1 を足した数が、次のステップで {FlipFlop} から出てきます。{C} は使いません。",
+ "再生ボタンを押し、右の矢印でステップを進めます。を押すと、1秒に1ステップずつひとりでに進みます。右上の {Display} に 0 から F が順に出れば、うまく動いています。",
],
},
"decimal-digit": {
title: "10進の1桁",
- goal: "ふだんの数のように、0 から 9 までを使い、9 の次で桁が上がる書き方を10進数といいます。Up が ON のステップだけ Count が 1 増え、1001 の次は 0000 に戻るようにしましょう。1001 は、8 と 1 を足した 9 です。Count が 1001 で Up が ON のステップでは、Carry が ON になるようにします。Carry は、上の桁に桁上がりを知らせる合図です。「確かめる」は、Up を ON にして Count を 1001 まで進めたあと、2ステップだけ Up を OFF にして、Count が 1001 のまま止まり、Carry が OFF のままかを調べます。そのあと Up をまた ON にして、0000 に戻るかを調べます。",
+ goal: [
+ "ふだんの数のように、0 から 9 までを使い、9 の次で桁が上がる書き方を10進数といいます。",
+ "{Up} が [ON] のステップだけ {Count} が 1 増え、[1001] の次は [0000] に戻るようにしましょう。[1001] は、8 と 1 を足した 9 です。{Count} が [1001] で {Up} が [ON] のステップでは、{Carry} が [ON] になるようにします。{Carry} は、上の桁に桁上がりを知らせる合図です。",
+ "は、{Up} を [ON] にして {Count} を [1001] まで進めたあと、2ステップだけ {Up} を [OFF] にして、{Count} が [1001] のまま止まり、{Carry} が [OFF] のままかを調べます。そのあと {Up} をまた [ON] にして、[0000] に戻るかを調べます。",
+ ],
steps: [
- "左の Const・Broadcast・And は、Up が ON のときは 0001 を、OFF のときは 0000 を「4桁の足し算」の B に送っています。Broadcast は、1ビットの値を、同じ値が並んだ何ビットもの値に広げます(ON なら 1111、OFF なら 0000)。And に何ビットもの値をつなぐと、ビットごとに、両方が 1 のビットだけ 1 になります。",
- "Carry を作ります。0000 から 1001 のうち、8の位と1の位がどちらも 1 なのは 1001 だけです。一番下の Decompose の右側の、一番上(8の位)と一番下(1の位)のピンを And でまとめ、その出力と Up をもう1つの And でまとめて、Carry につなぎます。",
- "Broadcast を置き、右側のピンをクリックします。出てきた欄はビット幅、つまり出力のビット数です。1 を 4 に書きかえて「適用」を押すと、出力が4ビットになります。線をつなぐ前にしておきます。",
- "Carry が ON のときに 0000 に戻す部分を作ります。S はまだ FlipFlop につながっていません。Carry につないだ And の出力を Not にもつないで反対にし、その Broadcast で4ビットに広げ、S と And でまとめて、FlipFlop の入力につなぎます。",
- "再生中は、Up をクリックして ON と OFF を切り替えながら、右の矢印でステップを進めます。Up が ON のときだけ Display の数が進み、9 の次に 0 に戻れば、うまく動いています。",
+ "左の {Const}・{Broadcast}・{And} は、{Up} が [ON] のときは [0001] を、[OFF] のときは [0000] を「{4桁の足し算}」の {B} に送っています。{Broadcast} は、1ビットの値を、同じ値が並んだ何ビットもの値に広げます([ON] なら [1111]、[OFF] なら [0000])。{And} に何ビットもの値をつなぐと、ビットごとに、両方が [1] のビットだけ [1] になります。",
+ "{Carry} を作ります。[0000] から [1001] のうち、8の位と1の位がどちらも [1] なのは [1001] だけです。一番下の {Decompose} の右側の、一番上(8の位)と一番下(1の位)のピンを {And} でまとめ、その出力と {Up} をもう1つの {And} でまとめて、{Carry} につなぎます。",
+ "{Broadcast} を置き、右側のピンをクリックします。出てきた欄はビット幅、つまり出力のビット数です。1 を 4 に書きかえてを押すと、出力が4ビットになります。線をつなぐ前にしておきます。",
+ "{Carry} が [ON] のときに [0000] に戻す部分を作ります。{S} はまだ {FlipFlop} につながっていません。{Carry} につないだ {And} の出力を {Not} にもつないで反対にし、その {Broadcast} で4ビットに広げ、{S} と {And} でまとめて、{FlipFlop} の入力につなぎます。",
+ "再生中は、{Up} をクリックして [ON] と [OFF] を切り替えながら、右の矢印でステップを進めます。{Up} が [ON] のときだけ {Display} の数が進み、9 の次に 0 に戻れば、うまく動いています。",
],
},
stopwatch: {
title: "ストップウォッチ",
- goal: "いよいよ、分と秒を 12:34 のように数えるストップウォッチです。Start が ON のステップごとに、1秒ずつ進めます。右上の Display には、左から分の10の位(M10)、分の1の位(M1)、コロン、秒の10の位(S10)、秒の1の位(S1)が出ます。M10 と S10 は 0 から 5 を、M1 と S1 は 0 から 9 を数えます。59:59 の次は 00:00 に戻ります。Display の左にある 7seg・Const・Decompose・Aggregate は、4つの数字とコロンを1つの Display に並べるためのものです。「確かめる」は、Start を ON にしたまま、59:59 の次に 00:00 に戻るまで進めます。そのあと2ステップだけ Start を OFF にして止まるかを、また ON にしてまた進むかを調べます。",
+ goal: [
+ "いよいよ、分と秒を 12:34 のように数えるストップウォッチです。{Start} が [ON] のステップごとに、1秒ずつ進めます。右上の {Display} には、左から分の10の位({M10})、分の1の位({M1})、コロン、秒の10の位({S10})、秒の1の位({S1})が出ます。{M10} と {S10} は 0 から 5 を、{M1} と {S1} は 0 から 9 を数えます。59:59 の次は 00:00 に戻ります。",
+ "{Display} の左にある {7seg}・{Const}・{Decompose}・{Aggregate} は、4つの数字とコロンを1つの {Display} に並べるためのものです。",
+ "は、{Start} を [ON] にしたまま、59:59 の次に 00:00 に戻るまで進めます。そのあと2ステップだけ {Start} を [OFF] にして止まるかを、また [ON] にしてまた進むかを調べます。",
+ ],
steps: [
- "「6進の1桁」を2つと、「10進の1桁」を2つ置きます。「6進の1桁」は「10進の1桁」と同じつくりで、0 から 5 を数え、5 の次で 0 に戻って上の桁が上がります。10進数が 9 の次で桁が上がるのと同じです。",
- "置いた4つの部品を、M10・M1・S10・S1 に1つずつ割り当てます。M10 と S10 には「6進の1桁」を、M1 と S1 には「10進の1桁」を使います。それぞれの Count を、割り当てた桁と同じ名前の右の出力と、その桁の 7seg につなぎます。7seg は、上から M10・M1・S10・S1 用です。",
- "S1 につないだ部品の Up に Start をつなぎます。次に、S1 の部品の Carry を S10 の部品の Up に、S10 の Carry を M1 の Up に、M1 の Carry を M10 の Up につなぎます。こうすると、1つ下の桁が 0 に戻るときだけ、その上の桁が進みます。",
- "再生ボタンを押します。最初のステップで Start が OFF なら、クリックして ON にします。「自動」を押すと、1秒に1ステップずつ、Display が時計のように進みます。59:59 の次を見るには、「自動」を止めて下の数字をクリックし、3600 と入れて Enter キーを押します。そのステップまで一度に進んで 59:59 になり、右の矢印を押すと 00:00 に戻ります。",
+ "「{6進の1桁}」を2つと、「{10進の1桁}」を2つ置きます。「{6進の1桁}」は「{10進の1桁}」と同じつくりで、0 から 5 を数え、5 の次で 0 に戻って上の桁が上がります。10進数が 9 の次で桁が上がるのと同じです。",
+ "置いた4つの部品を、{M10}・{M1}・{S10}・{S1} に1つずつ割り当てます。{M10} と {S10} には「{6進の1桁}」を、{M1} と {S1} には「{10進の1桁}」を使います。それぞれの {Count} を、割り当てた桁と同じ名前の右の出力と、その桁の {7seg} につなぎます。{7seg} は、上から {M10}・{M1}・{S10}・{S1} 用です。",
+ "{S1} につないだ部品の {Up} に {Start} をつなぎます。次に、{S1} の部品の {Carry} を {S10} の部品の {Up} に、{S10} の {Carry} を {M1} の {Up} に、{M1} の {Carry} を {M10} の {Up} につなぎます。こうすると、1つ下の桁が 0 に戻るときだけ、その上の桁が進みます。",
+ "再生ボタンを押します。最初のステップで {Start} が [OFF] なら、クリックして [ON] にします。を押すと、1秒に1ステップずつ、{Display} が時計のように進みます。59:59 の次を見るには、を止めて下の数字をクリックし、3600 と入れてキーを押します。そのステップまで一度に進んで 59:59 になり、右の矢印を押すと 00:00 に戻ります。",
],
},
},
diff --git a/src/main.tsx b/src/main.tsx
index 183776e..ca60c15 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -10,6 +10,10 @@ import {
} from "react-router";
import App from "./App";
import { LanguageProvider } from "./i18n";
+// The first of the Latin fonts in style.css, with the weights the interface uses
+import "@fontsource/roboto/400.css";
+import "@fontsource/roboto/500.css";
+import "@fontsource/roboto/700.css";
import "./style.css";
import { muiTheme } from "./common/theme";
import EditPage from "./pages/edit";
diff --git a/src/pages/edit/Editor/components/FrameControl.tsx b/src/pages/edit/Editor/components/FrameControl.tsx
index 6b93fb0..795ae70 100644
--- a/src/pages/edit/Editor/components/FrameControl.tsx
+++ b/src/pages/edit/Editor/components/FrameControl.tsx
@@ -2,6 +2,7 @@ import { ChevronLeft, ChevronRight } from "@mui/icons-material";
import { Box, IconButton, Paper, TextField, ToggleButton } from "@mui/material";
import { useState } from "react";
import { useInterval } from "react-use";
+import { autoToggleButtonLook } from "../../../../components/controlLooks";
import { useMessages } from "../../../../i18n";
import { useComponentEditorStore } from "../store";
import {
@@ -58,9 +59,9 @@ export default function CCComponentEditorFrameControl() {
elevation={3}
>
{
componentEditorState.setPlaybackMode(
diff --git a/src/pages/edit/Editor/components/NodePinPropertyEditor.tsx b/src/pages/edit/Editor/components/NodePinPropertyEditor.tsx
index 5a465c2..1e43c37 100644
--- a/src/pages/edit/Editor/components/NodePinPropertyEditor.tsx
+++ b/src/pages/edit/Editor/components/NodePinPropertyEditor.tsx
@@ -4,6 +4,10 @@ import nullthrows from "nullthrows";
import { useState } from "react";
import invariant from "tiny-invariant";
import { rect } from "../../../../common/rect";
+import {
+ pinApplyButtonLook,
+ withLookSx,
+} from "../../../../components/controlLooks";
import { useMessages } from "../../../../i18n";
import { IntrinsicComponentDefinition } from "../../../../store/intrinsics/base";
import { CCNodePinStore } from "../../../../store/nodePin";
@@ -177,10 +181,9 @@ export function CCComponentEditorNodePinPropertyEditor() {
>
)}