Browse Source

Folder restructuring and slight changes to gspgpu

pull/107/head
Andrea Ciliberti 2 years ago
parent
commit
c3df8af69f
  1. 2
      ctru-rs/examples/camera-image.rs
  2. 2
      ctru-rs/examples/file-explorer.rs
  3. 2
      ctru-rs/examples/gfx-3d-mode.rs
  4. 2
      ctru-rs/examples/graphics-bitmap.rs
  5. 2
      ctru-rs/examples/romfs.rs
  6. 2
      ctru-rs/src/console.rs
  7. 20
      ctru-rs/src/lib.rs
  8. 3
      ctru-rs/src/prelude.rs
  9. 2
      ctru-rs/src/services/gfx.rs
  10. 28
      ctru-rs/src/services/gspgpu.rs
  11. 20
      ctru-rs/src/services/mod.rs
  12. 2
      ctru-rs/src/services/romfs.rs
  13. 5
      ctru-rs/src/test_runner.rs

2
ctru-rs/examples/camera-image.rs

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
use ctru::gfx::Screen;
use ctru::prelude::*;
use ctru::services::cam::{Cam, CamOutputFormat, CamShutterSoundType, CamSize, Camera};
use ctru::services::gfx::Screen;
use ctru::services::gspgpu::FramebufferFormat;
use std::time::Duration;

2
ctru-rs/examples/file-explorer.rs

