...
 
Commits (10)
......@@ -138,6 +138,11 @@ name = "gcc"
version = "0.3.54"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "hound"
version = "3.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "httparse"
version = "1.2.4"
......@@ -721,6 +726,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
name = "vesad"
version = "0.1.0"
dependencies = [
"hound 3.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"orbclient 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
"ransid 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -810,6 +817,7 @@ dependencies = [
"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
"checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb"
"checksum hound 3.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3dc93c30441ea05cb560395096ecce4d885986958c5be12e50daf4362f8a0e0"
"checksum httparse 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2f407128745b78abc95c0ffbe4e5d37427fdc0d45470710cfef8c44522a2e37"
"checksum hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)" = "368cb56b2740ebf4230520e2b90ebb0461e69034d85d1945febd9b3971426db2"
"checksum hyper-rustls 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "04535774f79684c99528944ebdb89756c945c027e55ce52faa245879d836c8fb"
......
......@@ -365,7 +365,7 @@ impl StreamBuffer {
let len = min(self.block_size(), buf.len());
print!("Phys: {:X} Virt: {:X} Offset: {:X} Len: {:X}\n", self.phys(), self.addr(), self.current_block() * self.block_size(), len);
// print!("Phys: {:X} Virt: {:X} Offset: {:X} Len: {:X}\n", self.phys(), self.addr(), self.current_block() * self.block_size(), len);
unsafe {
copy_nonoverlapping(buf.as_ptr(), (self.addr() + self.current_block() * self.block_size()) as * mut u8, len);
}
......
......@@ -7,20 +7,20 @@ class = 1
subclass = 6
command = ["ahcid", "$NAME", "$BAR5", "$IRQ"]
# bgad
[[drivers]]
name = "QEMU Graphics Array"
class = 3
vendor = 4660
device = 4369
command = ["bgad", "$NAME", "$BAR0"]
[[drivers]]
name = "VirtualBox Graphics Array"
class = 3
vendor = 33006
device = 48879
command = ["bgad", "$NAME", "$BAR0"]
# # bgad
# [[drivers]]
# name = "QEMU Graphics Array"
# class = 3
# vendor = 4660
# device = 4369
# command = ["bgad", "$NAME", "$BAR0"]
#
# [[drivers]]
# name = "VirtualBox Graphics Array"
# class = 3
# vendor = 33006
# device = 48879
# command = ["bgad", "$NAME", "$BAR0"]
# nvmed
[[drivers]]
......@@ -29,10 +29,10 @@ class = 1
subclass = 8
command = ["nvmed", "$NAME", "$BAR0", "$IRQ"]
# vboxd
[[drivers]]
name = "VirtualBox Guest Device"
class = 8
vendor = 33006
device = 51966
command = ["vboxd", "$NAME", "$BAR0", "$BAR1", "$IRQ"]
# # vboxd
# [[drivers]]
# name = "VirtualBox Guest Device"
# class = 8
# vendor = 33006
# device = 51966
# command = ["vboxd", "$NAME", "$BAR0", "$BAR1", "$IRQ"]
......@@ -3,10 +3,12 @@ name = "vesad"
version = "0.1.0"
[dependencies]
hound = "3.3"
lazy_static = "1.0"
orbclient = "0.3"
ransid = "0.4"
rusttype = { version = "0.2", optional = true }
redox_syscall = "0.1"
[features]
default = []
default = ["rusttype"]
/
/(_____________ ____
\ /______)\ | |
:\ | / \:| |:::::::::: : .. . : .. . . :. .
\_____| / | \| |______
___ / ________ \... . . .
\______________ \ | | /.. . . . . .
\ |__| /
--x--x-----x----\______ |-/_____/-x--x-xx--x-- - -x -- - - -- - - -
. . . . . . . . . . . .\____|. . . . . .
-------------------------------------------------------------------------------
>> perfect dos vga 437 - general information >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-------------------------------------------------------------------------------
"Perfect DOS VGA 437" and "Perfect DOS VGA 437 Win" are truetype fonts
designed to emulate the MS-DOS/Text mode standard font, used on VGA monitors,
with the 437 Codepage (standard US/International). This is a "bitmap" font,
meaning it emulates a bitmap font and can only be used at a given size (8 or
multiples of it like 16, 24, 32, etc). It's optimized for Flash too, so it
won't produce antialias if used at round positions.
There are two fonts available. "Perfect DOS VGA 437" uses the original DOS
codepage 437. It should be used, for example, if you're opening DOS ASCII
files on notepad or another windows-based editor. Since it's faithful to the
original DOS codes, it won't accent correctly in windows ("é" would produce
something different, not an "e" with an acute).
There's also "Perfect DOS VGA 437 Win" which is the exactly same font adapted
to a windows codepage. This should use accented characters correctly but won't
work if you're opening a DOS-based text file.
UPDATE: this is a new version, updated in august/2008. It has fixed leading
metrics for Mac systems.
-------------------------------------------------------------------------------
>> perfect dos vga 437 - creation process >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-------------------------------------------------------------------------------
This font was created to be used on a Flash-based ANSi viewer I'm working. To
create it, I created a small Quick Basic program to write all characters on
screen,
CLS
FOR l = 0 TO 255
charWrite 1 + (l MOD 20), 1 + (l \ 20) * 6 + (l MOD 2), LTRIM$(RTRIM$(STR$(l))) + CHR$(l)
NEXT
SUB charWrite (lin, col, char$)
DEF SEG = &HB800
FOR i = 1 TO LEN(char$)
POKE ((lin - 1) * 160) + ((col - 2 + i) * 2), ASC(MID$(char$, i, 1))
IF (i = LEN(char$)) THEN POKE ((lin - 1) * 160) + ((col - 2 + i) * 2) + 1, 113
NEXT
END SUB
Then captured the text screen using SCREEN THIEF (a very, very old screen
capture TSR program which converts text screens to images accurately). I then
recreated the font polygon by polygon on Fontlab, while looking at the image
on Photoshop. No conversion took place.
-------------------------------------------------------------------------------
>> author >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-------------------------------------------------------------------------------
zeh fernando remembers the old days. SMASH DAH FUCKING ENTAH.
http://www.fatorcaos.com.br
rorshack ^ maiden brazil
-------------------------------------------------------------------------------
^zehPULLSdahTRICK^kudosOUTtoWHOkeepsITreal^smashDAHfuckingENTAH!!!^lowres4ever^
-------------------------------------------------------------------------------
Copyright 2011, The VT323 Project Authors (peter.hull@oikoi.com)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
use std::fs::OpenOptions;
use std::io::Write;
use std::sync::Mutex;
use std::{thread, time};
struct Data {
i: usize,
buffers: Vec<Box<[u8; 16384]>>,
}
impl Data {
fn new() -> Data {
let mut buffers = Vec::new();
for _i in 0..64 {
buffers.push(Box::new([0; 16384]));
}
Data {
i: 0,
buffers: buffers,
}
}
fn queue(&mut self, buf: &[i16]) {
let mut i = 0;
for &sample in buf.iter() {
self.buffers[(self.i + (i + 16383)/16384) % 64][i % 16384] += sample as u8;
i += 1;
self.buffers[(self.i + (i + 16383)/16384) % 64][i % 16384] += (sample >> 8) as u8;
i += 1;
}
}
fn unqueue(&mut self, buf: &mut [u8; 16384]) {
for i in 0..buf.len() {
buf[i] = self.buffers[self.i][i];
self.buffers[self.i][i] = 0;
}
self.i = (self.i + 1) % 64;
}
}
lazy_static! {
static ref DATA: Mutex<Data> = Mutex::new(Data::new());
}
pub fn queue(buf: &[i16]) {
let mut data = DATA.lock().unwrap();
data.queue(buf);
}
pub fn thread() {
let mut audio = loop {
match OpenOptions::new().write(true).open("audio:") {
Ok(ok) => {
eprintln!("opened audio:");
break ok;
},
Err(err) => {
eprintln!("failed to open audio:: {}", err);
thread::sleep(time::Duration::new(1, 0));
}
}
};
let mut buf = [0; 16384];
loop {
{
let mut data = DATA.lock().unwrap();
data.unqueue(&mut buf);
}
audio.write(&buf).unwrap();
}
}
......@@ -3,6 +3,7 @@ extern crate rusttype;
use alloc::allocator::{Alloc, Layout};
use alloc::heap::Heap;
use orbclient;
use std::{cmp, slice};
use primitive::{fast_set32, fast_set64, fast_copy};
......@@ -10,17 +11,14 @@ use primitive::{fast_set32, fast_set64, fast_copy};
#[cfg(feature="rusttype")]
use self::rusttype::{Font, FontCollection, Scale, point};
#[cfg(not(feature="rusttype"))]
use orbclient::FONT;
#[cfg(feature="rusttype")]
static FONT: &'static [u8] = include_bytes!("../../../res/fonts/DejaVuSansMono.ttf");
static FONT: &'static [u8] = include_bytes!("../res/DOS437/Perfect DOS VGA 437 Win.ttf");
#[cfg(feature="rusttype")]
static FONT_BOLD: &'static [u8] = include_bytes!("../../../res/fonts/DejaVuSansMono-Bold.ttf");
static FONT_BOLD: &'static [u8] = include_bytes!("../res/DOS437/Perfect DOS VGA 437 Win.ttf");
#[cfg(feature="rusttype")]
static FONT_BOLD_ITALIC: &'static [u8] = include_bytes!("../../../res/fonts/DejaVuSansMono-BoldOblique.ttf");
static FONT_BOLD_ITALIC: &'static [u8] = include_bytes!("../res/DOS437/Perfect DOS VGA 437 Win.ttf");
#[cfg(feature="rusttype")]
static FONT_ITALIC: &'static [u8] = include_bytes!("../../../res/fonts/DejaVuSansMono-Oblique.ttf");
static FONT_ITALIC: &'static [u8] = include_bytes!("../res/DOS437/Perfect DOS VGA 437 Win.ttf");
/// A display
pub struct Display {
......@@ -171,16 +169,14 @@ impl Display {
}
}
/// Draw a character
#[cfg(not(feature="rusttype"))]
pub fn char(&mut self, x: usize, y: usize, character: char, color: u32, _bold: bool, _italic: bool) {
fn char_unifont(&mut self, x: usize, y: usize, character: char, color: u32) {
if x + 8 <= self.width && y + 16 <= self.height {
let mut dst = self.offscreen.as_mut_ptr() as usize + (y * self.width + x) * 4;
let font_i = 16 * (character as usize);
if font_i + 16 <= FONT.len() {
if font_i + 16 <= orbclient::FONT.len() {
for row in 0..16 {
let row_data = FONT[font_i + row];
let row_data = orbclient::FONT[font_i + row];
for col in 0..8 {
if (row_data >> (7 - col)) & 1 == 1 {
unsafe { *((dst + col * 4) as *mut u32) = color; }
......@@ -192,6 +188,12 @@ impl Display {
}
}
/// Draw a character
#[cfg(not(feature="rusttype"))]
pub fn char(&mut self, x: usize, y: usize, character: char, color: u32, _bold: bool, _italic: bool) {
self.char_unifont(x, y, character, color);
}
/// Draw a character
#[cfg(feature="rusttype")]
pub fn char(&mut self, x: usize, y: usize, character: char, color: u32, bold: bool, italic: bool) {
......@@ -209,7 +211,7 @@ impl Display {
&self.font
};
if let Some(glyph) = font.glyph(character){
if let Some(glyph) = font.glyph(character) {
let scale = Scale::uniform(16.0);
let v_metrics = font.v_metrics(scale);
let point = point(0.0, v_metrics.ascent);
......@@ -241,7 +243,11 @@ impl Display {
}
}
});
} else {
self.char_unifont(x, y, character, color);
}
} else {
self.char_unifont(x, y, character, color);
}
}
......
#![deny(warnings)]
//#![deny(warnings)]
#![feature(alloc)]
#![feature(allocator_api)]
#![feature(asm)]
#![feature(nll)]
extern crate alloc;
extern crate hound;
#[macro_use]
extern crate lazy_static;
extern crate orbclient;
extern crate syscall;
......@@ -16,6 +20,7 @@ use mode_info::VBEModeInfo;
use primitive::fast_set64;
use scheme::DisplayScheme;
pub mod audio;
pub mod display;
pub mod mode_info;
pub mod primitive;
......@@ -52,6 +57,8 @@ fn main() {
if physbaseptr > 0 {
// Daemonize
if unsafe { syscall::clone(0).unwrap() } == 0 {
::std::thread::spawn(audio::thread);
let mut socket = File::create(":display").expect("vesad: failed to create display scheme");
let size = width * height;
......@@ -62,8 +69,6 @@ fn main() {
let mut scheme = DisplayScheme::new(width, height, onscreen, &spec);
syscall::setrens(0, 0).expect("vesad: failed to enter null namespace");
let mut blocked = Vec::new();
loop {
let mut packet = Packet::default();
......
extern crate ransid;
use std::collections::{BTreeSet, VecDeque};
use std::fs::File;
use std::io::Read;
use std::ptr;
use orbclient::{Event, EventOption};
use hound::WavReader;
use orbclient::{self, Event, EventOption, KeyEvent};
use syscall::error::*;
use audio;
use display::Display;
use screen::Screen;
fn play(name: &str) {
let path = format!("file:/sfx/{}.wav", name);
match WavReader::open(&path) {
Ok(mut wav) => {
let data: Vec<i16> = wav.into_samples::<i16>().map(|x| x.unwrap_or(0)).collect();
audio::queue(&data);
},
Err(err) => {
eprintln!("failed to open {}: {}", path, err);
}
}
}
fn announce(key_event: KeyEvent) {
if key_event.pressed {
match key_event.scancode {
orbclient::K_A => play("A"),
orbclient::K_B => play("B"),
orbclient::K_C => play("C"),
orbclient::K_D => play("D"),
orbclient::K_E => play("E"),
orbclient::K_F => play("F"),
orbclient::K_G => play("G"),
orbclient::K_H => play("H"),
orbclient::K_I => play("I"),
orbclient::K_J => play("J"),
orbclient::K_K => play("K"),
orbclient::K_L => play("L"),
orbclient::K_M => play("M"),
orbclient::K_N => play("N"),
orbclient::K_O => play("O"),
orbclient::K_P => play("P"),
orbclient::K_Q => play("Q"),
orbclient::K_R => play("R"),
orbclient::K_S => play("S"),
orbclient::K_T => play("T"),
orbclient::K_U => play("U"),
orbclient::K_V => play("V"),
orbclient::K_W => play("W"),
orbclient::K_X => play("X"),
orbclient::K_Y => play("Y"),
orbclient::K_Z => play("Z"),
orbclient::K_0 => play("0"),
orbclient::K_1 => play("1"),
orbclient::K_2 => play("2"),
orbclient::K_3 => play("3"),
orbclient::K_4 => play("4"),
orbclient::K_5 => play("5"),
orbclient::K_6 => play("6"),
orbclient::K_7 => play("7"),
orbclient::K_8 => play("8"),
orbclient::K_9 => play("9"),
// Tick/tilde key
orbclient::K_TICK => play("GraveAccent_Tilde"),
// Minus/underline key
orbclient::K_MINUS => play("Hyphen_Minus"),
// Equals/plus key
orbclient::K_EQUALS => play("Equals"),
// Backslash/pipe key
orbclient::K_BACKSLASH => play("BackSlash"),
// Bracket open key
orbclient::K_BRACE_OPEN => play("LeftSquareBracket"),
// Bracket close key
orbclient::K_BRACE_CLOSE => play("RightSquareBracket"),
// Semicolon key
orbclient::K_SEMICOLON => play("SemiColon"),
// Quote key
orbclient::K_QUOTE => play("Apostrophe"),
// Comma key
orbclient::K_COMMA => play("Comma"),
// Period key
orbclient::K_PERIOD => play("Period"),
// Slash key
orbclient::K_SLASH => play("ForwardSlash"),
// Backspace key
orbclient::K_BKSP => play("Backspace"),
// Space key
orbclient::K_SPACE => play("Space"),
// Tab key
orbclient::K_TAB => play("Tab"),
// Capslock
orbclient::K_CAPS => play("CapsLock"),
// Left shift
orbclient::K_LEFT_SHIFT => play("LeftShift"),
// Right shift
orbclient::K_RIGHT_SHIFT => play("LeftShift"),
// Control key
orbclient::K_CTRL => play("LeftControl"),
// Alt key
orbclient::K_ALT => play("LeftAlt"),
// Enter key
orbclient::K_ENTER => play("Enter"),
// Escape key
orbclient::K_ESC => play("Escape"),
// F1 key
orbclient::K_F1 => play("F1"),
// F2 key
orbclient::K_F2 => play("F2"),
// F3 key
orbclient::K_F3 => play("F3"),
// F4 key
orbclient::K_F4 => play("F4"),
// F5 key
orbclient::K_F5 => play("F5"),
// F6 key
orbclient::K_F6 => play("F6"),
// F7 key
orbclient::K_F7 => play("F7"),
// F8 key
orbclient::K_F8 => play("F8"),
// F9 key
orbclient::K_F9 => play("F9"),
// F10 key
orbclient::K_F10 => play("F10"),
// Home key
orbclient::K_HOME => play("Home"),
// Up key
orbclient::K_UP => play("Up"),
// Page up key
orbclient::K_PGUP => play("PageUp"),
// Left key
orbclient::K_LEFT => play("Left"),
// Right key
orbclient::K_RIGHT => play("Right"),
// End key
orbclient::K_END => play("End"),
// Down key
orbclient::K_DOWN => play("Down"),
// Page down key
orbclient::K_PGDN => play("PageDown"),
// Delete key
orbclient::K_DEL => play("Delete"),
// F11 key
orbclient::K_F11 => play("F11"),
// F12 key
orbclient::K_F12 => play("F12"),
_ => ()
}
}
}
pub struct TextScreen {
pub console: ransid::Console,
pub display: Display,
......@@ -20,8 +168,11 @@ pub struct TextScreen {
impl TextScreen {
pub fn new(display: Display) -> TextScreen {
let mut console = ransid::Console::new(display.width/8, display.height/16);
console.state.foreground_default = ransid::Color::Ansi(11);
console.state.background_default = ransid::Color::Ansi(12);
TextScreen {
console: ransid::Console::new(display.width/8, display.height/16),
console: console,
display: display,
changed: BTreeSet::new(),
ctrl: false,
......@@ -60,6 +211,7 @@ impl Screen for TextScreen {
match event.to_option() {
EventOption::Key(key_event) => {
announce(key_event);
if key_event.scancode == 0x1D {
self.ctrl = key_event.pressed;
} else if key_event.pressed {
......@@ -115,9 +267,7 @@ impl Screen for TextScreen {
_ => () //TODO: Mouse in terminal
}
for &b in buf.iter() {
self.input.push_back(b);
}
self.input.extend(buf);
}
fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
......