Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Added basic mode7 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrueger committed Feb 20, 2024
1 parent 1b018dd commit 0c93f7a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/com/telnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ impl ComTelnetImpl {
Terminal::Avatar => buf.extend_from_slice(b"AVATAR"),
Terminal::Rip => buf.extend_from_slice(b"RIP"),
Terminal::IGS => buf.extend_from_slice(b"IGS"),
Terminal::Mode7 => buf.extend_from_slice(b"MODE7"),
}
buf.extend([telnet_cmd::Iac, telnet_cmd::SE]);

Expand Down
15 changes: 13 additions & 2 deletions src/data/addresses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::TerminalResult;
use chrono::{Duration, Utc};
use icy_engine::ansi::{BaudEmulation, MusicOption};
use icy_engine::igs::CommandExecutor;
use icy_engine::{ansi, ascii, atascii, avatar, petscii, rip, viewdata, BufferParser, UnicodeConverter};
use icy_engine::{ansi, ascii, atascii, avatar, petscii, rip, viewdata, mode7, BufferParser, UnicodeConverter};
use notify::{Config, RecommendedWatcher, RecursiveMode, Watcher};
use regex::Regex;
use std::fs::File;
Expand All @@ -27,12 +27,13 @@ pub enum Terminal {
PETscii,
ATAscii,
ViewData,
Mode7,
Rip,
IGS,
}