@ -16,7 +16,7 @@ fn main() { @@ -16,7 +16,7 @@ fn main() {
let gfx = Gfx::init().unwrap();
#[cfg(all(feature = "romfs", romfs_exists))]
let _romfs = ctru::romfs::RomFS::init().unwrap();
let _romfs = ctru::services::romfs::RomFS::init().unwrap();
FileExplorer::init(&apt, &hid, &gfx).run();
}

2
ctru-rs/examples/gfx-3d-mode.rs

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
use ctru::gfx::{Screen, Side, TopScreen3D};
use ctru::prelude::*;
use ctru::services::gfx::{Screen, Side, TopScreen3D};
/// See `graphics-bitmap.rs` for details on how the image is generated.
///

2
ctru-rs/examples/graphics-bitmap.rs

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
use ctru::gfx::Screen as _;
use ctru::prelude::*;
use ctru::services::gfx::Screen;
/// Ferris image taken from <https://rustacean.net> and scaled down to 320x240px.
/// To regenerate the data, you will need to install `imagemagick` and run this

2
ctru-rs/examples/romfs.rs

@ -13,7 +13,7 @@ fn main() { @@ -13,7 +13,7 @@ fn main() {
// This never fails as `ctru-rs` examples inherit all of the `ctru` features,
// but it might if a normal user application wasn't setup correctly
if #[cfg(all(feature = "romfs", romfs_exists))] {
let _romfs = ctru::romfs::RomFS::init().unwrap();
let _romfs = ctru::services::romfs::RomFS::init().unwrap();
let f = std::fs::read_to_string("romfs:/test-file.txt").unwrap();
println!("Contents of test-file.txt: \n{f}\n");

2
ctru-rs/src/console.rs

@ -3,7 +3,7 @@ use std::default::Default; @@ -3,7 +3,7 @@ use std::default::Default;
use ctru_sys::{consoleClear, consoleInit, consoleSelect, consoleSetWindow, PrintConsole};
use crate::gfx::Screen;
use crate::services::gfx::Screen;
static mut EMPTY_CONSOLE: PrintConsole = unsafe { const_zero::const_zero!(PrintConsole) };

20
ctru-rs/src/lib.rs

@ -62,31 +62,11 @@ fn panic_hook_setup() { @@ -62,31 +62,11 @@ fn panic_hook_setup() {
pub mod applets;
pub mod console;
pub mod error;
pub mod gfx;
pub mod linear;
pub mod mii;
pub mod prelude;
pub mod services;
cfg_if::cfg_if! {
if #[cfg(all(feature = "romfs", romfs_exists))] {
pub mod romfs;
} else {
pub mod romfs {
//! The RomFS folder has not been detected and/or the `romfs` feature has not been enabled.
//!
//! Configure the path in Cargo.toml (the default path is "romfs"). Paths are relative to the
//! `CARGO_MANIFEST_DIR` environment variable, which is the directory containing the manifest of
//! your package.
//!
//! ```toml
//! [package.metadata.cargo-3ds]
//! romfs_dir = "romfs"
//! ```
}
}
}
#[cfg(test)]
mod test_runner;

3
ctru-rs/src/prelude.rs

@ -1,3 +1,2 @@ @@ -1,3 +1,2 @@
pub use crate::console::Console;
pub use crate::gfx::Gfx;
pub use crate::services::{hid::KeyPad, soc::Soc, Apt, Hid};
pub use crate::services::{gfx::Gfx, hid::KeyPad, soc::Soc, Apt, Hid};

2
ctru-rs/src/gfx.rs → ctru-rs/src/services/gfx.rs

@ -57,7 +57,7 @@ pub trait Screen: private::Sealed { @@ -57,7 +57,7 @@ pub trait Screen: private::Sealed {
/// Gets the framebuffer format
fn get_framebuffer_format(&self) -> FramebufferFormat {
unsafe { ctru_sys::gfxGetScreenFormat(self.as_raw()).into() }
unsafe { ctru_sys::gfxGetScreenFormat(self.as_raw()) }.into()
}
/// Change the framebuffer format

28
ctru-rs/src/services/gspgpu.rs

@ -3,29 +3,31 @@ @@ -3,29 +3,31 @@
use std::convert::From;
#[derive(Copy, Clone, Debug)]
#[repr(u32)]
pub enum Event {
Psc0,
Psc1,
VBlank0,
VBlank1,
PPF,
P3D,
DMA,
Psc0 = ctru_sys::GSPGPU_EVENT_PSC0,
Psc1 = ctru_sys::GSPGPU_EVENT_PSC1,
VBlank0 = ctru_sys::GSPGPU_EVENT_VBlank0,
VBlank1 = ctru_sys::GSPGPU_EVENT_VBlank1,
PPF = ctru_sys::GSPGPU_EVENT_PPF,
P3D = ctru_sys::GSPGPU_EVENT_P3D,
DMA = ctru_sys::GSPGPU_EVENT_DMA,
}
/// The different framebuffer formats supported by the 3DS
/// Framebuffer formats supported by the 3DS
#[derive(Copy, Clone, Debug)]
#[repr(u32)]
pub enum FramebufferFormat {
/// RGBA8. 4 bytes per pixel
Rgba8,
Rgba8 = ctru_sys::GSP_RGBA8_OES,
/// BGR8. 3 bytes per pixel
Bgr8,
Bgr8 = ctru_sys::GSP_BGR8_OES,
/// RGB565. 2 bytes per pixel
Rgb565,
Rgb565 = ctru_sys::GSP_RGB565_OES,
/// RGB5A1. 2 bytes per pixel
Rgb5A1,
Rgb5A1 = ctru_sys::GSP_RGB5_A1_OES,
/// RGBA4. 2 bytes per pixel
Rgba4,
Rgba4 = ctru_sys::GSP_RGBA4_OES,
}
impl FramebufferFormat {

20
ctru-rs/src/services/mod.rs

@ -10,6 +10,7 @@ pub mod apt; @@ -10,6 +10,7 @@ pub mod apt;
pub mod cam;
pub mod cfgu;
pub mod fs;
pub mod gfx;
pub mod gspgpu;
pub mod hid;
pub mod ndsp;
@ -18,6 +19,25 @@ mod reference; @@ -18,6 +19,25 @@ mod reference;
pub mod soc;
pub mod sslc;
cfg_if::cfg_if! {
if #[cfg(all(feature = "romfs", romfs_exists))] {
pub mod romfs;
} else {
pub mod romfs {
//! The RomFS folder has not been detected and/or the `romfs` feature has not been enabled.
//!
//! Configure the path in Cargo.toml (the default path is "romfs"). Paths are relative to the
//! `CARGO_MANIFEST_DIR` environment variable, which is the directory containing the manifest of
//! your package.
//!
//! ```toml
//! [package.metadata.cargo-3ds]
//! romfs_dir = "romfs"
//! ```
}
}
}
pub use self::apt::Apt;
pub use self::hid::Hid;

2
ctru-rs/src/romfs.rs → ctru-rs/src/services/romfs.rs

@ -1,3 +1,5 @@ @@ -1,3 +1,5 @@
//! Read-Only Memory FileSystem
//!
//! This module only gets compiled if the configured RomFS directory is found and the `romfs`
//! feature is enabled.
//!

5
ctru-rs/src/test_runner.rs

@ -6,10 +6,7 @@ use std::io; @@ -6,10 +6,7 @@ use std::io;
use test::{ColorConfig, OutputFormat, TestDescAndFn, TestFn, TestOpts};
use crate::console::Console;
use crate::gfx::Gfx;
use crate::services::hid::{Hid, KeyPad};
use crate::services::Apt;
use crate::prelude::*;
/// A custom runner to be used with `#[test_runner]`. This simple implementation
/// runs all tests in series, "failing" on the first one to panic (really, the

Loading…
Cancel
Save