apple2js/js/components/LanguageCard.tsx

36 lines
901 B
TypeScript
Raw Normal View History

2022-07-10 14:58:29 +00:00
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;
};