Skip to content

Commit

Permalink
Add Pravetz 82 support (#204)
Browse files Browse the repository at this point in the history
* Initial support for Pravetz 82

* Add character ROM for Pravetz 82 (#2)

* Initial working Pravetz 82 keyboard (#3)

* Fix row1 wrapping
  • Loading branch information
zayfod authored Nov 26, 2023
1 parent aaca31f commit 9d536ae
Show file tree
Hide file tree
Showing 11 changed files with 2,157 additions and 21 deletions.
94 changes: 94 additions & 0 deletions css/apple2.css
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,10 @@ a.button:hover {
width: 570px;
}

#keyboard.layout-pravetz82 .row {
width: 610px;
}

.apple2e #keyboard .row {
width: 610px;
}
Expand All @@ -418,18 +422,38 @@ a.button:hover {
margin-left: 20px;
}

#keyboard.layout-pravetz82 .row0 {
margin-left: 0px;
}

#keyboard.layout-pravetz82 .row1 {
margin-left: -14px;
}

#keyboard .row2 {
margin-left: 10px;
}

#keyboard.layout-pravetz82 .row2 {
margin-left: 0px;
}

#keyboard .row3 {
margin-left: 10px;
}

#keyboard.layout-pravetz82 .row3 {
margin-left: 15px;
}

#keyboard .row4 {
margin-left: 10px;
}

#keyboard.layout-pravetz82 .row4 {
margin-left: 0px;
}

.apple2e #keyboard .row0 {
margin-left: 0;
}
Expand Down Expand Up @@ -531,11 +555,81 @@ a.button:hover {
bottom: 15px;
}

#keyboard.layout-pravetz82 .key-RST {
border-left-color: #d00;
border-top-color: #d00;
border-right-color: #700;
border-bottom-color: #700;
background-color: #a00;
}

#keyboard.layout-pravetz82 .key-RST:active {
border-left-color: #800;
border-top-color: #800;
border-right-color: #000;
border-bottom-color: #000;
background-color: #500;
}

#keyboard.layout-pravetz82 .key-ОСВ,
#keyboard .key-МК {
border-left-color: #aaa;
border-top-color: #aaa;
border-right-color: #444;
border-bottom-color: #444;
background-color: #777;
}

#keyboard.layout-pravetz82 .key-ОСВ:active,
#keyboard .key-МК:active {
border-left-color: #777;
border-top-color: #777;
border-right-color: #000;
border-bottom-color: #000;
background-color: #333;
}

#keyboard.layout-pravetz82 .key-ЛАТ {
border-left-color: #ddd;
border-top-color: #ddd;
border-right-color: #888;
border-bottom-color: #888;
background-color: #bbb;
}

#keyboard.layout-pravetz82 .key-ЛАТ:active {
border-left-color: #888;
border-top-color: #888;
border-right-color: #222;
border-bottom-color: #222;
background-color: #999;
}

#keyboard.layout-pravetz82 .key-ЛАТ2 {
border-left-color: #dd0;
border-top-color: #dd0;
border-right-color: #880;
border-bottom-color: #880;
background-color: #aa0;
}

#keyboard.layout-pravetz82 .key-ЛАТ2:active {
border-left-color: #770;
border-top-color: #770;
border-right-color: #000;
border-bottom-color: #000;
background-color: #550;
}

#keyboard .key-nbsp {
margin-left: 62px;
width: 330px;
}

#keyboard.layout-pravetz82 .key-nbsp {
margin-left: 72px;
}

.apple2e #display {
margin: 5px;
}
Expand Down
5 changes: 3 additions & 2 deletions js/components/Apple2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface Apple2Props {
gl: boolean;
rom: string;
sectors: SupportedSectors;
keyboardLayout: string;
}

