Skip to content

Commit

Permalink
Keyboard and character drawing tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
breqdev committed Nov 16, 2023
1 parent bf2e783 commit 9db50f3
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 299 deletions.
3 changes: 3 additions & 0 deletions aiie/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Source:
https://mirrors.apple2.org.za/ftp.apple.asimov.net/emulators/rom_images/
apple_2e_unenhanced_rom.zip
209 changes: 0 additions & 209 deletions src/keyboard/apple.rs

This file was deleted.

78 changes: 25 additions & 53 deletions src/systems/aiie/keyboard.rs
Original file line number Diff line number Diff line change
@@ -1,55 +1,27 @@
use crate::keyboard::apple::AppleKeys;
use crate::keyboard::{KeyAdapter, KeyState, KeySymbol};

/// The keyboard matrix found on a Commodore 64.
/// Source: <https://www.c64-wiki.com/wiki/Keyboard>.
pub const KEYBOARD_MAPPING: [[AppleKeys; 10]; 8] = {
use AppleKeys::*;
pub struct AppleIISymbolAdapter;

[
[
Esc, Digit1, Digit2, Digit3, Digit4, Digit6, Digit5, Digit7, Digit8, Digit9,
],
[Tab, Q, W, E, R, Y, T, U, I, O],
[A, D, S, H, F, G, J, K, Semicolon, L],
[Z, X, C, V, B, N, M, Comma, Period, Backslash],
[
NumDivide, NumLeft, Num0, Num1, Num2, Num3, Slash, Equals, Digit0, Minus,
],
[
NumRightParen,
NumEsc,
Num4,
Num5,
Num6,
Num7,
Grave,
P,
LeftBracket,
RightBracket,
],
[
NumMultiply,
NumRight,
Digit8,
Digit9,
NumPeriod,
NumPlus,
Return,
UpArrow,
Space,
Apostrophe,
],
[
NumPrint,
NumSpace,
NumLeftParen,
NumMinus,
NumReturn,
NumComma,
Del,
DownArrow,
LeftArrow,
RightArrow,
],
]
};
impl KeyAdapter<KeySymbol, u8> for AppleIISymbolAdapter {
fn map(state: &KeyState<KeySymbol>) -> KeyState<u8> {
let mut mapped = KeyState::new();

for symbol in state.pressed() {
use KeySymbol::*;

let mapped_symbol = match symbol {
&Char(c) => Some(c as u8),
Return => Some(0x0D), // Carriage Return
Backspace => Some(0x08),
Escape => Some(0x1B),
_ => None,
};

if let Some(symbol) = mapped_symbol {
mapped.press(symbol);
}
}

mapped
}
}
Loading

0 comments on commit 9db50f3

Please sign in to comment.