Warn if not using the real bios
Also run rustfmt Former-commit-id: 1c46b90fc6099eed5124a3bd2712883fd0f6d1d2 Former-commit-id: 1236956de08a30e4dd76aa78619290b63b4df24a
This commit is contained in:
parent
a56f515563
commit
3ac1d57e04
786
Cargo.lock
generated
786
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -21,8 +21,8 @@ use android_log;
|
|||
use env_logger;
|
||||
|
||||
use rustboyadvance_core::prelude::*;
|
||||
use rustboyadvance_core::StereoSample;
|
||||
use rustboyadvance_core::util::audio::AudioRingBuffer;
|
||||
use rustboyadvance_core::StereoSample;
|
||||
|
||||
struct Hardware {
|
||||
jvm: JavaVM,
|
||||
|
|
|
@ -6,8 +6,8 @@ use wasm_bindgen::Clamped;
|
|||
|
||||
use js_sys::Float32Array;
|
||||
|
||||
use web_sys::CanvasRenderingContext2d;
|
||||
use web_sys::AudioContext;
|
||||
use web_sys::CanvasRenderingContext2d;
|
||||
|
||||
use rustboyadvance_core::core::keypad as gba_keypad;
|
||||
use rustboyadvance_core::prelude::*;
|
||||
|
@ -37,15 +37,13 @@ impl Drop for Interface {
|
|||
|
||||
impl Interface {
|
||||
fn new(audio_ctx: AudioContext) -> Result<Interface, JsValue> {
|
||||
Ok(
|
||||
Interface {
|
||||
Ok(Interface {
|
||||
frame: vec![0; 240 * 160 * 4],
|
||||
keyinput: gba_keypad::KEYINPUT_ALL_RELEASED,
|
||||
sample_rate: audio_ctx.sample_rate() as i32,
|
||||
audio_ctx: audio_ctx,
|
||||
audio_ring_buffer: AudioRingBuffer::new(),
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +62,6 @@ impl VideoInterface for Interface {
|
|||
|
||||
fn convert_sample(s: i16) -> f32 {
|
||||
((s as f32) / 32767_f32)
|
||||
|
||||
}
|
||||
|
||||
impl AudioInterface for Interface {
|
||||
|
|
|
@ -18,19 +18,22 @@ hexdump = "0.1.0"
|
|||
time = "0.2.6"
|
||||
bitfield = "0.13.1"
|
||||
bitflags = "1.2.1"
|
||||
zip = {version = "0.5.4", default-features = false, features = ["deflate", "time"]}
|
||||
zip = { version = "0.5.4", default-features = false, features = [
|
||||
"deflate",
|
||||
"time"
|
||||
] }
|
||||
bit-set = "0.5.1"
|
||||
debug_stub_derive = "0.3.0"
|
||||
bytesize = "1.0.0"
|
||||
memmem = "0.1.1"
|
||||
log = "0.4.8"
|
||||
arrayvec = "0.5.1"
|
||||
|
||||
sha2 = "0.8.1"
|
||||
hex-literal = "0.2.1"
|
||||
rustyline = { version = "6.0.0", optional = true }
|
||||
nom = { version = "5.0.0", optional = true }
|
||||
gdbstub = { version = "0.1.2", optional = true, features = ["std"] }
|
||||
ringbuf = "0.2.1"
|
||||
|
||||
goblin = { version = "0.2", optional = true }
|
||||
fuzzy-matcher = { version = "0.3.4", optional = true }
|
||||
|
||||
|
|
|
@ -34,6 +34,20 @@ struct SaveState {
|
|||
cpu: arm7tdmi::Core,
|
||||
}
|
||||
|
||||
/// Checks if the bios provided is the real one,
|
||||
/// Otherwise output a log warning to the user
|
||||
fn check_real_bios(bios: &[u8]) {
|
||||
use sha2::{Digest, Sha256};
|
||||
let mut hasher = Sha256::new();
|
||||
hasher.input(bios);
|
||||
let digest = hasher.result();
|
||||
|
||||
let expected_hash = hex!("fd2547724b505f487e6dcb29ec2ecff3af35a841a77ab2e85fd87350abd36570");
|
||||
if digest.as_slice() != &expected_hash[..] {
|
||||
warn!("This is not the real bios, some games may not be compatible");
|
||||
}
|
||||
}
|
||||
|
||||
impl GameBoyAdvance {
|
||||
pub fn new(
|
||||
bios_rom: Box<[u8]>,
|
||||
|
@ -42,6 +56,8 @@ impl GameBoyAdvance {
|
|||
audio_device: Rc<RefCell<dyn AudioInterface>>,
|
||||
input_device: Rc<RefCell<dyn InputInterface>>,
|
||||
) -> GameBoyAdvance {
|
||||
// Warn the user if the bios is not the real one
|
||||
check_real_bios(&bios_rom);
|
||||
let gpu = Box::new(Gpu::new());
|
||||
let sound_controller = Box::new(SoundController::new(
|
||||
audio_device.borrow().get_sample_rate() as f32,
|
||||
|
@ -289,7 +305,9 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_arm7tdmi_thumb_eggvance() {
|
||||
let mut gba = make_mock_gba(include_bytes!("../../../external/gba-suite/thumb/thumb.gba"));
|
||||
let mut gba = make_mock_gba(include_bytes!(
|
||||
"../../../external/gba-suite/thumb/thumb.gba"
|
||||
));
|
||||
|
||||
for _ in 0..10 {
|
||||
gba.frame();
|
||||
|
|
|
@ -201,9 +201,11 @@ impl Gpu {
|
|||
break 'blend;
|
||||
}
|
||||
|
||||
|
||||
// if this is object alpha blending, ensure that the bottom layer contains a color to blend with
|
||||
let blend_mode = if obj_sfx && layers.len() > 1 && bot_layer_flags.contains_render_layer(&layers[1]) {
|
||||
let blend_mode = if obj_sfx
|
||||
&& layers.len() > 1
|
||||
&& bot_layer_flags.contains_render_layer(&layers[1])
|
||||
{
|
||||
BldMode::BldAlpha
|
||||
} else {
|
||||
self.bldcnt.mode()
|
||||
|
|
|
@ -106,8 +106,7 @@ impl Debugger {
|
|||
}
|
||||
println!("{}\n", self.gba.cpu);
|
||||
}
|
||||
Continue => {
|
||||
loop {
|
||||
Continue => loop {
|
||||
self.gba.key_poll();
|
||||
match self.gba.check_breakpoint() {
|
||||
Some(addr) => {
|
||||
|
@ -118,8 +117,7 @@ impl Debugger {
|
|||
self.gba.cpu.step(&mut self.gba.sysbus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
Frame(count) => {
|
||||
let start = time::Instant::now();
|
||||
for _ in 0..count {
|
||||
|
|
|
@ -20,6 +20,9 @@ use byteorder;
|
|||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
#[macro_use]
|
||||
extern crate hex_literal;
|
||||
|
||||
#[macro_use]
|
||||
pub mod util;
|
||||
pub mod core;
|
||||
|
@ -65,5 +68,5 @@ pub mod prelude {
|
|||
#[cfg(feature = "debugger")]
|
||||
pub use super::debugger::Debugger;
|
||||
pub use super::util::{read_bin_file, write_bin_file};
|
||||
pub use super::{AudioInterface, StereoSample, InputInterface, VideoInterface};
|
||||
pub use super::{AudioInterface, InputInterface, StereoSample, VideoInterface};
|
||||
}
|
||||
|
|
|
@ -128,7 +128,6 @@ macro_rules! host_breakpoint {
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
pub mod audio {
|
||||
use ringbuf::{Consumer, Producer, RingBuffer};
|
||||
|
||||
|
|
Reference in a new issue