impl Terminal {
pub const ALL: [Terminal; 8] = [
pub const ALL: [Terminal; 9] = [
Terminal::Ansi,
Terminal::Avatar,
Terminal::Ascii,
Expand All @@ -41,6 +42,7 @@ impl Terminal {
Terminal::ViewData,
Terminal::Rip,
Terminal::IGS,
Terminal::Mode7,
];

#[must_use]
Expand All @@ -57,6 +59,7 @@ impl Terminal {
Terminal::PETscii => Box::<petscii::Parser>::default(),
Terminal::ATAscii => Box::<atascii::Parser>::default(),
Terminal::ViewData => Box::<viewdata::Parser>::default(),
Terminal::Mode7 => Box::<mode7::Parser>::default(),
Terminal::Rip => {
let mut parser = ansi::Parser::default();
parser.ansi_music = use_ansi_music;
Expand All @@ -79,6 +82,7 @@ impl Terminal {
Terminal::PETscii => Box::<petscii::CharConverter>::default(),
Terminal::ATAscii => Box::<atascii::CharConverter>::default(),
Terminal::ViewData => Box::<viewdata::CharConverter>::default(),
Terminal::Mode7 => Box::<mode7::CharConverter>::default(),
}
}
}
Expand All @@ -92,6 +96,7 @@ impl Display for Terminal {
Terminal::PETscii => write!(f, "PETSCII"),
Terminal::ATAscii => write!(f, "ATASCII"),
Terminal::ViewData => write!(f, "VIEWDATA"),
Terminal::Mode7 => write!(f, "Mode7"),
Terminal::Rip => write!(f, "RIPscrip"),
Terminal::IGS => write!(f, "IGS (Experimental)"),
}
Expand Down Expand Up @@ -588,6 +593,7 @@ fn parse_address(value: &Value) -> Address {
"viewdata" => result.terminal_type = Terminal::ViewData,
"rip" => result.terminal_type = Terminal::Rip,
"igs" => result.terminal_type = Terminal::IGS,
"mode7" => result.terminal_type = Terminal::Mode7,
_ => {}
}
}
Expand All @@ -611,6 +617,7 @@ fn parse_address(value: &Value) -> Address {
"videotex" => result.screen_mode = ScreenMode::Videotex,
"rip" => result.screen_mode = ScreenMode::Rip,
"igs" => result.screen_mode = ScreenMode::Igs,
"mode7" => result.screen_mode = ScreenMode::Mode7,
_ => {
if let Some(caps) = vga_regex.captures(lowercase) {
let mut width = 80;
Expand Down Expand Up @@ -773,6 +780,10 @@ fn parse_legacy_address(value: &Value) -> Address {
result.screen_mode = ScreenMode::Videotex;
result.terminal_type = Terminal::ViewData;
}
"Mode7" => {
result.screen_mode = ScreenMode::Mode7;
result.terminal_type = Terminal::Mode7;
}
"Rip" => {
result.screen_mode = ScreenMode::Rip;
result.terminal_type = Terminal::Rip;
Expand Down
10 changes: 8 additions & 2 deletions src/ui/terminal_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use eframe::{
egui::{self, CursorIcon, PointerButton},
epaint::Vec2,
};
use egui::{Event, ImageButton, Modifiers, RichText};
use egui::{ImageButton, Modifiers, RichText};
use i18n_embed_fl::fl;
use icy_engine::{Position, Selection, TextPane};

Expand Down Expand Up @@ -386,8 +386,14 @@ impl MainWindow {
self.handle_key_press(ui, &response, egui::Key::C, Modifiers::CTRL);
}
egui::Event::Key {
key, pressed: true, modifiers, ..
key, pressed: true, modifiers, physical_key, ..
} => {
let key = if let Some(key) = physical_key {
key
} else {
key
};
println!("Key: {key:?}, modifiers:{modifiers:?}");
self.handle_key_press(ui, &response, key, modifiers);
}
_ => {}
Expand Down
14 changes: 9 additions & 5 deletions src/ui/util/screen_modes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub enum ScreenMode {
Vic,
Antic,
Videotex,
Mode7,
Rip,
Igs,
}
Expand All @@ -35,7 +36,7 @@ impl ScreenMode {
}
}

pub const DEFAULT_MODES: [ScreenMode; 13] = [
pub const DEFAULT_MODES: [ScreenMode; 14] = [
ScreenMode::Vga(80, 25),
ScreenMode::Vga(80, 50),
ScreenMode::Vga(132, 37),
Expand All @@ -49,6 +50,7 @@ pub const DEFAULT_MODES: [ScreenMode; 13] = [
ScreenMode::Rip,
ScreenMode::Videotex,
ScreenMode::Igs,
ScreenMode::Mode7,
];

impl Display for ScreenMode {
Expand All @@ -69,6 +71,7 @@ impl Display for ScreenMode {
ScreenMode::Default => write!(f, "Default"),
ScreenMode::Rip => write!(f, "RIPscrip"),
ScreenMode::Igs => write!(f, "Igs"),
ScreenMode::Mode7 => write!(f, "Mode7"),
}
}
}
Expand All @@ -81,14 +84,15 @@ impl ScreenMode {
ScreenMode::Vic => BufferInputMode::PETscii,
ScreenMode::Antic => BufferInputMode::ATAscii,
ScreenMode::Videotex => BufferInputMode::ViewData,
ScreenMode::Mode7 => BufferInputMode::CP437
}
}

pub fn get_window_size(&self) -> Size {
match self {
// ScreenMode::Cga(w, h) | ScreenMode::Ega(w, h) |
ScreenMode::Vga(w, h) => Size::new(*w, *h),
ScreenMode::Vic | ScreenMode::Igs => Size::new(40, 25),
ScreenMode::Vic | ScreenMode::Igs | ScreenMode::Mode7 => Size::new(40, 25),
ScreenMode::Antic | ScreenMode::Videotex => Size::new(40, 24),
ScreenMode::Default => Size::new(80, 25),
ScreenMode::Rip => Size::new(80, 44),
Expand Down Expand Up @@ -134,7 +138,7 @@ impl ScreenMode {
.set_font(0, BitFont::from_bytes("", ATARI).unwrap());
main_window.buffer_view.lock().get_buffer_mut().palette = Palette::from_slice(&ATARI_DEFAULT_PALETTE);
}
ScreenMode::Videotex => {
ScreenMode::Videotex | ScreenMode::Mode7 => {
main_window.buffer_view.lock().get_buffer_mut().clear_font_table();
main_window
.buffer_view
Expand Down Expand Up @@ -175,7 +179,7 @@ impl ScreenMode {
ScreenMode::Default | ScreenMode::Vga(_, _) | ScreenMode::Rip => Color::new(0xAA, 0x00, 0xAA),
ScreenMode::Vic => Color::new(0x37, 0x39, 0xC4),
ScreenMode::Antic => Color::new(0x09, 0x51, 0x83),
ScreenMode::Videotex => Color::new(0, 0, 0),
ScreenMode::Videotex | ScreenMode::Mode7 => Color::new(0, 0, 0),
ScreenMode::Igs => Color::new(0, 0, 0),
}
}
Expand All @@ -186,7 +190,7 @@ impl ScreenMode {
ScreenMode::Default | ScreenMode::Vga(_, _) | ScreenMode::Rip => Color::new(0xAA, 0xAA, 0xAA),
ScreenMode::Vic => Color::new(0xB0, 0x3F, 0xB6),
ScreenMode::Antic => Color::new(0xFF, 0xFF, 0xFF),
ScreenMode::Videotex => Color::new(0xFF, 0xFF, 0xFF),
ScreenMode::Videotex | ScreenMode::Mode7 => Color::new(0xFF, 0xFF, 0xFF),
ScreenMode::Igs => Color::new(0xFF, 0xFF, 0xFF),
}
}
Expand Down

0 comments on commit 0c93f7a

Please sign in to comment.