Add Pravetz 82 support (#204)

* Initial support for Pravetz 82

* Add character ROM for Pravetz 82 (#2)

* Initial working Pravetz 82 keyboard (#3)

* Fix row1 wrapping
This commit is contained in:
Kaloyan Tenchov 2023-11-26 14:40:22 -05:00 committed by GitHub
parent aaca31f96b
commit 9d536ae367
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 2157 additions and 21 deletions

View File

@ -410,6 +410,10 @@ a.button:hover {
width: 570px;
}
#keyboard.layout-pravetz82 .row {
width: 610px;
}
.apple2e #keyboard .row {
width: 610px;
}
@ -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;
}
@ -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;
}

View File

@ -41,6 +41,7 @@ export interface Apple2Props {
gl: boolean;
rom: string;
sectors: SupportedSectors;
keyboardLayout: string;
}
/**
@ -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>();
@ -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>

View File

@ -96,7 +96,7 @@ export const Key = ({
*/
export interface KeyboardProps {
apple2: Apple2Impl | undefined;
e: boolean;
layout: string;
}
/**
@ -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(() => {

View File

@ -4,6 +4,7 @@ export interface SystemType {
e: boolean;
enhanced: boolean;
sectors: 13 | 16;
keyboardLayout: string;
}
// Enhanced Apple //e
@ -14,6 +15,7 @@ export const defaultSystem = {
e: true,
enhanced: true,
sectors: 16,
keyboardLayout: 'apple2e',
} as const;
export const systemTypes: Record<string, Partial<SystemType>> = {
@ -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;

View File

@ -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 = {
@ -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);

View File

@ -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 = {
@ -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);

View File

@ -0,0 +1,262 @@
import { ReadonlyUint8Array } from '../../types';
const pravetz82_charset = new Uint8Array([
0x00, 0x1c, 0x22, 0x2a, 0x2e, 0x2c, 0x20, 0x1e,
0x00, 0x08, 0x14, 0x22, 0x22, 0x3e, 0x22, 0x22,
0x00, 0x3c, 0x22, 0x22, 0x3c, 0x22, 0x22, 0x3c,
0x00, 0x1c, 0x22, 0x20, 0x20, 0x20, 0x22, 0x1c,
0x00, 0x3c, 0x22, 0x22, 0x22, 0x22, 0x22, 0x3c,
0x00, 0x3e, 0x20, 0x20, 0x3c, 0x20, 0x20, 0x3e,
0x00, 0x3e, 0x20, 0x20, 0x3c, 0x20, 0x20, 0x20,
0x00, 0x1e, 0x20, 0x20, 0x20, 0x26, 0x22, 0x1e,
0x00, 0x22, 0x22, 0x22, 0x3e, 0x22, 0x22, 0x22,
0x00, 0x1c, 0x08, 0x08, 0x08, 0x08, 0x08, 0x1c,
0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x22, 0x1c,
0x00, 0x22, 0x24, 0x28, 0x30, 0x28, 0x24, 0x22,
0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3e,
0x00, 0x22, 0x36, 0x2a, 0x2a, 0x22, 0x22, 0x22,
0x00, 0x22, 0x22, 0x32, 0x2a, 0x26, 0x22, 0x22,
0x00, 0x1c, 0x22, 0x22, 0x22, 0x22, 0x22, 0x1c,
0x00, 0x3c, 0x22, 0x22, 0x3c, 0x20, 0x20, 0x20,
0x00, 0x1c, 0x22, 0x22, 0x22, 0x2a, 0x24, 0x1a,
0x00, 0x3c, 0x22, 0x22, 0x3c, 0x28, 0x24, 0x22,
0x00, 0x1c, 0x22, 0x20, 0x1c, 0x02, 0x22, 0x1c,
0x00, 0x3e, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
0x00, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x1c,
0x00, 0x22, 0x22, 0x22, 0x22, 0x22, 0x14, 0x08,
0x00, 0x22, 0x22, 0x22, 0x2a, 0x2a, 0x36, 0x22,
0x00, 0x22, 0x22, 0x14, 0x08, 0x14, 0x22, 0x22,
0x00, 0x22, 0x22, 0x14, 0x08, 0x08, 0x08, 0x08,
0x00, 0x3e, 0x02, 0x04, 0x08, 0x10, 0x20, 0x3e,
0x00, 0x3e, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3e,
0x00, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00,
0x00, 0x3e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x3e,
0x00, 0x00, 0x00, 0x08, 0x14, 0x22, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x08,
0x00, 0x14, 0x14, 0x14, 0x00, 0x00, 0x00, 0x00,
0x00, 0x14, 0x14, 0x3e, 0x14, 0x3e, 0x14, 0x14,
0x00, 0x08, 0x1e, 0x28, 0x1c, 0x0a, 0x3c, 0x08,
0x00, 0x30, 0x32, 0x04, 0x08, 0x10, 0x26, 0x06,
0x00, 0x10, 0x28, 0x28, 0x10, 0x2a, 0x24, 0x1a,
0x00, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00,
0x00, 0x08, 0x10, 0x20, 0x20, 0x20, 0x10, 0x08,
0x00, 0x08, 0x04, 0x02, 0x02, 0x02, 0x04, 0x08,
0x00, 0x08, 0x2a, 0x1c, 0x08, 0x1c, 0x2a, 0x08,
0x00, 0x00, 0x08, 0x08, 0x3e, 0x08, 0x08, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x10,
0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
0x00, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00,
0x00, 0x1c, 0x22, 0x26, 0x2a, 0x32, 0x22, 0x1c,
0x00, 0x08, 0x18, 0x08, 0x08, 0x08, 0x08, 0x1c,
0x00, 0x1c, 0x22, 0x02, 0x0c, 0x10, 0x20, 0x3e,
0x00, 0x3e, 0x02, 0x04, 0x0c, 0x02, 0x22, 0x1c,
0x00, 0x04, 0x0c, 0x14, 0x24, 0x3e, 0x04, 0x04,
0x00, 0x3e, 0x20, 0x3c, 0x02, 0x02, 0x22, 0x1c,
0x00, 0x0e, 0x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x88,
0x80, 0xb0, 0xb2, 0x84, 0x88, 0x90, 0xa6, 0x86,
0x80, 0x90, 0xa8, 0xa8, 0x90, 0xaa, 0xa4, 0x9a,
0x80, 0x88, 0x88, 0x88, 0x80, 0x80, 0x80, 0x80,
0x80, 0x88, 0x90, 0xa0, 0xa0, 0xa0, 0x90, 0x88,
0x80, 0x88, 0x84, 0x82, 0x82, 0x82, 0x84, 0x88,
0x80, 0x88, 0xaa, 0x9c, 0x88, 0x9c, 0xaa, 0x88,
0x80, 0x80, 0x88, 0x88, 0xbe, 0x88, 0x88, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x88, 0x88, 0x90,
0x80, 0x80, 0x80, 0x80, 0xbe, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x88,
0x80, 0x80, 0x82, 0x84, 0x88, 0x90, 0xa0, 0x80,
0x80, 0x9c, 0xa2, 0xa6, 0xaa, 0xb2, 0xa2, 0x9c,
0x80, 0x88, 0x98, 0x88, 0x88, 0x88, 0x88, 0x9c,
0x80, 0x9c, 0xa2, 0x82, 0x8c, 0x90, 0xa0, 0xbe,
0x80, 0xbe, 0x82, 0x84, 0x8c, 0x82, 0xa2, 0x9c,
0x80, 0x84, 0x8c, 0x94, 0xa4, 0xbe, 0x84, 0x84,
0x80, 0xbe, 0xa0, 0xbc, 0x82, 0x82, 0xa2, 0x9c,
0x80, 0x8e, 0x90, 0xa0, 0xbc, 0xa2, 0xa2, 0x9c,
0x80, 0xbe, 0x82, 0x84, 0x88, 0x90, 0x90, 0x90,
0x80, 0x9c, 0xa2, 0xa2, 0x9c, 0xa2, 0xa2, 0x9c,
0x80, 0x9c, 0xa2, 0xa2, 0x9e, 0x82, 0x84, 0xb8,
0x80, 0x80, 0x80, 0x88, 0x80, 0x88, 0x80, 0x80,
0x80, 0x80, 0x80, 0x88, 0x80, 0x88, 0x88, 0x90,
0x80, 0x84, 0x88, 0x90, 0xa0, 0x90, 0x88, 0x84,
0x80, 0x80, 0x80, 0xbe, 0x80, 0xbe, 0x80, 0x80,
0x80, 0x90, 0x88, 0x84, 0x82, 0x84, 0x88, 0x90,
0x80, 0x9c, 0xa2, 0x84, 0x88, 0x88, 0x80, 0x88,
0x00, 0x1c, 0x22, 0x2a, 0x2e, 0x2c, 0x20, 0x1e,
0x00, 0x08, 0x14, 0x22, 0x22, 0x3e, 0x22, 0x22,
0x00, 0x3c, 0x22, 0x22, 0x3c, 0x22, 0x22, 0x3c,
0x00, 0x1c, 0x22, 0x20, 0x20, 0x20, 0x22, 0x1c,
0x00, 0x3c, 0x22, 0x22, 0x22, 0x22, 0x22, 0x3c,
0x00, 0x3e, 0x20, 0x20, 0x3c, 0x20, 0x20, 0x3e,
0x00, 0x3e, 0x20, 0x20, 0x3c, 0x20, 0x20, 0x20,
0x00, 0x1e, 0x20, 0x20, 0x20, 0x26, 0x22, 0x1e,
0x00, 0x22, 0x22, 0x22, 0x3e, 0x22, 0x22, 0x22,
0x00, 0x1c, 0x08, 0x08, 0x08, 0x08, 0x08, 0x1c,
0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x22, 0x1c,
0x00, 0x22, 0x24, 0x28, 0x30, 0x28, 0x24, 0x22,
0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3e,
0x00, 0x22, 0x36, 0x2a, 0x2a, 0x22, 0x22, 0x22,
0x00, 0x22, 0x22, 0x32, 0x2a, 0x26, 0x22, 0x22,
0x00, 0x1c, 0x22, 0x22, 0x22, 0x22, 0x22, 0x1c,
0x00, 0x3c, 0x22, 0x22, 0x3c, 0x20, 0x20, 0x20,
0x00, 0x1c, 0x22, 0x22, 0x22, 0x2a, 0x24, 0x1a,
0x00, 0x3c, 0x22, 0x22, 0x3c, 0x28, 0x24, 0x22,
0x00, 0x1c, 0x22, 0x20, 0x1c, 0x02, 0x22, 0x1c,
0x00, 0x3e, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
0x00, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x1c,
0x00, 0x22, 0x22, 0x22, 0x22, 0x22, 0x14, 0x08,
0x00, 0x22, 0x22, 0x22, 0x2a, 0x2a, 0x36, 0x22,
0x00, 0x22, 0x22, 0x14, 0x08, 0x14, 0x22, 0x22,
0x00, 0x22, 0x22, 0x14, 0x08, 0x08, 0x08, 0x08,
0x00, 0x3e, 0x02, 0x04, 0x08, 0x10, 0x20, 0x3e,
0x00, 0x3e, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3e,
0x00, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00,
0x00, 0x3e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x3e,
0x00, 0x00, 0x00, 0x08, 0x14, 0x22, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x08,
0x00, 0x14, 0x14, 0x14, 0x00, 0x00, 0x00, 0x00,
0x00, 0x14, 0x14, 0x3e, 0x14, 0x3e, 0x14, 0x14,
0x00, 0x08, 0x1e, 0x28, 0x1c, 0x0a, 0x3c, 0x08,
0x00, 0x30, 0x32, 0x04, 0x08, 0x10, 0x26, 0x06,
0x00, 0x10, 0x28, 0x28, 0x10, 0x2a, 0x24, 0x1a,
0x00, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00,
0x00, 0x08, 0x10, 0x20, 0x20, 0x20, 0x10, 0x08,
0x00, 0x08, 0x04, 0x02, 0x02, 0x02, 0x04, 0x08,
0x00, 0x08, 0x2a, 0x1c, 0x08, 0x1c, 0x2a, 0x08,
0x00, 0x00, 0x08, 0x08, 0x3e, 0x08, 0x08, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x10,
0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
0x00, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00,
0x00, 0x1c, 0x22, 0x26, 0x2a, 0x32, 0x22, 0x1c,
0x00, 0x08, 0x18, 0x08, 0x08, 0x08, 0x08, 0x1c,
0x00, 0x1c, 0x22, 0x02, 0x0c, 0x10, 0x20, 0x3e,
0x00, 0x3e, 0x02, 0x04, 0x0c, 0x02, 0x22, 0x1c,
0x00, 0x04, 0x0c, 0x14, 0x24, 0x3e, 0x04, 0x04,
0x00, 0x3e, 0x20, 0x3c, 0x02, 0x02, 0x22, 0x1c,
0x00, 0x0e, 0x10, 0x20, 0x3c, 0x22, 0x22, 0x1c,
0x00, 0x3e, 0x02, 0x04, 0x08, 0x10, 0x10, 0x10,
0x00, 0x1c, 0x22, 0x22, 0x1c, 0x22, 0x22, 0x1c,
0x00, 0x1c, 0x22, 0x22, 0x1e, 0x02, 0x04, 0x38,
0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00,
0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x08, 0x10,
0x00, 0x04, 0x08, 0x10, 0x20, 0x10, 0x08, 0x04,
0x00, 0x00, 0x00, 0x3e, 0x00, 0x3e, 0x00, 0x00,
0x00, 0x10, 0x08, 0x04, 0x02, 0x04, 0x08, 0x10,
0x00, 0x1c, 0x22, 0x04, 0x08, 0x08, 0x00, 0x08,
0x00, 0x24, 0x2a, 0x2a, 0x3a, 0x2a, 0x2a, 0x24,
0x80, 0x88, 0x94, 0xa2, 0xa2, 0xbe, 0xa2, 0xa2,
0x80, 0xbc, 0xa2, 0xa2, 0xbc, 0xa2, 0xa2, 0xbc,
0x80, 0x9c, 0xa2, 0xa0, 0xa0, 0xa0, 0xa2, 0x9c,
0x80, 0xbc, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xbc,
0x80, 0xbe, 0xa0, 0xa0, 0xbc, 0xa0, 0xa0, 0xbe,
0x80, 0xbe, 0xa0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x80,
0x00, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x3e, 0x02,
0x00, 0x22, 0x22, 0x22, 0x1e, 0x02, 0x02, 0x02,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xbe,
0x00, 0x1c, 0x22, 0x2a, 0x2e, 0x2c, 0x20, 0x1e,
0x00, 0x08, 0x14, 0x22, 0x22, 0x3e, 0x22, 0x22,
0x00, 0x3c, 0x20, 0x20, 0x3c, 0x22, 0x22, 0x3c,
0x00, 0x24, 0x24, 0x24, 0x24, 0x24, 0x3e, 0x02,
0x00, 0x0c, 0x12, 0x12, 0x12, 0x12, 0x3e, 0x22,
0x00, 0x3e, 0x20, 0x20, 0x3c, 0x20, 0x20, 0x3e,
0x00, 0x08, 0x1c, 0x2a, 0x2a, 0x2a, 0x1c, 0x08,
0x00, 0x3e, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x00, 0x22, 0x22, 0x14, 0x08, 0x14, 0x22, 0x22,
0x00, 0x22, 0x22, 0x26, 0x2a, 0x32, 0x22, 0x22,
0x00, 0x2a, 0x22, 0x26, 0x2a, 0x32, 0x22, 0x22,
0x00, 0x22, 0x24, 0x28, 0x30, 0x28, 0x24, 0x22,
0x00, 0x0e, 0x12, 0x12, 0x12, 0x12, 0x12, 0x22,
0x00, 0x22, 0x36, 0x2a, 0x2a, 0x22, 0x22, 0x22,
0x00, 0x22, 0x22, 0x22, 0x3e, 0x22, 0x22, 0x22,
0x00, 0x1c, 0x22, 0x22, 0x22, 0x22, 0x22, 0x1c,
0x00, 0x3e, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
0x00, 0x1e, 0x22, 0x22, 0x1e, 0x0a, 0x12, 0x22,
0x00, 0x3c, 0x22, 0x22, 0x3c, 0x20, 0x20, 0x20,
0x00, 0x1c, 0x22, 0x20, 0x20, 0x20, 0x22, 0x1c,
0x00, 0x3e, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
0x00, 0x22, 0x22, 0x22, 0x1e, 0x02, 0x02, 0x3c,
0x00, 0x2a, 0x2a, 0x1c, 0x1c, 0x2a, 0x2a, 0x2a,
0x00, 0x3c, 0x22, 0x22, 0x3c, 0x22, 0x22, 0x3c,
0x00, 0x20, 0x20, 0x20, 0x3c, 0x22, 0x22, 0x3c,
0x00, 0x30, 0x10, 0x10, 0x1c, 0x12, 0x12, 0x1c,
0x00, 0x3c, 0x02, 0x02, 0x1c, 0x02, 0x02, 0x3c,
0x00, 0x3e, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3e,
0x00, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x3e, 0x02,
0x00, 0x3e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x3e,
0x00, 0x00, 0x00, 0x08, 0x14, 0x22, 0x00, 0x00,
0x00, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e,
]) as ReadonlyUint8Array;
export default pravetz82_charset;

1547
js/roms/system/pravetz82.ts Normal file

File diff suppressed because it is too large Load Diff

View File

@ -900,7 +900,8 @@ function onLoaded(
disk2: DiskII,
massStorage: MassStorage<BlockFormat>,
printer: Printer,
e: boolean
e: boolean,
keyboardLayout: string
) {
_apple2 = apple2;
cpu = _apple2.getCPU();
@ -930,7 +931,7 @@ function onLoaded(
MicroModal.init();
keyboard = new KeyBoard(cpu, io, e);
keyboard = new KeyBoard(cpu, io, keyboardLayout);
keyboard.create('#keyboard');
keyboard.setFunction('F1', () => cpu.reset());
keyboard.setFunction('F2', (event) => {
@ -1053,9 +1054,10 @@ export function initUI(
disk2: DiskII,
massStorage: MassStorage<BlockFormat>,
printer: Printer,
e: boolean
e: boolean,
keyboardLayout: string
) {
window.addEventListener('load', () => {
onLoaded(apple2, disk2, massStorage, printer, e);
onLoaded(apple2, disk2, massStorage, printer, e, keyboardLayout);
});
}

View File

@ -200,7 +200,26 @@ export const keys2e = [
type Key2e = DeepMemberOf<typeof keys2e>;
type Key = Key2 | Key2e;
// prettier-ignore
const keyspravetz82 = [
[
['!', '"', '#', '¤', '%', '&', '\'', '(', ')', '0', '*', '=', '﹁', 'RST'],
['ОСВ', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '@', 'RPT', 'RETURN'],
['МК', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', '+', '[', ']', '&darr;'],
['ЛАТ', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', 'ЛАТ', АТ2'],
['ВКЛ', '&nbsp;']
], [
['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', ':', '-', 'Ч', 'RST'],
['ОСВ', 'Я', 'В', 'Е', 'Р', 'Т', 'Ъ', 'У', 'И', 'О', 'П', 'Ю', 'RPT', 'RETURN'],
['МК', 'А', 'С', 'Д', 'Ф', 'Г', 'Х', 'Й', 'К', 'Л', ';', 'Ш', 'Щ', '&darr;'],
['ЛАТ', 'З', 'Ь', 'Ц', 'Ж', 'Б', 'Н', 'М', ',', '.', '/', 'ЛАТ', АТ2'],
['ВКЛ', '&nbsp;']
]
] as const;
type KeyPravetz82 = DeepMemberOf<typeof keyspravetz82>;
type Key = Key2 | Key2e | KeyPravetz82;
type KeyFunction = (key: KeyboardEvent) => void;
@ -223,9 +242,20 @@ export default class KeyBoard {
constructor(
private cpu: CPU6502,
private io: Apple2IO,
private e: boolean
private layout: string
) {
this.keys = e ? keys2e : keys2;
switch (this.layout) {
case 'apple2e':
this.keys = keys2e;
break;
case 'pravetz82':
this.keys = keyspravetz82;
this.capslocked = false; // Pravetz 82 starts with CAPS LOCK off.
break;
default:
this.keys = keys2;
break;
}
window.addEventListener('keydown', this.keydown);
window.addEventListener('keyup', this.keyup);
@ -264,7 +294,9 @@ export default class KeyBoard {
}
shiftKey(down: boolean) {
const shiftKeys = this.kb.querySelectorAll('.key-SHIFT');
const shiftKeys = this.kb.querySelectorAll(
this.layout !== 'pravetz82' ? '.key-SHIFT' : '.key-ЛАТ'
);
this.shifted = down;
if (down) {
this.io.buttonUp(2);
@ -280,7 +312,9 @@ export default class KeyBoard {
}
controlKey(down: boolean) {
const ctrlKey = this.kb.querySelector('.key-CTRL');
const ctrlKey = this.kb.querySelector(
this.layout !== 'pravetz82' ? '.key-CTRL' : '.key-МК'
);
this.controlled = down;
if (down) {
ctrlKey!.classList.add('active');
@ -327,7 +361,9 @@ export default class KeyBoard {
* otherwise the used state is set to true.
*/
capslockKey(down?: boolean | undefined) {
const capsLock = this.kb.querySelector('.key-LOCK');
const capsLock = this.kb.querySelector(
this.layout !== 'pravetz82' ? '.key-LOCK' : '.key-ЛАТ2'
);
if (arguments.length === 0) {
if (this.capslockKeyUsed) {
@ -357,6 +393,7 @@ export default class KeyBoard {
create(el: string) {
this.kb = document.querySelector(el)!;
this.kb.classList.add('layout-' + this.layout);
let x, y, row, key, label, label1, label2;
const buildLabel = (k: string) => {
@ -424,7 +461,14 @@ export default class KeyBoard {
ev.preventDefault();
target.classList.add('pressed');
let key: string = this.shifted ? key2 : key1;
let key: string;
if (this.layout !== 'pravetz82') {
key = this.shifted ? key2 : key1;
} else {
// In Pravetz 82, the operation of the shift key is inverted.
// The top row (cyrillic) is used by default and shift switches to using the bottow row (latin).
key = this.shifted ? key1 : key2;
}
switch (key) {
case 'BELL':
key = 'G';
@ -445,7 +489,11 @@ export default class KeyBoard {
key = '\x15';
break;
case '&darr;':
key = '\x0A';
if (this.layout !== 'pravetz82') {
key = '\x0A';
} else {
// On Pravetz 82 this key has no action.
}
break;
case '&uarr;':
key = '\x0B';
@ -460,24 +508,151 @@ export default class KeyBoard {
break;
}
if (this.layout === 'pravetz82') {
// Pravetz 82 specific remapping.
// Lower-case lattin letters are replaced with cyrillic capital letters.
switch (key) {
// First row.
case 'Ч':
key = '^';
break;
case '﹁':
// FIXME: Which character should this map to?
break;
// Second row.
case 'ОСВ': // Pravetz 82 ESC key in cyrillic.
key = '\x1B';
break;
case 'Я':
key = 'q';
break;
case 'В':
key = 'w';
break;
case 'Е':
key = 'e';
break;
case 'Р':
key = 'r';
break;
case 'Т':
key = 't';
break;
case 'Ъ':
key = 'y';
break;
case 'У':
key = 'u';
break;
case 'И':
key = 'i';
break;
case 'О':
key = 'o';
break;
case 'П':
key = 'p';
break;
case 'Ю':
key = '@';
break;
case '@':
key = '`';
break;
// Third row.
case 'А':
key = 'a';
break;
case 'С':
key = 's';
break;
case 'Д':
key = 'd';
break;
case 'Ф':
key = 'f';
break;
case 'Г':
key = 'g';
break;
case 'Х':
key = 'h';
break;
case 'Й':
key = 'j';
break;
case 'К':
key = 'k';
break;
case 'Л':
key = 'l';
break;
case 'Ш':
key = '[';
break;
case 'Щ':
key = ']';
break;
case '[':
key = '{';
break;
case ']':
key = '}';
break;
// Fourth row.
case 'З':
key = 'z';
break;
case 'Ь':
key = 'x';
break;
case 'Ц':
key = 'c';
break;
case 'Ж':
key = 'v';
break;
case 'Б':
key = 'b';
break;
case 'Н':
key = 'n';
break;
case 'М':
key = 'm';
break;
default:
break;
}
}
if (key.length > 1) {
switch (key) {
case 'SHIFT':
case 'ЛАТ': // Shift on Pravetz 82 switches to cyrillic.
this.shiftKey(!this.shifted);
break;
case 'CTRL':
case 'МК': // Pravetz 82 CTRL key in cyrillic.
this.controlKey(!this.controlled);
break;
case 'CAPS':
case 'LOCK':
case АТ2': // CAPS LOCK on Pravetz 82 switches between cyrillic and latin.
this.capslockKey(undefined);
break;
case 'POW':
case 'POWER':
case 'ВКЛ': // Pravetz 82 power key in cyrillic.
if (window.confirm('Power Cycle?'))
window.location.reload();
break;
case 'RESET':
case 'RST':
this.cpu.reset();
break;
case 'OPEN_APPLE':
@ -486,6 +661,9 @@ export default class KeyBoard {
case 'CLOSED_APPLE':
this.optionKey(!this.optioned);
break;
case 'RPT': // Pravetz 82 "repeat" key.
// Do nothing.
break;
default:
break;
}
@ -493,13 +671,22 @@ export default class KeyBoard {
if (this.controlled && key >= '@' && key <= '_') {
this.io.keyDown(key.charCodeAt(0) - 0x40);
} else if (
this.e &&
this.layout === 'apple2e' &&
!this.shifted &&
!this.capslocked &&
key >= 'A' &&
key <= 'Z'
) {
this.io.keyDown(key.charCodeAt(0) + 0x20);
} else if (
this.layout === 'pravetz82' &&
!this.shifted &&
this.capslocked &&
key >= 'a' &&
key <= 'z'
) {
// CAPS LOCK on Pravetz 82 switches between cyrillic and latin.
this.io.keyDown(key.charCodeAt(0) - 0x20);
} else {
this.io.keyDown(key.charCodeAt(0));
}
@ -516,7 +703,10 @@ export default class KeyBoard {
}
private keydown = (evt: KeyboardEvent) => {
if (!this.dialogOpen() && (!evt.metaKey || evt.ctrlKey || this.e)) {
if (
!this.dialogOpen() &&
(!evt.metaKey || evt.ctrlKey || this.layout === 'apple2e')
) {
evt.preventDefault();
const key = this.mapKeyEvent(evt);

View File

@ -77,6 +77,10 @@ export class System implements OptionHandler {
value: 'apple2pig',
name: 'Apple ][+ (pig font)',
},
{
value: 'pravetz82',
name: 'Pravetz 82',
},
],
},
],