Skip to content

Commit c76e98c

Browse files
authored
Merge pull request #167 from dbalsom/0.4.0/audio_latency
0.4.0/audio latency
2 parents a9f536e + 335c795 commit c76e98c

File tree

52 files changed

+1106
-434
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1106
-434
lines changed

.gitignore

+51
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,54 @@ icon.png
9999
/test-gen/
100100

101101

102+
/exo_demo/configs/keyboard_layouts/keyboard_IT.toml
103+
/exo_demo/configs/keyboard_layouts/keyboard_UK.toml
104+
/exo_demo/configs/keyboard_layouts/keyboard_US.toml
105+
/exo_demo/configs/machines/acid88.toml
106+
/exo_demo/configs/machines/compaq_portable.toml
107+
/exo_demo/configs/machines/config_overlays.toml
108+
/exo_demo/configs/machines/generic_xt.toml
109+
/exo_demo/configs/machines/ibm5150.toml
110+
/exo_demo/configs/machines/ibm5160.toml
111+
/exo_demo/configs/machines/ibm_pcjr.toml
112+
/exo_demo/configs/machines/readme.md
113+
/exo_demo/configs/machines/s100.toml
114+
/exo_demo/configs/machines/tandy1000.toml
115+
/exo_demo/media/floppies/Demos/8088MPH (Compo version).img
116+
/exo_demo/media/floppies/Demos/8088MPH (Final Version).img
117+
/exo_demo/media/floppies/Demos/Area 5150 (Compo Version).img
118+
/exo_demo/media/floppies/Demos/AUTOEXEC.BAT
119+
/exo_demo/media/floppies/Demos/CGADEMO (Codemasters).img
120+
/exo_demo/media/roms/GLaBIOS/parking/GLABIOS_0.2.6_8EC.ROM
121+
/exo_demo/media/roms/GLaBIOS/parking/GLABIOS_0.2.6_8P.ROM
122+
/exo_demo/media/roms/GLaBIOS/parking/GLABIOS_0.2.6_8PC.ROM
123+
/exo_demo/media/roms/GLaBIOS/parking/GLABIOS_0.2.6_8T.ROM
124+
/exo_demo/media/roms/GLaBIOS/parking/GLABIOS_0.2.6_8TC.ROM
125+
/exo_demo/media/roms/GLaBIOS/parking/GLABIOS_0.2.6_8X.ROM
126+
/exo_demo/media/roms/GLaBIOS/parking/GLABIOS_0.2.6_8XC.ROM
127+
/exo_demo/media/roms/GLaBIOS/GLABIOS_0.2.5_8PC.ROM
128+
/exo_demo/media/roms/GLaBIOS/GLABIOS_0.2.5_8TC_PEN.ROM
129+
/exo_demo/media/roms/GLaBIOS/GLABIOS_0.2.5_8XC.ROM
130+
/exo_demo/media/roms/GLaBIOS/GLABIOS_0.2.6_8P.ROM
131+
/exo_demo/media/roms/GLaBIOS/GLABIOS_0.2.6_8PC.ROM
132+
/exo_demo/media/roms/GLaBIOS/GLABIOS_0.2.6_8T.ROM
133+
/exo_demo/media/roms/GLaBIOS/GLABIOS_0.2.6_8TC.ROM
134+
/exo_demo/media/roms/GLaBIOS/GLABIOS_0.2.6_8X.ROM
135+
/exo_demo/media/roms/GLaBIOS/GLABIOS_0.2.6_8XC.ROM
136+
/exo_demo/media/roms/romdef.toml
137+
/exo_demo/media/roms/romdef_ast.toml
138+
/exo_demo/media/roms/romdef_compaq.toml
139+
/exo_demo/media/roms/romdef_glabios.toml
140+
/exo_demo/media/roms/romdef_ibm.toml
141+
/exo_demo/media/roms/romdef_ibm_pcjr.toml
142+
/exo_demo/media/roms/romdef_megabios.toml
143+
/exo_demo/media/roms/romdef_s100.toml
144+
/exo_demo/media/roms/romdef_tandy.toml
145+
/exo_demo/8088mph.toml
146+
/exo_demo/area5150.toml
147+
/exo_demo/cgademo.toml
148+
/exo_demo/exo_demo.7z
149+
/exo_demo/run Area5150.bat
150+
/exo_demo/run cgademo.bat
151+
/exo_demo/run 8088mph.bat
152+
/util/mquit/mquit.com

