Refactor rustboyadvance-core crate directory structure

Former-commit-id: 1aad71d283f7ec5a0f0328f9b683f51e459ae56f
Former-commit-id: 42bb30d300c17bace976d106f6da1aca8c0d7643
This commit is contained in:
Michel Heily 2020-05-01 18:13:00 +03:00
parent 3ac1d57e04
commit ef3f39defc
57 changed files with 117 additions and 122 deletions

View file

@ -2,7 +2,7 @@ use jni::objects::*;
use jni::sys::*;
use jni::JNIEnv;
use rustboyadvance_core::core::cartridge;
use rustboyadvance_core::cartridge;
fn parse_rom_header(env: &JNIEnv, barr: jbyteArray) -> cartridge::header::CartridgeHeader {
let rom_data = env.convert_byte_array(barr).unwrap();

View file

@ -7,7 +7,7 @@ use std::time;
#[macro_use]
extern crate clap;
use rustboyadvance_core::core::keypad;
use rustboyadvance_core::keypad;
use rustboyadvance_core::prelude::*;
use rustboyadvance_core::util::FpsCounter;

View file

@ -1,6 +1,6 @@
use sdl2::keyboard::Keycode;
use rustboyadvance_core::core::keypad as gba_keypad;
use rustboyadvance_core::keypad as gba_keypad;
use rustboyadvance_core::InputInterface;
use bit;

View file

@ -5,7 +5,7 @@ use sdl2::keyboard::Keycode;
use sdl2::messagebox::*;
use sdl2::pixels::Color;
use sdl2::rect::Rect;
use sdl2::render::{Texture, WindowCanvas};
use sdl2::render::WindowCanvas;
use sdl2::EventPump;
@ -41,7 +41,7 @@ use audio::create_audio_player;
use input::create_input;
use video::{create_video_interface, SCREEN_HEIGHT, SCREEN_WIDTH};
use rustboyadvance_core::core::cartridge::BackupType;
use rustboyadvance_core::cartridge::BackupType;
use rustboyadvance_core::prelude::*;
use rustboyadvance_core::util::spawn_and_run_gdb_server;
use rustboyadvance_core::util::FpsCounter;

View file

@ -3,7 +3,7 @@ use sdl2::rect::Rect;
use sdl2::render::{Texture, TextureCreator, WindowCanvas};
use sdl2::video::WindowContext;
use rustboyadvance_core::core::gpu::{DISPLAY_HEIGHT, DISPLAY_WIDTH};
use rustboyadvance_core::gpu::{DISPLAY_HEIGHT, DISPLAY_WIDTH};
use rustboyadvance_core::VideoInterface;
pub const SCREEN_WIDTH: u32 = DISPLAY_WIDTH as u32;

View file

@ -9,7 +9,7 @@ use js_sys::Float32Array;
use web_sys::AudioContext;
use web_sys::CanvasRenderingContext2d;
use rustboyadvance_core::core::keypad as gba_keypad;
use rustboyadvance_core::keypad as gba_keypad;
use rustboyadvance_core::prelude::*;
use rustboyadvance_core::util::audio::AudioRingBuffer;

View file

@ -7,7 +7,7 @@ extern crate log;
use wasm_bindgen_console_logger::DEFAULT_LOGGER;
use rustboyadvance_core::core::cartridge;
use rustboyadvance_core::cartridge;
pub mod emulator;

View file

@ -7,7 +7,7 @@ use crate::bit::BitIndex;
use super::{ArmFormat, ArmInstruction};
use super::{AluOpCode, ArmCond, ArmHalfwordTransferType};
use crate::core::arm7tdmi::*;
use crate::arm7tdmi::*;
impl fmt::Display for ArmCond {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

View file

@ -1,11 +1,11 @@
use crate::bit::BitIndex;
use super::super::alu::*;
use crate::core::arm7tdmi::psr::RegPSR;
use crate::core::arm7tdmi::CpuAction;
use crate::core::arm7tdmi::{Addr, Core, CpuMode, CpuState, REG_LR, REG_PC};
use crate::core::sysbus::SysBus;
use crate::core::Bus;
use crate::arm7tdmi::psr::RegPSR;
use crate::arm7tdmi::CpuAction;
use crate::arm7tdmi::{Addr, Core, CpuMode, CpuState, REG_LR, REG_PC};
use crate::sysbus::SysBus;
use crate::Bus;
use super::*;

View file

@ -4,7 +4,7 @@ pub mod exec;
use serde::{Deserialize, Serialize};
use super::alu::*;
use crate::core::arm7tdmi::{Addr, InstructionDecoder};
use crate::arm7tdmi::{Addr, InstructionDecoder};
use crate::bit::BitIndex;
use crate::byteorder::{LittleEndian, ReadBytesExt};
@ -367,8 +367,8 @@ impl ArmInstruction {
// /// All instructions constants were generated using an ARM assembler.
// mod tests {
// use super::*;
// use crate::core::arm7tdmi::*;
// use crate::core::sysbus::BoxedMemory;
// use crate::arm7tdmi::*;
// use crate::sysbus::BoxedMemory;
// #[test]
// fn swi() {

View file

@ -25,8 +25,8 @@ use super::CpuAction;
use super::DecodedInstruction;
use super::{arm::*, psr::RegPSR, thumb::ThumbInstruction, Addr, CpuMode, CpuState};
use crate::core::bus::Bus;
use crate::core::sysbus::{MemoryAccessType::*, MemoryAccessWidth::*, SysBus};
use crate::bus::Bus;
use crate::sysbus::{MemoryAccessType::*, MemoryAccessWidth::*, SysBus};
use bit::BitIndex;
use num::FromPrimitive;

View file

@ -21,7 +21,7 @@ pub const REG_PC: usize = 15;
pub const REG_LR: usize = 14;
pub const REG_SP: usize = 13;
pub(self) use crate::core::Addr;
pub(self) use crate::Addr;
pub enum CpuAction {
AdvancePC,

View file

@ -5,7 +5,7 @@ use crate::bit::BitIndex;
use super::*;
#[cfg(feature = "debugger")]
use crate::core::arm7tdmi::*;
use crate::arm7tdmi::*;
#[cfg(feature = "debugger")]
impl ThumbInstruction {

View file

@ -1,6 +1,6 @@
use crate::core::arm7tdmi::*;
use crate::core::sysbus::SysBus;
use crate::core::Bus;
use crate::arm7tdmi::*;
use crate::sysbus::SysBus;
use crate::Bus;
use crate::bit::BitIndex;

View file

@ -321,8 +321,8 @@ impl ThumbInstruction {
// mod tests {
// use super::super::Core;
// use super::*;
// use crate::core::sysbus::BoxedMemory;
// use crate::core::Bus;
// use crate::sysbus::BoxedMemory;
// use crate::Bus;
// #[test]
// fn mov_low_reg() {

View file

@ -1,68 +0,0 @@
pub mod arm7tdmi;
pub mod cartridge;
pub mod gpu;
pub mod sound;
pub mod sysbus;
pub use sysbus::SysBus;
pub mod interrupt;
pub mod iodev;
pub use interrupt::Interrupt;
pub use interrupt::IrqBitmask;
pub mod gba;
pub use gba::GameBoyAdvance;
pub mod bus;
pub mod dma;
pub mod keypad;
pub mod timer;
pub use bus::*;
pub use super::{AudioInterface, InputInterface, VideoInterface};
#[cfg(feature = "debugger")]
use crate::debugger;
use zip;
use std::error::Error;
use std::fmt;
#[derive(Debug)]
pub enum GBAError {
IO(::std::io::Error),
CartridgeLoadError(String),
#[cfg(feature = "debugger")]
DebuggerError(debugger::DebuggerError),
}
impl fmt::Display for GBAError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "error: {:?}", self)
}
}
impl Error for GBAError {
fn description(&self) -> &str {
"emulator error"
}
}
pub type GBAResult<T> = Result<T, GBAError>;
impl From<::std::io::Error> for GBAError {
fn from(err: ::std::io::Error) -> GBAError {
GBAError::IO(err)
}
}
#[cfg(feature = "debugger")]
impl From<debugger::DebuggerError> for GBAError {
fn from(err: debugger::DebuggerError) -> GBAError {
GBAError::DebuggerError(err)
}
}
impl From<zip::result::ZipError> for GBAError {
fn from(_err: zip::result::ZipError) -> GBAError {
GBAError::IO(::std::io::Error::from(::std::io::ErrorKind::InvalidInput))
}
}

View file

@ -2,12 +2,12 @@ use std::path::Path;
use std::sync::atomic::Ordering;
use std::time;
use crate::core::arm7tdmi::arm::ArmInstruction;
use crate::core::arm7tdmi::thumb::ThumbInstruction;
use crate::core::arm7tdmi::CpuState;
use crate::core::{Addr, Bus};
use crate::arm7tdmi::arm::ArmInstruction;
use crate::arm7tdmi::thumb::ThumbInstruction;
use crate::arm7tdmi::CpuState;
use crate::disass::Disassembler;
use crate::util::{read_bin_file, write_bin_file};
use crate::{Addr, Bus};
// use super::palette_view::create_palette_view;
// use super::tile_view::create_tile_view;

View file

@ -6,8 +6,8 @@ use rustyline::Editor;
use colored::*;
use super::core::GameBoyAdvance;
use super::core::{Addr, Bus};
use super::GameBoyAdvance;
use super::{Addr, Bus};
mod parser;
use parser::{parse_expr, DerefType, Expr, Value};

View file

@ -3,7 +3,7 @@
// use sdl2::rect::{Point, Rect};
// use sdl2::render::Canvas;
// use crate::core::palette::{Palette, Rgb15};
// use crate::palette::{Palette, Rgb15};
// const PALETTE_RECT_WIDTH: u32 = 20;

View file

@ -5,8 +5,8 @@
// use sdl2::rect::{Point, Rect};
// use sdl2::render::Canvas;
// use crate::core::gba::GameBoyAdvance;
// use crate::core::gpu::PixelFormat;
// use crate::gba::GameBoyAdvance;
// use crate::gpu::PixelFormat;
// fn draw_tile(
// gba: &GameBoyAdvance,

View file

@ -1,8 +1,8 @@
use std::fmt;
use std::marker::PhantomData;
use super::core::arm7tdmi::InstructionDecoder;
use super::core::Addr;
use super::arm7tdmi::InstructionDecoder;
use super::Addr;
pub struct Disassembler<'a, D>
where

View file

@ -13,7 +13,7 @@ use super::iodev::*;
use super::sound::SoundController;
use super::sysbus::SysBus;
use super::super::{AudioInterface, InputInterface, VideoInterface};
use super::{AudioInterface, InputInterface, VideoInterface};
pub struct GameBoyAdvance {
pub sysbus: Box<SysBus>,

View file

@ -1,9 +1,9 @@
use super::core::arm7tdmi::CpuState;
use super::core::interrupt::*;
use super::core::iodev::IoDevices;
use super::core::sysbus::SysBus;
use super::core::Bus;
use super::arm7tdmi::CpuState;
use super::core::GameBoyAdvance;
use super::interrupt::*;
use super::iodev::IoDevices;
use super::sysbus::SysBus;
use super::Bus;
use byteorder::{LittleEndian, ReadBytesExt};
use gdbstub::{Access, Target, TargetState};

View file

@ -4,10 +4,10 @@ use std::rc::Rc;
use serde::{Deserialize, Serialize};
use super::super::VideoInterface;
use super::interrupt::IrqBitmask;
use super::sysbus::{BoxedMemory, SysBus};
use super::Bus;
use super::VideoInterface;
use crate::bitfield::Bit;
use crate::num::FromPrimitive;

View file

@ -6,7 +6,7 @@ use super::super::Rgb15;
use super::{utils, SCREEN_VIEWPORT};
use crate::core::Bus;
use crate::Bus;
impl Gpu {
pub(in super::super) fn render_mode3(&mut self, bg: usize) {

View file

@ -5,7 +5,7 @@ use super::super::Rgb15;
use super::super::{Gpu, PixelFormat, SCREEN_BLOCK_SIZE};
use super::{utils, ViewPort};
use crate::core::Bus;
use crate::Bus;
impl Gpu {
pub(in super::super) fn render_reg_bg(&mut self, bg: usize) {

View file

@ -23,10 +23,31 @@ extern crate log;
#[macro_use]
extern crate hex_literal;
use zip;
use std::error::Error;
use std::fmt;
#[macro_use]
pub mod util;
pub mod core;
pub mod arm7tdmi;
pub mod cartridge;
pub mod disass;
pub mod gpu;
pub mod sound;
pub mod sysbus;
pub use sysbus::SysBus;
pub mod interrupt;
pub mod iodev;
pub use interrupt::Interrupt;
pub use interrupt::IrqBitmask;
pub mod gba;
pub use gba::GameBoyAdvance;
pub mod bus;
pub mod dma;
pub mod keypad;
pub mod timer;
pub use bus::*;
#[cfg(feature = "gdb")]
pub mod gdb;
@ -55,18 +76,60 @@ pub trait AudioInterface {
pub trait InputInterface {
fn poll(&mut self) -> u16 {
core::keypad::KEYINPUT_ALL_RELEASED
keypad::KEYINPUT_ALL_RELEASED
}
}
#[cfg(feature = "debugger")]
#[derive(Debug)]
pub enum GBAError {
IO(::std::io::Error),
CartridgeLoadError(String),
#[cfg(feature = "debugger")]
DebuggerError(debugger::DebuggerError),
}
impl fmt::Display for GBAError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "error: {:?}", self)
}
}
impl Error for GBAError {
fn description(&self) -> &str {
"emulator error"
}
}
pub type GBAResult<T> = Result<T, GBAError>;
impl From<::std::io::Error> for GBAError {
fn from(err: ::std::io::Error) -> GBAError {
GBAError::IO(err)
}
}
#[cfg(feature = "debugger")]
impl From<debugger::DebuggerError> for GBAError {
fn from(err: debugger::DebuggerError) -> GBAError {
GBAError::DebuggerError(err)
}
}
impl From<zip::result::ZipError> for GBAError {
fn from(_err: zip::result::ZipError) -> GBAError {
GBAError::IO(::std::io::Error::from(::std::io::ErrorKind::InvalidInput))
}
}
pub mod prelude {
pub use super::core::arm7tdmi;
pub use super::core::cartridge::{Cartridge, GamepakBuilder};
pub use super::core::gpu::{DISPLAY_HEIGHT, DISPLAY_WIDTH};
pub use super::core::Bus;
pub use super::core::{GBAError, GBAResult, GameBoyAdvance};
pub use super::arm7tdmi;
pub use super::cartridge::{Cartridge, GamepakBuilder};
#[cfg(feature = "debugger")]
pub use super::debugger::Debugger;
pub use super::gpu::{DISPLAY_HEIGHT, DISPLAY_WIDTH};
pub use super::util::{read_bin_file, write_bin_file};
pub use super::Bus;
pub use super::{AudioInterface, InputInterface, StereoSample, VideoInterface};
pub use super::{GBAError, GBAResult, GameBoyAdvance};
}

View file

@ -21,7 +21,7 @@ fn now() -> Instant {
instant::Instant::now()
}
use crate::core::GameBoyAdvance;
use crate::GameBoyAdvance;
#[cfg(feature = "gdb")]
use gdbstub;
#[cfg(feature = "gdb")]