/**
Expand All @@ -53,7 +54,7 @@ export interface Apple2Props {
* @returns
*/
export const Apple2 = (props: Apple2Props) => {
const { e, enhanced, sectors } = props;
const { e, enhanced, sectors, keyboardLayout } = props;
const screenRef = useRef<HTMLCanvasElement>(null);
const [apple2, setApple2] = useState<Apple2Impl>();
const [error, setError] = useState<unknown>();
Expand Down Expand Up @@ -192,7 +193,7 @@ export const Apple2 = (props: Apple2Props) => {
toggleDebugger={toggleDebugger}
/>
<Inset>
<Keyboard apple2={apple2} e={e} />
<Keyboard apple2={apple2} layout={keyboardLayout} />
</Inset>
<ErrorModal error={error} setError={setError} />
</div>
Expand Down
9 changes: 6 additions & 3 deletions js/components/Keyboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const Key = ({
*/
export interface KeyboardProps {
apple2: Apple2Impl | undefined;
e: boolean;
layout: string;
}

/**
Expand All @@ -107,10 +107,13 @@ export interface KeyboardProps {
* @param apple2 Apple2 object
* @returns Keyboard component
*/
export const Keyboard = ({ apple2, e }: KeyboardProps) => {
export const Keyboard = ({ apple2, layout }: KeyboardProps) => {
const [pressed, setPressed] = useState<string[]>([]);
const [active, setActive] = useState<string[]>(['LOCK']);
const keys = useMemo(() => keysAsTuples(e ? keys2e : keys2), [e]);
const keys = useMemo(
() => keysAsTuples(layout === 'apple2e' ? keys2e : keys2),
[layout]
);

// Set global keystroke handler
useEffect(() => {
Expand Down
15 changes: 15 additions & 0 deletions js/components/util/systems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface SystemType {
e: boolean;
enhanced: boolean;
sectors: 13 | 16;
keyboardLayout: string;
}

// Enhanced Apple //e
Expand All @@ -14,6 +15,7 @@ export const defaultSystem = {
e: true,
enhanced: true,
sectors: 16,
keyboardLayout: 'apple2e',
} as const;

export const systemTypes: Record<string, Partial<SystemType>> = {
Expand All @@ -36,36 +38,49 @@ export const systemTypes: Record<string, Partial<SystemType>> = {
rom: 'intbasic',
characterRom: 'apple2_char',
e: false,
keyboardLayout: 'apple2',
},
apple213: {
rom: 'intbasic',
characterRom: 'apple2_char',
e: false,
sectors: 13,
keyboardLayout: 'apple2',
},
original: {
rom: 'original',
characterRom: 'apple2_char',
e: false,
keyboardLayout: 'apple2',
},
apple2jplus: {
rom: 'apple2j',
characterRom: 'apple2j_char',
e: false,
keyboardLayout: 'apple2',
},
apple2pig: {
rom: 'fpbasic',
characterRom: 'pigfont_char',
e: false,
keyboardLayout: 'apple2',
},
apple2lc: {
rom: 'fpbasic',
characterRom: 'apple2lc_char',
e: false,
keyboardLayout: 'apple2',
},
apple2plus: {
rom: 'fpbasic',
characterRom: 'apple2_char',
e: false,
keyboardLayout: 'apple2',
},
pravetz82: {
rom: 'pravetz82',
characterRom: 'pravetz82_char',
e: false,
keyboardLayout: 'apple2',
},
} as const;
15 changes: 14 additions & 1 deletion js/main2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,49 @@ const romVersion = prefs.readPref('computer_type2');
let rom: string;
let characterRom: string;
let sectors: SupportedSectors = 16;
let keyboardLayout: string;

switch (romVersion) {
case 'apple2':
rom = 'intbasic';
characterRom = 'apple2_char';
keyboardLayout = 'apple2';
break;
case 'apple213':
rom = 'intbasic';
characterRom = 'apple2_char';
sectors = 13;
keyboardLayout = 'apple2';
break;
case 'original':
rom = 'original';
characterRom = 'apple2_char';
keyboardLayout = 'apple2';
break;
case 'apple2jplus':
rom = 'apple2j';
characterRom = 'apple2j_char';
keyboardLayout = 'apple2';
break;
case 'apple2pig':
rom = 'fpbasic';
characterRom = 'pigfont_char';
keyboardLayout = 'apple2';
break;
case 'apple2lc':
rom = 'fpbasic';
characterRom = 'apple2lc_char';
keyboardLayout = 'apple2';
break;
case 'pravetz82':
rom = 'pravetz82';
characterRom = 'pravetz82_char';
keyboardLayout = 'pravetz82';
break;
default:
rom = 'fpbasic';
characterRom = 'apple2_char';
keyboardLayout = 'apple2';
}

const options = {
Expand Down Expand Up @@ -88,6 +101,6 @@ apple2.ready

cpu.addPageHandler(lc);

initUI(apple2, disk2, smartport, printer, false);
initUI(apple2, disk2, smartport, printer, false, keyboardLayout);
})
.catch(console.error);
7 changes: 6 additions & 1 deletion js/main2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,31 @@ const romVersion = prefs.readPref('computer_type2e');
let enhanced = false;
let rom: string;
let characterRom: string;
let keyboardLayout: string;

switch (romVersion) {
case 'apple2e':
rom = 'apple2e';
characterRom = 'apple2e_char';
keyboardLayout = 'apple2e';
break;
case 'apple2rm':
rom = 'apple2e';
characterRom = 'rmfont_char';
enhanced = true;
keyboardLayout = 'apple2e';
break;
case 'apple2ex':
rom = 'apple2ex';
characterRom = 'apple2enh_char';
enhanced = true;
keyboardLayout = 'apple2e';
break;
default:
rom = 'apple2enh';
characterRom = 'apple2enh_char';
enhanced = true;
keyboardLayout = 'apple2e';
}

const options = {
Expand Down Expand Up @@ -74,6 +79,6 @@ apple2.ready
io.setSlot(6, disk2);
io.setSlot(7, smartport);

initUI(apple2, disk2, smartport, printer, options.e);
initUI(apple2, disk2, smartport, printer, options.e, keyboardLayout);
})
.catch(console.error);
Loading

0 comments on commit 9d536ae

Please sign in to comment.