mirror of
https://github.com/whscullin/apple2js.git
synced 2024-01-12 14:14:38 +00:00
Add language card
This commit is contained in:
parent
e367d56bc3
commit
fd5217158e
|
@ -7,6 +7,7 @@ import { Debugger } from './Debugger';
|
||||||
import { ErrorModal } from './ErrorModal';
|
import { ErrorModal } from './ErrorModal';
|
||||||
import { Inset } from './Inset';
|
import { Inset } from './Inset';
|
||||||
import { Keyboard } from './Keyboard';
|
import { Keyboard } from './Keyboard';
|
||||||
|
import { LanguageCard } from './LanguageCard';
|
||||||
import { Mouse } from './Mouse';
|
import { Mouse } from './Mouse';
|
||||||
import { Screen } from './Screen';
|
import { Screen } from './Screen';
|
||||||
import { Drives } from './Drives';
|
import { Drives } from './Drives';
|
||||||
|
@ -56,6 +57,7 @@ export const Apple2 = (props: Apple2Props) => {
|
||||||
const io = apple2?.getIO();
|
const io = apple2?.getIO();
|
||||||
const cpu = apple2?.getCPU();
|
const cpu = apple2?.getCPU();
|
||||||
const vm = apple2?.getVideoModes();
|
const vm = apple2?.getVideoModes();
|
||||||
|
const rom = apple2?.getROM();
|
||||||
|
|
||||||
const doPaste = useCallback((event: Event) => {
|
const doPaste = useCallback((event: Event) => {
|
||||||
if (io) {
|
if (io) {
|
||||||
|
@ -135,6 +137,7 @@ export const Apple2 = (props: Apple2Props) => {
|
||||||
onClick={removeFocus}
|
onClick={removeFocus}
|
||||||
>
|
>
|
||||||
<Screen screen={screen} />
|
<Screen screen={screen} />
|
||||||
|
{!e ? <LanguageCard cpu={cpu} io={io} rom={rom} slot={0} /> : null}
|
||||||
<Slinky io={io} slot={2} />
|
<Slinky io={io} slot={2} />
|
||||||
{!e ? <Videoterm io={io} slot={3} /> : null}
|
{!e ? <Videoterm io={io} slot={3} /> : null}
|
||||||
<Mouse cpu={cpu} screen={screen} io={io} slot={4} />
|
<Mouse cpu={cpu} screen={screen} io={io} slot={4} />
|
||||||
|
|
35
js/components/LanguageCard.tsx
Normal file
35
js/components/LanguageCard.tsx
Normal 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;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user