Cargo.lock

+10-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+20-14
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ with both demos.
5050

5151
Currently, MartyPC can emulate an original IBM 5150 PC, 5160 XT, or a generic XT clone machine.
5252

53-
Preliminary support for the IBM PCJr and Tandy 1000 is present as of 0.2.1. These machines may be buggy and unstable.
53+
Preliminary support for the IBM PCjr and Tandy 1000 is present as of 0.2.1. These machines may be buggy and unstable.
5454

5555
### Device Support
5656
MartyPC emulates the following devices:
@@ -59,31 +59,37 @@ MartyPC emulates the following devices:
5959
* **Intel 8088** - A cycle-accurate implementation of the Intel 8088 including the asynchronous BIU, processor instruction queue and prefetch logic. Tested for correctness and cycle-accuracy against hardware.
6060
* **NEC V20** - A preliminary implementation of the NEC V20 CPU. Cycle-based, but not fully cycle-accurate or as performant as the real thing, as timings have not been adjusted from the 8088 that was used as a base. All native-mode V20 instructions are implemented and tested for correctness against hardware.
6161

62-
* ### Video Cards:
62+
* ### System Hardware:
63+
* **8255 PPI** - Low level keyboard emulation is supported via the PPI and keyboard shift register. Supports the 'turbo bit' found in TurboXT clones.
64+
* **8259 PIC** - Mostly complete, but still missing advanced features such as priority rotation and nested modes.
65+
* **8253 PIT** - Highly accurate, supporting PCM audio.
66+
* **8237 DMAC** - Mostly implemented, but DMA transfers are currently "faked". DRAM refresh DMA is simulated using a scheduling system.
67+
* **8250 UART** - Supports serial passthrough or mouse emulation.
68+
* **Game Port** - Supports two analog joysticks with two buttons each.
69+
* **Parallel Port** - Enough of a basic parallel port is emulated to be detected, but is not really functional for any purpose yet.
70+
71+
* ### Video Devices:
6372
* **CGA** - A dynamic, cycle-or-character clocked implementation of the IBM CGA including the Motorola MC6845 CRTC controller allows MartyPC to run demanding PC demos like 8088MPH and Area5150. MartyPC takes a unique approach to PC video card emulation by simulating the entire display field - including overscan. Composite output and monitor simulation is supported, via reenigne's excellent composite conversion code (also used by DOSBox and 86Box)
6473
* **TGA** - A character-clocked implementation of the PCJr and Tandy Graphics Video Gate Array. Work in progress.
6574
* **MDA** - A character-clocked implementation of the IBM MDA card built on the Motorola MC6845 CRTC controller. An MDA adapter can be installed alongside a CGA or EGA card for multi-monitor operation.
6675
* **Hercules** - The MDA device optionally supports emulation of the Hercules Graphics Adapter.
6776
* **EGA** - A character-clocked implementation of the IBM EGA builds on the techniques used developing the CGA. It is structured to replicate the logical functions of each of the LSI chips on the original hardware. It supports redefinable fonts, vsync interrupts and per-scanline pel-panning for smooth scrolling.
77+
* **VGA** - IBM VGA card emulation is in development, but graphics modes such as Mode 13h and Mode X are working.
78+
79+
* ### Sound Devices:
80+
* **PC Speaker** - Not really its own sound device, the PC speaker is driven by MartyPC's timer chip emulation. It can produce reasonable quality PWM audio in demos such as 8088MPH, Area5150, and Magic Mushroom.
81+
* **Adlib** - The original Adlib Music Synthesizer is emulated, with OPL2 emulation provided by nuked-opl3, via my [opl3-rs](https://github.com/dbalsom/opl3-rs) bidings. This is a bit CPU heavy, so you'll need a fast computer.
6882

6983
* ### Storage Devices:
7084
* **µPD765 FDC** - Currently robust enough to support both DOS and Minix operating systems. MartyPC uses my disk
7185
image library, [fluxfox](https://github.com/dbalsom/fluxfox/), which allows it to support a wide variety of PC disk image formats.
7286
MartyPC's FDC emulation is still not as accurate as I'd like it to be, but it can support a number
7387
of copy-protected titles, given a disk image of the appropriate format.
74-
* **IBM/Xebec 20MB HDC** - Emulated with basic VHD support. MartyPC currently supports a single disk geometry of 20MB.
75-
* **PCJr Cartridges** - PCJr cartridge ROMs are supported, in JrRipCart (.JRC) format
88+
* **IBM/Xebec 20MB HDC** - Emulated with basic VHD support. MartyPC currently supports a single disk geometry of 20MB when using this controller.
89+
* **XTIDE** - Emulation of an XTIDE Rev 2 board allows MartyPC to support a wide range of hard disk formats. This emulation is still in early stages, and may be a bit rough around the edges. Not all ATA commands are implemented.
90+
* **PCjr Cartridges** - PCjr cartridge ROMs are supported, in JrRipCart (.JRC) format
7691

77-
* ### System Hardware:
78-
* **8255 PPI** - Low level keyboard emulation is supported via the PPI and keyboard shift register. Supports the 'turbo bit' found in TurboXT clones.
79-
* **8259 PIC** - Mostly complete, but still missing advanced features such as priority rotation and nested modes.
80-
* **8253 PIT** - Highly accurate, supporting PCM audio.
81-
* **8237 DMAC** - Mostly implemented, but DMA transfers are currently "faked". DRAM refresh DMA is simulated using a scheduling system.
82-
* **8250 UART** - Supports serial passthrough or mouse emulation. Still a bit incomplete (fails tests in CheckIt)
83-
* **Game Port** - Supports two analog joysticks with two buttons each.
84-
* **PC Speaker** - Although sometimes a little glitchy, it can produce reasonable PCM audio in demos such as 8088MPH, Area5150, and Magic Mushroom.
85-
86-
* ### Add-on Cards:
92+
* ### Memory Expansion Devices:
8793
* **LoTech 2MB EMS Card** - 2MB of EMS memory is made available via the [LoTech EMS board](https://www.lo-tech.co.uk/wiki/Lo-tech_2MB_EMS_Board).
8894

8995
* ### Input Devices:

crates/frontends/martypc_eframe/src/app.rs

+42-7
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ use crate::event_loop::web_keyboard::handle_web_key_event;
5858

5959
use crossbeam_channel::{Receiver, Sender};
6060

61-
use egui::{Context, RawInput, Sense, ViewportId};
61+
use egui::{Context, RawInput, Sense, ViewportCommand, ViewportId};
6262

6363
use crate::emulator_builder::builder::EmuBuilderError;
6464
#[cfg(target_arch = "wasm32")]
@@ -80,6 +80,7 @@ pub struct MartyApp {
8080
current_size: egui::Vec2,
8181
last_size: egui::Vec2,
8282
focused: bool,
83+
hide_menu: bool,
8384
#[serde(skip)]
8485
gui: GuiRenderContext,
8586
#[serde(skip)]
@@ -107,6 +108,7 @@ impl Default for MartyApp {
107108
let (sender, receiver) = crossbeam_channel::bounded(1);
108109

109110
Self {
111+
hide_menu: false,
110112
current_size: egui::Vec2::ZERO,
111113
last_size: egui::Vec2::INFINITY,
112114
focused: false,
@@ -136,7 +138,7 @@ impl MartyApp {
136138
/// We split app initialization into two parts, since we can't make the callback eframe passes
137139
/// the creation context to async. So we first create the app, then let eframe call `init` with
138140
/// the partially initialized app - it should have the emulator built by then.
139-
pub async fn new(_native_options: &mut MartyAppNewOptions) -> Self {
141+
pub async fn new(native_options: &mut MartyAppNewOptions) -> Self {
140142
// Build the emulator.
141143
let mut emu_builder = EmulatorBuilder::default();
142144
let emu_result;
@@ -226,8 +228,8 @@ impl MartyApp {
226228
}
227229
EmuBuilderError::BadMachineConfig(e) =>{
228230
format!("MartyPC encountered an error reading its Machine Configuration files!\n\
229-
At least one machine configuration TOML file in /configs/machines appears to be invalid or corrupt.\n\n\
230-
The error reported was:\n{e}")
231+
The specified machine configuration could not be found:\n\n\
232+
'{e}'")
231233
}
232234
EmuBuilderError::IOError(e) => e.to_string(),
233235
EmuBuilderError::Other(e) => e.to_string(),
@@ -253,6 +255,14 @@ impl MartyApp {
253255
let mut timestep_manager = TimestepManager::new();
254256
timestep_manager.set_cpu_mhz(emu.machine.get_cpu_mhz());
255257

258+
// Set eframe's NativeOptions for fullscreen if specified by config
259+
if let Some(window) = emu.config.emulator.window.get_mut(0) {
260+
if window.fullscreen {
261+
native_options.viewport.inner_size = None;
262+
native_options.viewport.fullscreen = Some(true);
263+
}
264+
}
265+
256266
MartyApp {
257267
emu: Some(emu),
258268
tm: timestep_manager,
@@ -275,11 +285,19 @@ impl MartyApp {
275285

276286
let mut emu = self.emu.take().expect("Emulator should have been Some, but was None");
277287

288+
// Apply fullscreen configuration now (doesn't seem to work applying to NativeOptions in new())
289+
290+
if let Some(window) = emu.config.emulator.window.get_mut(0) {
291+
let _ = &cc
292+
.egui_ctx
293+
.send_viewport_cmd(ViewportCommand::Fullscreen(window.fullscreen));
294+
}
295+
278296
// Get a list of video devices from machine.
279297
let cardlist = emu.machine.bus().enumerate_videocards();
280298

281299
// Find the maximum refresh rate of all video cards
282-
let mut highest_rate = 50;
300+
let mut highest_rate = 50.0;
283301
for card in cardlist.iter() {
284302
let rate = emu.machine.bus().video(&card).unwrap().get_refresh_rate();
285303
if rate > highest_rate {
@@ -290,12 +308,20 @@ impl MartyApp {
290308
self.tm.set_emu_update_rate(highest_rate);
291309
self.tm.set_emu_render_rate(highest_rate);
292310

311+
self.hide_menu = if emu.config.emulator.demo_mode {
312+
true
313+
}
314+
else {
315+
emu.config.gui.disabled
316+
};
317+
318+
// TODO: Re-implement this stuff?
293319
// Create GUI parameters for the Display Manager.
294320
let gui_options = DmGuiOptions {
295321
enabled: !emu.config.gui.disabled,
296322
theme: emu.config.gui.theme,
297323
menu_theme: emu.config.gui.menu_theme,
298-
menubar_h: EGUI_MENU_BAR_HEIGHT, // TODO: Dynamically measure the height of the egui menu bar somehow
324+
menubar_h: EGUI_MENU_BAR_HEIGHT, // ignored on eframe
299325
zoom: emu.config.gui.zoom.unwrap_or(1.0),
300326
debug_drawing: false,
301327
};
@@ -420,6 +446,12 @@ impl MartyApp {
420446
}
421447
});
422448

449+
// Initialize sound info
450+
// -- Update sound sources
451+
if let Some(si) = emu.si.as_ref() {
452+
emu.gui.init_sound_info(si.info());
453+
}
454+
423455
// Insert floppies specified in config.
424456
match emu.insert_floppies(emu.sender.clone()) {
425457
Ok(_) => {
@@ -530,6 +562,7 @@ impl eframe::App for MartyApp {
530562
handle_window_event(
531563
emu,
532564
self.dm.as_mut().unwrap(),
565+
ctx.clone(),
533566
&mut self.tm,
534567
event.0,
535568
event.1,
@@ -557,7 +590,7 @@ impl eframe::App for MartyApp {
557590
let dm = self.dm.as_mut().unwrap();
558591
// Process timestep.
559592
process_update(emu, dm, &mut self.tm);
560-
handle_thread_event(emu);
593+
handle_thread_event(emu, ctx);
561594

562595
let fill_color = dm
563596
.main_display_target()
@@ -569,9 +602,11 @@ impl eframe::App for MartyApp {
569602
.and_then(|c| Some(MartyColor::from_u24(c).to_color32()));
570603

571604
let show_bezel = emu.gui.primary_video_has_bezel();
605+
572606
// Draw the emulator GUI.
573607
self.gui.show(
574608
&mut emu.gui,
609+
!self.hide_menu,
575610
fill_color,
576611
|ctx| {
577612
if let Some(DisplayTargetType::GuiWidget) = dm.display_type(DtHandle::MAIN) {

0 commit comments

Comments
 (0)