mirror of
https://github.com/transistorfet/moa.git
synced 2025-04-08 10:38:02 +00:00
WIP
This commit is contained in:
parent
62a484d317
commit
2c2b8e58b4
@ -77,7 +77,7 @@ fn initialize_ym(ym_sound: TransmutableBox) -> Result<(), Error> {
|
||||
set_register(device, 0, 0x30, 0x71)?;
|
||||
set_register(device, 0, 0x34, 0x0D)?;
|
||||
set_register(device, 0, 0x38, 0x33)?;
|
||||
set_register(device, 0, 0x3C, 0x01)?;
|
||||
set_register(device, 0, 0x3C, 0x00)?;
|
||||
|
||||
set_register(device, 0, 0xA4, 0x22)?;
|
||||
set_register(device, 0, 0xA0, 0x69)?;
|
||||
|
@ -167,11 +167,11 @@ mod decode_tests {
|
||||
let mut tests = 0;
|
||||
let mut errors = 0;
|
||||
|
||||
//use super::super::testcases::{TimingCase, TIMING_TESTS};
|
||||
use super::super::testcases::{TimingCase, TIMING_TESTS};
|
||||
for case in TIMING_TESTS {
|
||||
tests += 1;
|
||||
let assembly_text = format!("{}", case.ins);
|
||||
print!("Testing assembling of {:?} ", assembly_text);
|
||||
print!("Testing assembling of {:?} from {:?}", assembly_text, case.ins);
|
||||
|
||||
let mut assembler = M68kAssembler::new(M68kType::MC68000);
|
||||
match assembler.assemble_words(&assembly_text) {
|
||||
|
@ -48,7 +48,7 @@ pub enum LogLevel {
|
||||
Debug,
|
||||
}
|
||||
|
||||
static mut LOG_LEVEL: LogLevel = LogLevel::Warning;
|
||||
static mut LOG_LEVEL: LogLevel = LogLevel::Info;
|
||||
|
||||
pub fn log_level() -> LogLevel {
|
||||
unsafe { LOG_LEVEL }
|
||||
|
@ -19,7 +19,9 @@ impl SineWave {
|
||||
}
|
||||
|
||||
pub fn set_frequency(&mut self, frequency: f32) {
|
||||
let ratio = self.frequency / frequency;
|
||||
self.frequency = frequency;
|
||||
self.position = (self.position as f32 * ratio) as usize;
|
||||
}
|
||||
|
||||
pub fn reset(&mut self) {
|
||||
@ -54,7 +56,9 @@ impl SquareWave {
|
||||
}
|
||||
|
||||
pub fn set_frequency(&mut self, frequency: f32) {
|
||||
let ratio = self.frequency / frequency;
|
||||
self.frequency = frequency;
|
||||
self.position = (self.position as f32 * ratio) as usize;
|
||||
}
|
||||
|
||||
pub fn reset(&mut self) {
|
||||
@ -106,7 +110,9 @@ impl SkewedSquareWave {
|
||||
}
|
||||
|
||||
pub fn set_frequency(&mut self, frequency: f32) {
|
||||
let ratio = self.frequency / frequency;
|
||||
self.frequency = frequency;
|
||||
self.position = (self.position as f32 * ratio) as usize;
|
||||
}
|
||||
|
||||
pub fn reset(&mut self) {
|
||||
|
@ -86,7 +86,8 @@ pub fn build_genesis<H: Host>(host: &mut H, options: SegaGenesisOptions) -> Resu
|
||||
system.add_addressable_device(0x00a00000, coproc_ram)?;
|
||||
system.add_addressable_device(0x00a04000, coproc_ym_sound)?;
|
||||
system.add_addressable_device(0x00a06000, coproc_register)?;
|
||||
system.add_addressable_device(0x00c00010, coproc_sn_sound)?;
|
||||
//system.add_addressable_device(0x00c00010, coproc_sn_sound)?;
|
||||
system.add_device("sn_sound", coproc_sn_sound.clone())?;
|
||||
system.add_device("coproc", wrap_transmutable(coproc))?;
|
||||
|
||||
|
||||
@ -97,7 +98,7 @@ pub fn build_genesis<H: Host>(host: &mut H, options: SegaGenesisOptions) -> Resu
|
||||
let coproc = genesis::coprocessor::CoprocessorCoordinator::new(reset, bus_request);
|
||||
system.add_addressable_device(0x00a11000, wrap_transmutable(coproc)).unwrap();
|
||||
|
||||
let vdp = genesis::ym7101::Ym7101::new(host, interrupt);
|
||||
let vdp = genesis::ym7101::Ym7101::new(host, interrupt, coproc_sn_sound);
|
||||
system.break_signal = Some(vdp.frame_complete.clone());
|
||||
system.add_peripheral("vdp", 0x00c00000, wrap_transmutable(vdp)).unwrap();
|
||||
|
||||
|
@ -5,7 +5,7 @@ use crate::error::Error;
|
||||
use crate::system::System;
|
||||
use crate::memory::dump_slice;
|
||||
use crate::signals::{EdgeSignal};
|
||||
use crate::devices::{Clock, ClockElapsed, Address, Addressable, Steppable, Inspectable, Transmutable, read_beu16};
|
||||
use crate::devices::{Clock, ClockElapsed, Address, Addressable, Steppable, Inspectable, Transmutable, TransmutableBox, read_beu16};
|
||||
use crate::host::traits::{Host, BlitableSurface, HostData};
|
||||
use crate::host::gfx::{Frame, FrameSwapper};
|
||||
|
||||
@ -678,13 +678,14 @@ impl Steppable for Ym7101 {
|
||||
pub struct Ym7101 {
|
||||
swapper: FrameSwapper,
|
||||
state: Ym7101State,
|
||||
sn_sound: TransmutableBox,
|
||||
|
||||
pub external_interrupt: HostData<bool>,
|
||||
pub frame_complete: EdgeSignal,
|
||||
}
|
||||
|
||||
impl Ym7101 {
|
||||
pub fn new<H: Host>(host: &mut H, external_interrupt: HostData<bool>) -> Ym7101 {
|
||||
pub fn new<H: Host>(host: &mut H, external_interrupt: HostData<bool>, sn_sound: TransmutableBox) -> Ym7101 {
|
||||
let swapper = FrameSwapper::new(320, 224);
|
||||
|
||||
host.add_window(FrameSwapper::to_boxed(swapper.clone())).unwrap();
|
||||
@ -692,6 +693,7 @@ impl Ym7101 {
|
||||
Ym7101 {
|
||||
swapper,
|
||||
state: Ym7101State::new(),
|
||||
sn_sound,
|
||||
external_interrupt,
|
||||
frame_complete: EdgeSignal::new(),
|
||||
}
|
||||
@ -834,6 +836,10 @@ impl Addressable for Ym7101 {
|
||||
}
|
||||
},
|
||||
|
||||
0x11 | 0x12 => {
|
||||
self.sn_sound.borrow_mut().as_addressable().unwrap().write(0, data)?;
|
||||
},
|
||||
|
||||
_ => { warning!("{}: !!! unhandled write to {:x} with {:?}", DEV_NAME, addr, data); },
|
||||
}
|
||||
Ok(())
|
||||
|
@ -41,7 +41,7 @@ impl ToneGenerator {
|
||||
}
|
||||
|
||||
pub fn get_sample(&mut self) -> f32 {
|
||||
self.wave.next().unwrap()
|
||||
self.wave.next().unwrap() / self.attenuation
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,20 +23,20 @@ impl AverageTimer {
|
||||
}
|
||||
|
||||
pub fn start(&mut self) {
|
||||
self.start = Some(Instant::now())
|
||||
//self.start = Some(Instant::now())
|
||||
}
|
||||
|
||||
pub fn end(&mut self) {
|
||||
let time = self.start.unwrap().elapsed().as_nanos() as u32;
|
||||
//let time = self.start.unwrap().elapsed().as_nanos() as u32;
|
||||
|
||||
self.events += 1;
|
||||
if time > self.high {
|
||||
self.high = time;
|
||||
}
|
||||
if time < self.low {
|
||||
self.low = time;
|
||||
}
|
||||
self.average = (self.average + time as f32) / 2.0;
|
||||
//self.events += 1;
|
||||
//if time > self.high {
|
||||
// self.high = time;
|
||||
//}
|
||||
//if time < self.low {
|
||||
// self.low = time;
|
||||
//}
|
||||
//self.average = (self.average + time as f32) / 2.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user