Add language card

This commit is contained in:
Will Scullin 2022-07-10 07:58:29 -07:00
parent e367d56bc3
commit fd5217158e
No known key found for this signature in database
GPG Key ID: 26DCD1042C6638CD
2 changed files with 38 additions and 0 deletions

View File

@ -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}
>
<Screen screen={screen} />
{!e ? <LanguageCard cpu={cpu} io={io} rom={rom} slot={0} /> : null}
<Slinky io={io} slot={2} />
{!e ? <Videoterm io={io} slot={3} /> : null}
<Mouse cpu={cpu} screen={screen} io={io} slot={4} />

View File

@ -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;
};