diff --git a/js/components/Apple2.tsx b/js/components/Apple2.tsx index 212ad81..a1b7d6f 100644 --- a/js/components/Apple2.tsx +++ b/js/components/Apple2.tsx @@ -7,6 +7,7 @@ import { Debugger } from './Debugger'; import { ErrorModal } from './ErrorModal'; import { Inset } from './Inset'; import { Keyboard } from './Keyboard'; +import { LanguageCard } from './LanguageCard'; import { Mouse } from './Mouse'; import { Screen } from './Screen'; import { Drives } from './Drives'; @@ -56,6 +57,7 @@ export const Apple2 = (props: Apple2Props) => { const io = apple2?.getIO(); const cpu = apple2?.getCPU(); const vm = apple2?.getVideoModes(); + const rom = apple2?.getROM(); const doPaste = useCallback((event: Event) => { if (io) { @@ -135,6 +137,7 @@ export const Apple2 = (props: Apple2Props) => { onClick={removeFocus} > + {!e ? : null} {!e ? : null} diff --git a/js/components/LanguageCard.tsx b/js/components/LanguageCard.tsx new file mode 100644 index 0000000..1370870 --- /dev/null +++ b/js/components/LanguageCard.tsx @@ -0,0 +1,35 @@ +import CPU6502 from 'js/cpu6502'; +import { Memory } from 'js/types'; +import { useEffect } from 'preact/hooks'; +import Apple2IO, { slot } from '../apple2io'; +import LanguageCardImpl from '../cards/langcard'; + +/** + * Language Card component properties + */ +export interface LanguageCardProps { + io: Apple2IO | undefined; + cpu: CPU6502 | undefined; + rom: Memory | undefined; + slot: slot; +} + +/** + * Language card component. Adds 16KB of memory. + * + * @param cpu 6502 object + * @param io Apple2IO object + * @param slot Slot to register card in + * @returns LanguageCard component + */ +export const LanguageCard = ({ cpu, io, rom, slot }: LanguageCardProps) => { + useEffect(() => { + if (io && cpu && rom) { + const lc = new LanguageCardImpl(rom); + io.setSlot(slot, lc); + cpu.addPageHandler(lc); + } + }, [io, cpu, rom, slot]); + + return null; +};