Merge remote-tracking branch 'upstream/master' into dungeon/simulation

This commit is contained in:
Corwin 2023-09-14 13:50:00 +01:00
commit 0e5063a9f0
No known key found for this signature in database
55 changed files with 1203 additions and 916 deletions

View file

@ -25,7 +25,7 @@ jobs:
rustup toolchain install nightly --component miri
rustup override set nightly
cargo miri setup
- uses: actions/checkout@v3
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
- name: Cache
uses: actions/cache@v3
with:

View file

@ -13,7 +13,7 @@ jobs:
- name: Install build tools
run: sudo apt-get update && sudo apt-get install build-essential zip -y
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
with:
fetch-depth: 0
- name: Login to crates.io

View file

@ -16,7 +16,7 @@ jobs:
- name: Set CARGO_TARGET_DIR
run: echo "CARGO_TARGET_DIR=$HOME/target" >> $GITHUB_ENV
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
- uses: extractions/setup-just@v1
- name: Update lock files
run: just update-lockfiles --commit

View file

@ -12,14 +12,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- New tracker for playing XM files (see the `agb-tracker` crate).
- You can now declare where looping sound channels should restart.
- Fixnums now have constructors from_f32 and from_f64. This is mainly useful if using agb-fixnum outside of the Game Boy Advance e.g. in build scripts or macros.
- New option when loading a background to automatically deduplicate tiles.
- Methods on tile_setting to toggle its hflip and vflip status.
### Changed
- Sound channel panning and volume options are now `Num<i16, 8>` rather than `Num<i16, 4>` for improved precision and sound quality.
- Due to dependency changes, agb-gbafix is now released under MPL rather than GPL.
- `include_background_gfx!` now produces tile sets and tile settings directly.
### Fixed
- 256-colour backgrounds are better supported.
- Mono looping samples will now correctly play to the end if it doesn't perfectly align with a buffer boundry and short samples now also loop correctly.
## [0.16.0] - 2023/07/18

139
agb-gbafix/Cargo.lock generated
View file

@ -13,24 +13,23 @@ dependencies = [
[[package]]
name = "anstream"
version = "0.3.2"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163"
checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is-terminal",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.1"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd"
checksum = "b84bf0a05bbb2a83e5eb6fa36bb6e87baa08193c35ff52bbf6b38d8af2890e46"
[[package]]
name = "anstyle-parse"
@ -52,9 +51,9 @@ dependencies = [
[[package]]
name = "anstyle-wincon"
version = "1.0.2"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c677ab05e09154296dd37acecd46420c17b9713e8366facafa8fc0885167cf4c"
checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd"
dependencies = [
"anstyle",
"windows-sys",
@ -62,39 +61,24 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.72"
version = "1.0.75"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854"
[[package]]
name = "bitflags"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
[[package]]
name = "cc"
version = "1.0.82"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "305fe645edc1442a0fa8b6726ba61d422798d37a52e12eaecf4b022ebbb88f01"
dependencies = [
"libc",
]
checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
[[package]]
name = "clap"
version = "4.3.21"
version = "4.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c27cdf28c0f604ba3f512b0c9a409f8de8513e4816705deb0498b627e7c3a3fd"
checksum = "84ed82781cea27b43c9b106a979fe450a13a31aab0500595fb3fc06616de08e6"
dependencies = [
"clap_builder",
]
[[package]]
name = "clap_builder"
version = "4.3.21"
version = "4.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08a9f1ab5e9f01a9b81f202e8562eb9a10de70abf9eaeac1be465c28b75aa4aa"
checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08"
dependencies = [
"anstream",
"anstyle",
@ -104,9 +88,9 @@ dependencies = [
[[package]]
name = "clap_lex"
version = "0.5.0"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b"
checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961"
[[package]]
name = "colorchoice"
@ -120,69 +104,6 @@ version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2b183d6ce6ca4cf30e3db37abf5b52568b5f9015c97d9fbdd7026aa5dcdd758"
[[package]]
name = "errno"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f"
dependencies = [
"errno-dragonfly",
"libc",
"windows-sys",
]
[[package]]
name = "errno-dragonfly"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
dependencies = [
"cc",
"libc",
]
[[package]]
name = "hermit-abi"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b"
[[package]]
name = "is-terminal"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
dependencies = [
"hermit-abi",
"rustix",
"windows-sys",
]
[[package]]
name = "libc"
version = "0.2.147"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
[[package]]
name = "linux-raw-sys"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503"
[[package]]
name = "rustix"
version = "0.38.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19ed4fa021d81c8392ce04db050a3da9a60299050b7ae1cf482d862b54a7218f"
dependencies = [
"bitflags",
"errno",
"libc",
"linux-raw-sys",
"windows-sys",
]
[[package]]
name = "strsim"
version = "0.10.0"
@ -206,9 +127,9 @@ dependencies = [
[[package]]
name = "windows-targets"
version = "0.48.1"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f"
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
@ -221,42 +142,42 @@ dependencies = [
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_i686_gnu"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_msvc"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"

View file

@ -11,4 +11,5 @@ pub(crate) trait Config {
pub(crate) trait Image {
fn filename(&self) -> String;
fn colours(&self) -> Colours;
fn deduplicate(&self) -> bool;
}

View file

@ -0,0 +1,152 @@
use std::{collections::HashMap, hash::BuildHasher};
use crate::{colour::Colour, image_loader::Image};
pub struct Transformation {
pub vflip: bool,
pub hflip: bool,
}
impl Transformation {
pub fn none() -> Self {
Self {
vflip: false,
hflip: false,
}
}
pub fn vflipped() -> Self {
Self {
vflip: true,
hflip: false,
}
}
pub fn hflipped() -> Self {
Self {
vflip: false,
hflip: true,
}
}
pub fn vhflipped() -> Self {
Self {
vflip: true,
hflip: true,
}
}
}
pub struct DeduplicatedData {
pub new_index: usize,
pub transformation: Transformation,
}
#[derive(Clone, PartialEq, Eq, Hash)]
struct Tile {
data: [Colour; 64],
}
impl Tile {
fn split_image(input: &Image) -> Vec<Self> {
let mut ret = vec![];
for y in 0..(input.height / 8) {
for x in 0..(input.width / 8) {
let mut tile_data = Vec::with_capacity(64);
for j in 0..8 {
for i in 0..8 {
tile_data.push(input.colour(x * 8 + i, y * 8 + j));
}
}
ret.push(Tile {
data: tile_data.try_into().unwrap(),
});
}
}
ret
}
fn vflipped(&self) -> Self {
let mut new_data = self.data;
for y in 0..4 {
for x in 0..8 {
new_data.swap(y * 8 + x, (7 - y) * 8 + x);
}
}
Self { data: new_data }
}
fn hflipped(&self) -> Self {
let mut new_data = self.data;
for y in 0..8 {
for x in 0..4 {
new_data.swap(y * 8 + x, y * 8 + (7 - x));
}
}
Self { data: new_data }
}
}
pub(crate) fn deduplicate_image(input: &Image, can_flip: bool) -> (Image, Vec<DeduplicatedData>) {
let mut resulting_tiles = vec![];
let mut deduplication_data = vec![];
let all_tiles = Tile::split_image(input);
let mut existing_tiles = HashMap::new();
let hasher = std::collections::hash_map::RandomState::new();
for tile in all_tiles {
let (tile, transformation) = if can_flip {
let vflipped = tile.vflipped();
let hflipped = tile.hflipped();
let vhflipped = vflipped.hflipped();
// find the one with the smallest hash
let tile_hash = hasher.hash_one(&tile);
let vflipped_hash = hasher.hash_one(&vflipped);
let hflipped_hash = hasher.hash_one(&hflipped);
let vhflipped_hash = hasher.hash_one(&vhflipped);
let minimum = tile_hash
.min(vflipped_hash)
.min(hflipped_hash)
.min(vhflipped_hash);
if minimum == tile_hash {
(tile, Transformation::none())
} else if minimum == vflipped_hash {
(vflipped, Transformation::vflipped())
} else if minimum == hflipped_hash {
(hflipped, Transformation::hflipped())
} else {
(vhflipped, Transformation::vhflipped())
}
} else {
(tile, Transformation::none())
};
let index = *existing_tiles.entry(tile.clone()).or_insert_with(|| {
resulting_tiles.push(tile);
resulting_tiles.len() - 1
});
deduplication_data.push(DeduplicatedData {
new_index: index,
transformation,
});
}
let image_data = resulting_tiles
.iter()
.flat_map(|tile| tile.data)
.collect::<Vec<_>>();
(Image::from_colour_data(image_data), deduplication_data)
}

View file

@ -4,6 +4,7 @@ use image::{DynamicImage, GenericImageView};
use crate::colour::Colour;
#[derive(Clone)]
pub(crate) struct Image {
pub width: usize,
pub height: usize,
@ -42,6 +43,14 @@ impl Image {
}
}
pub fn from_colour_data(colour_data: Vec<Colour>) -> Self {
Self {
height: colour_data.len() / 8,
colour_data,
width: 8,
}
}
pub fn colour(&self, x: usize, y: usize) -> Colour {
self.colour_data[x + y * self.width]
}

View file

@ -15,6 +15,7 @@ use quote::{format_ident, quote, ToTokens};
mod aseprite;
mod colour;
mod config;
mod deduplicator;
mod font_loader;
mod image_loader;
mod palette16;
@ -36,6 +37,7 @@ struct BackgroundGfxOption {
module_name: String,
file_name: String,
colours: Colours,
deduplicate: bool,
}
impl config::Image for BackgroundGfxOption {
@ -46,6 +48,10 @@ impl config::Image for BackgroundGfxOption {
fn colours(&self) -> Colours {
self.colours
}
fn deduplicate(&self) -> bool {
self.deduplicate
}
}
impl Parse for BackgroundGfxOption {
@ -72,12 +78,30 @@ impl Parse for BackgroundGfxOption {
Colours::Colours16
};
let lookahead = input.lookahead1();
let deduplicate = if lookahead.peek(syn::Ident) {
let deduplicate: syn::Ident = input.parse()?;
if deduplicate == "deduplicate" {
true
} else {
return Err(syn::Error::new_spanned(
deduplicate,
"Must either be the literal deduplicate or missing",
));
}
} else {
false
};
let file_name: syn::LitStr = input.parse()?;
Ok(Self {
module_name: module_name.to_string(),
file_name: file_name.value(),
colours,
deduplicate,
})
}
}
@ -406,6 +430,7 @@ fn convert_image(
) -> proc_macro2::TokenStream {
let image_filename = &parent.join(settings.filename());
let image = Image::load_from_file(image_filename);
let deduplicate = settings.deduplicate();
rust_generator::generate_code(
variable_name,
@ -414,6 +439,7 @@ fn convert_image(
&image_filename.to_string_lossy(),
crate_prefix.to_owned(),
assignment_offset,
deduplicate,
)
}
@ -468,7 +494,14 @@ fn palette_tile_data(
let mut tile_data = Vec::new();
for (image_idx, image) in images.iter().enumerate() {
add_image_to_tile_data(&mut tile_data, image, optimiser, image_idx, true)
add_image_to_tile_data(
&mut tile_data,
image,
optimiser,
image_idx,
true,
&(0..images.len()).collect::<Vec<_>>(),
);
}
let tile_data = collapse_to_4bpp(&tile_data);
@ -491,6 +524,7 @@ fn add_image_to_tile_data(
optimiser: &Palette16OptimisationResults,
assignment_offset: usize,
is_sprite: bool,
remap_index: &[usize],
) {
let tile_size = 8;
let tiles_x = image.width / tile_size;
@ -501,7 +535,7 @@ fn add_image_to_tile_data(
let assignment = if is_sprite {
assignment_offset
} else {
y * tiles_x + x + assignment_offset
remap_index[y * tiles_x + x] + assignment_offset
};
let palette_index = optimiser.assignments[assignment];

View file

@ -1,3 +1,4 @@
use crate::deduplicator::{DeduplicatedData, Transformation};
use crate::palette16::Palette16OptimisationResults;
use crate::{add_image_256_to_tile_data, add_image_to_tile_data, collapse_to_4bpp};
use crate::{image_loader::Image, ByteString};
@ -5,6 +6,7 @@ use crate::{image_loader::Image, ByteString};
use proc_macro2::TokenStream;
use quote::{format_ident, quote};
use std::collections::BTreeMap;
use std::iter;
pub(crate) fn generate_palette_code(
@ -40,37 +42,83 @@ pub(crate) fn generate_code(
image_filename: &str,
crate_prefix: String,
assignment_offset: Option<usize>,
deduplicate: bool,
) -> TokenStream {
let crate_prefix = format_ident!("{}", crate_prefix);
let output_variable_name = format_ident!("{}", output_variable_name);
let (image, dedup_data) = if deduplicate {
let (new_image, dedup_data) =
crate::deduplicator::deduplicate_image(image, assignment_offset.is_some());
(new_image, dedup_data)
} else {
(
image.clone(),
(0..(image.width * image.height / 8 / 8))
.map(|i| DeduplicatedData {
new_index: i,
transformation: Transformation::none(),
})
.collect(),
)
};
let remap_index = dedup_data
.iter()
.enumerate()
.map(|(i, data)| (data.new_index, i))
.collect::<BTreeMap<_, _>>(); // BTreeMap so that values below is in order
let remap_index = remap_index.values().cloned().collect::<Vec<_>>();
let (tile_data, assignments) = if let Some(assignment_offset) = assignment_offset {
let mut tile_data = Vec::new();
add_image_to_tile_data(&mut tile_data, image, results, assignment_offset, false);
add_image_to_tile_data(
&mut tile_data,
&image,
results,
assignment_offset,
false,
&remap_index,
);
let tile_data = collapse_to_4bpp(&tile_data);
let num_tiles = image.width * image.height / 8usize.pow(2);
let assignments = results
.assignments
.iter()
.skip(assignment_offset)
.take(num_tiles)
.map(|&x| x as u8)
let all_assignments = &results.assignments[assignment_offset..];
let assignments = (0..num_tiles)
.map(|tile_id| all_assignments[remap_index[tile_id]] as u8)
.collect();
(tile_data, assignments)
} else {
let mut tile_data = Vec::new();
add_image_256_to_tile_data(&mut tile_data, image, results);
add_image_256_to_tile_data(&mut tile_data, &image, results);
(tile_data, vec![])
};
let tile_settings = dedup_data.iter().map(|data| {
let palette_assignment = assignments.get(data.new_index).unwrap_or(&0);
let vflipped = data.transformation.vflip;
let hflipped = data.transformation.hflip;
let index = data.new_index as u16;
quote! {
#crate_prefix::display::tiled::TileSetting::new(#index, #hflipped, #vflipped, #palette_assignment)
}
});
let data = ByteString(&tile_data);
let tile_format = if assignment_offset.is_some() {
quote! { #crate_prefix::display::tiled::TileFormat::FourBpp }
} else {
quote! { #crate_prefix::display::tiled::TileFormat::EightBpp }
};
quote! {
#[allow(non_upper_case_globals)]
@ -83,7 +131,7 @@ pub(crate) fn generate_code(
pub bytes: Bytes,
}
const ALIGNED: &AlignedAs<u16, [u8]> = &AlignedAs {
const ALIGNED: &AlignedAs<u32, [u8]> = &AlignedAs {
_align: [],
bytes: *#data,
};
@ -91,11 +139,13 @@ pub(crate) fn generate_code(
&ALIGNED.bytes
};
const PALETTE_ASSIGNMENT: &[u8] = &[
#(#assignments),*
const TILE_SET: #crate_prefix::display::tiled::TileSet = #crate_prefix::display::tiled::TileSet::new(TILE_DATA, #tile_format);
const TILE_SETTINGS: &[#crate_prefix::display::tiled::TileSetting] = &[
#(#tile_settings),*
];
#crate_prefix::display::tile_data::TileData::new(TILE_DATA, PALETTE_ASSIGNMENT)
#crate_prefix::display::tile_data::TileData::new(TILE_SET, TILE_SETTINGS)
};
}
}

View file

@ -4,7 +4,7 @@
use agb::{
display::{
affine::AffineMatrixBackground,
tiled::{AffineBackgroundSize, TileFormat, TileSet, TiledMap},
tiled::{AffineBackgroundSize, TiledMap},
Priority,
},
fixnum::{num, Num},
@ -18,7 +18,7 @@ fn main(mut gba: agb::Gba) -> ! {
let (gfx, mut vram) = gba.display.video.tiled2();
let vblank = agb::interrupt::VBlank::get();
let tileset = TileSet::new(affine_tiles::water_tiles.tiles, TileFormat::EightBpp);
let tileset = affine_tiles::water_tiles.tiles;
vram.set_background_palettes(affine_tiles::PALETTES);

View file

@ -3,7 +3,7 @@
use agb::{
display::{
tiled::{RegularBackgroundSize, TileFormat, TileSet, TileSetting, TiledMap},
tiled::{RegularBackgroundSize, TiledMap},
Priority,
},
include_background_gfx,
@ -16,14 +16,14 @@ fn main(mut gba: agb::Gba) -> ! {
let (gfx, mut vram) = gba.display.video.tiled0();
let vblank = agb::interrupt::VBlank::get();
let tileset = TileSet::new(water_tiles::water_tiles.tiles, TileFormat::FourBpp);
let tileset = water_tiles::water_tiles.tiles;
vram.set_background_palettes(water_tiles::PALETTES);
let mut bg = gfx.background(
Priority::P0,
RegularBackgroundSize::Background32x32,
TileFormat::FourBpp,
tileset.format(),
);
for y in 0..20u16 {
@ -32,7 +32,7 @@ fn main(mut gba: agb::Gba) -> ! {
&mut vram,
(x, y).into(),
&tileset,
TileSetting::new(0, false, false, 0),
water_tiles::water_tiles.tile_settings[0],
);
}
}

View file

@ -3,7 +3,7 @@
use agb::display::{
palette16::Palette16,
tiled::{RegularBackgroundSize, TileFormat, TileSetting, TiledMap},
tiled::{RegularBackgroundSize, TileFormat, TiledMap},
Priority,
};
@ -42,7 +42,7 @@ fn main(mut gba: agb::Gba) -> ! {
&mut vram,
(x as u16, y as u16).into(),
&dynamic_tile.tile_set(),
TileSetting::from_raw(dynamic_tile.tile_index()),
dynamic_tile.tile_setting(),
);
vram.remove_dynamic_tile(dynamic_tile);

View file

@ -3,9 +3,7 @@
use agb::{
display::{
tiled::{
RegularBackgroundSize, RegularMap, TileFormat, TileSetting, TiledMap, VRamManager,
},
tiled::{RegularBackgroundSize, RegularMap, TileFormat, TiledMap, VRamManager},
Font, Priority,
},
include_font, include_wav,
@ -110,7 +108,7 @@ fn init_background(bg: &mut RegularMap, vram: &mut VRamManager) {
vram,
(x, y).into(),
&background_tile.tile_set(),
TileSetting::from_raw(background_tile.tile_index()),
background_tile.tile_setting(),
);
}
}

View file

@ -24,76 +24,74 @@ fn entry(gba: agb::Gba) -> ! {
fn main(mut gba: agb::Gba) -> ! {
let (mut unmanaged, _sprites) = gba.display.object.get_unmanaged();
loop {
let mut palette = [0x0; 16];
palette[1] = 0xFF_FF;
palette[2] = 0x00_FF;
let palette = Palette16::new(palette);
let palette = PaletteVram::new(&palette).unwrap();
let mut palette = [0x0; 16];
palette[1] = 0xFF_FF;
palette[2] = 0x00_FF;
let palette = Palette16::new(palette);
let palette = PaletteVram::new(&palette).unwrap();
let timer = gba.timers.timers();
let mut timer: agb::timer::Timer = timer.timer2;
let timer = gba.timers.timers();
let mut timer: agb::timer::Timer = timer.timer2;
timer.set_enabled(true);
timer.set_divider(agb::timer::Divider::Divider256);
timer.set_enabled(true);
timer.set_divider(agb::timer::Divider::Divider256);
let mut wr = ObjectTextRender::new(&FONT, Size::S16x16, palette);
let start = timer.value();
let mut wr = ObjectTextRender::new(&FONT, Size::S16x16, palette);
let start = timer.value();
let player_name = "You";
let _ = writeln!(
let player_name = "You";
let _ = writeln!(
wr,
"Woah!{change2} {player_name}! {change1}Hey there! I have a bunch of text I want to show you. However, you will find that the amount of text I can display is limited. Who'd have thought! Good thing that my text system supports scrolling! It only took around 20 jank versions to get here!",
change2 = ChangeColour::new(2),
change1 = ChangeColour::new(1),
);
let end = timer.value();
let end = timer.value();
agb::println!(
"Write took {} cycles",
256 * (end.wrapping_sub(start) as u32)
);
agb::println!(
"Write took {} cycles",
256 * (end.wrapping_sub(start) as u32)
);
let vblank = agb::interrupt::VBlank::get();
let mut input = agb::input::ButtonController::new();
let vblank = agb::interrupt::VBlank::get();
let mut input = agb::input::ButtonController::new();
let start = timer.value();
wr.layout((WIDTH, 40).into(), TextAlignment::Justify, 2);
let end = timer.value();
agb::println!(
"Layout took {} cycles",
256 * (end.wrapping_sub(start) as u32)
);
let mut line_done = false;
let mut frame = 0;
loop {
vblank.wait_for_vblank();
input.update();
let oam = &mut unmanaged.iter();
wr.commit(oam);
let start = timer.value();
wr.layout((WIDTH, 40).into(), TextAlignment::Justify, 2);
if frame % 4 == 0 {
line_done = !wr.next_letter_group();
}
if line_done && input.is_just_pressed(Button::A) {
line_done = false;
wr.pop_line();
}
wr.update((0, HEIGHT - 40).into());
let end = timer.value();
frame += 1;
agb::println!(
"Layout took {} cycles",
256 * (end.wrapping_sub(start) as u32)
"Took {} cycles, line done {}",
256 * (end.wrapping_sub(start) as u32),
line_done
);
let mut line_done = false;
let mut frame = 0;
loop {
vblank.wait_for_vblank();
input.update();
let oam = &mut unmanaged.iter();
wr.commit(oam);
let start = timer.value();
if frame % 4 == 0 {
line_done = !wr.next_letter_group();
}
if line_done && input.is_just_pressed(Button::A) {
line_done = false;
wr.pop_line();
}
wr.update((0, HEIGHT - 40).into());
let end = timer.value();
frame += 1;
agb::println!(
"Took {} cycles, line done {}",
256 * (end.wrapping_sub(start) as u32),
line_done
);
}
}
}

View file

@ -3,9 +3,7 @@
use agb::{
display::{
tiled::{
RegularBackgroundSize, RegularMap, TileFormat, TileSetting, TiledMap, VRamManager,
},
tiled::{RegularBackgroundSize, RegularMap, TileFormat, TiledMap, VRamManager},
Font, Priority,
},
include_font, include_wav,
@ -98,7 +96,7 @@ fn init_background(bg: &mut RegularMap, vram: &mut VRamManager) {
vram,
(x, y).into(),
&background_tile.tile_set(),
TileSetting::from_raw(background_tile.tile_index()),
background_tile.tile_setting(),
);
}
}

View file

@ -3,7 +3,7 @@
use agb::{
display::{
tiled::{RegularBackgroundSize, TileFormat, TileSetting, TiledMap},
tiled::{RegularBackgroundSize, TileFormat, TiledMap},
Font, Priority,
},
include_font,
@ -37,7 +37,7 @@ fn main(mut gba: agb::Gba) -> ! {
&mut vram,
(x, y).into(),
&background_tile.tile_set(),
TileSetting::from_raw(background_tile.tile_index()),
background_tile.tile_setting(),
);
}
}

View file

@ -1,5 +0,0 @@
version = "1.0"
[image.water_tiles]
filename = "water_tiles.png"
tile_size = "8x8"

View file

@ -1,22 +1,11 @@
use super::tiled::{RegularMap, TileFormat, TileSet, TileSetting, TiledMap, VRamManager};
use super::tiled::{RegularMap, TiledMap, VRamManager};
crate::include_background_gfx!(crate, agb_logo, test_logo => "gfx/test_logo.png");
crate::include_background_gfx!(crate, agb_logo, test_logo => deduplicate "gfx/test_logo.png");
pub fn display_logo(map: &mut RegularMap, vram: &mut VRamManager) {
vram.set_background_palettes(agb_logo::PALETTES);
let background_tilemap = TileSet::new(agb_logo::test_logo.tiles, TileFormat::FourBpp);
for y in 0..20 {
for x in 0..30 {
let tile_id = y * 30 + x;
let palette_entry = agb_logo::test_logo.palette_assignments[tile_id as usize];
let tile_setting = TileSetting::new(tile_id, false, false, palette_entry);
map.set_tile(vram, (x, y).into(), &background_tilemap, tile_setting);
}
}
map.fill_with(vram, &agb_logo::test_logo);
map.commit(vram);
map.show();
@ -35,7 +24,7 @@ mod tests {
let mut map = gfx.background(
Priority::P0,
RegularBackgroundSize::Background32x32,
TileFormat::FourBpp,
agb_logo::test_logo.tiles.format(),
);
display_logo(&mut map, &mut vram);

View file

@ -3,7 +3,7 @@ use core::fmt::{Error, Write};
use crate::fixnum::Vector2D;
use crate::hash_map::HashMap;
use super::tiled::{DynamicTile, RegularMap, TileSetting, VRamManager};
use super::tiled::{DynamicTile, RegularMap, VRamManager};
/// The text renderer renders a variable width fixed size
/// bitmap font using dynamic tiles as a rendering surface.
@ -230,7 +230,7 @@ impl<'a, 'b> TextRenderer<'b> {
vram_manager,
(self.tile_pos.x + *x as u16, self.tile_pos.y + *y as u16).into(),
&tile.tile_set(),
TileSetting::from_raw(tile.tile_index()),
tile.tile_setting(),
);
}
}
@ -294,7 +294,7 @@ mod tests {
&mut vram,
(x, y).into(),
&background_tile.tile_set(),
TileSetting::from_raw(background_tile.tile_index()),
background_tile.tile_setting(),
);
}
}

View file

@ -1,15 +1,17 @@
use super::tiled::{TileSet, TileSetting};
#[non_exhaustive]
pub struct TileData {
pub tiles: &'static [u8],
pub palette_assignments: &'static [u8],
pub tiles: TileSet<'static>,
pub tile_settings: &'static [TileSetting],
}
impl TileData {
#[must_use]
pub const fn new(tiles: &'static [u8], palette_assignments: &'static [u8]) -> Self {
pub const fn new(tiles: TileSet<'static>, tile_settings: &'static [TileSetting]) -> Self {
TileData {
tiles,
palette_assignments,
tile_settings,
}
}
}

View file

@ -40,29 +40,27 @@ use crate::{
/// use agb::display::Priority;
///
/// mod tilemap {
/// pub const BACKGROUND_MAP: &[u16] = &[ // Probably load this from a file
/// pub const BACKGROUND_MAP: &[usize] = &[ // Probably load this from a file
/// # 0, 1, 2];
/// pub const WIDTH: i32 = // set it to some width
/// # 12;
/// pub const MAP_TILES: &[u8] = &[ // probably load this from a file
/// # 0];
/// }
///
/// agb::include_background_gfx!(water_tiles, tiles => "examples/water_tiles.png");
///
/// # fn foo(mut gba: agb::Gba) {
/// let (gfx, mut vram) = gba.display.video.tiled0();
///
/// let tileset = TileSet::new(&tilemap::MAP_TILES, TileFormat::FourBpp);
/// let tile_data = water_tiles::tiles;
///
/// let mut backdrop = InfiniteScrolledMap::new(
/// gfx.background(Priority::P2, RegularBackgroundSize::Background32x32, TileFormat::FourBpp),
/// Box::new(|pos| {
/// (
/// &tileset,
/// TileSetting::from_raw(
/// *tilemap::BACKGROUND_MAP
/// &tile_data.tiles,
/// tile_data.tile_settings[*tilemap::BACKGROUND_MAP
/// .get((pos.x + tilemap::WIDTH * pos.y) as usize)
/// .unwrap_or(&0),
/// ),
/// .unwrap_or(&0)]
/// )
/// }),
/// );
@ -135,26 +133,27 @@ impl<'a> InfiniteScrolledMap<'a> {
/// # use agb::display::Priority;
/// #
/// # mod tilemap {
/// # pub const BACKGROUND_MAP: &[u16] = &[0, 1, 2];
/// # pub const BACKGROUND_MAP: &[usize] = &[0, 1, 2];
/// # pub const WIDTH: i32 = 12;
/// # pub const MAP_TILES: &[u8] = &[0];
/// # }
/// #
/// # agb::include_background_gfx!(water_tiles, tiles => "examples/water_tiles.png");
/// #
/// # fn foo(mut gba: agb::Gba) {
/// # let (gfx, mut vram) = gba.display.video.tiled0();
/// #
/// # let tileset = TileSet::new(&tilemap::MAP_TILES, TileFormat::FourBpp);
/// # let tile_data = water_tiles::tiles;
/// #
/// # let mut backdrop = InfiniteScrolledMap::new(
/// # gfx.background(Priority::P2, RegularBackgroundSize::Background32x32, TileFormat::FourBpp),
/// # Box::new(|pos| {
/// # (
/// # &tileset,
/// # TileSetting::from_raw(
/// # &tile_data.tiles,
/// # tile_data.tile_settings[
/// # *tilemap::BACKGROUND_MAP
/// # .get((pos.x + tilemap::WIDTH * pos.y) as usize)
/// # .unwrap_or(&0),
/// # ),
/// # .unwrap_or(&0)]
/// # )
/// # }),
/// # );
@ -210,26 +209,27 @@ impl<'a> InfiniteScrolledMap<'a> {
/// # use agb::display::Priority;
/// #
/// # mod tilemap {
/// # pub const BACKGROUND_MAP: &[u16] = &[0, 1, 2];
/// # pub const BACKGROUND_MAP: &[usize] = &[0, 1, 2];
/// # pub const WIDTH: i32 = 12;
/// # pub const MAP_TILES: &[u8] = &[0];
/// # }
/// #
/// # agb::include_background_gfx!(water_tiles, tiles => "examples/water_tiles.png");
/// #
/// # fn foo(mut gba: agb::Gba) {
/// # let (gfx, mut vram) = gba.display.video.tiled0();
/// #
/// # let tileset = TileSet::new(&tilemap::MAP_TILES, TileFormat::FourBpp);
/// # let tile_data = water_tiles::tiles;
/// #
/// # let mut backdrop = InfiniteScrolledMap::new(
/// # gfx.background(Priority::P2, RegularBackgroundSize::Background32x32, TileFormat::FourBpp),
/// # Box::new(|pos| {
/// # (
/// # &tileset,
/// # TileSetting::from_raw(
/// # &tile_data.tiles,
/// # tile_data.tile_settings[
/// # *tilemap::BACKGROUND_MAP
/// # .get((pos.x + tilemap::WIDTH * pos.y) as usize)
/// # .unwrap_or(&0),
/// # ),
/// # .unwrap_or(&0)]
/// # )
/// # }),
/// # );

View file

@ -3,6 +3,7 @@ use core::ops::{Deref, DerefMut};
use crate::bitarray::Bitarray;
use crate::display::affine::AffineMatrixBackground;
use crate::display::tile_data::TileData;
use crate::display::{Priority, DISPLAY_CONTROL};
use crate::dma::dma_copy16;
use crate::fixnum::Vector2D;
@ -10,7 +11,7 @@ use crate::memory_mapped::MemoryMapped;
use super::{
AffineBackgroundSize, BackgroundID, BackgroundSize, BackgroundSizePrivate,
RegularBackgroundSize, Tile, TileFormat, TileIndex, TileSet, TileSetting, VRamManager,
RegularBackgroundSize, Tile, TileFormat, TileSet, TileSetting, VRamManager,
};
use alloc::{vec, vec::Vec};
@ -20,10 +21,9 @@ pub trait TiledMapTypes: private::Sealed {
}
trait TiledMapPrivate: TiledMapTypes {
type TileType: Into<TileIndex> + Copy + Default + Eq + PartialEq;
type AffineMatrix;
fn tiles_mut(&mut self) -> &mut [Self::TileType];
fn tiles_mut(&mut self) -> &mut [Tile];
fn tiles_dirty(&mut self) -> &mut bool;
fn colours(&self) -> TileFormat;
@ -59,9 +59,11 @@ where
T::Size: BackgroundSizePrivate,
{
fn clear(&mut self, vram: &mut VRamManager) {
let colours = self.colours();
for tile in self.tiles_mut() {
if *tile != Default::default() {
vram.remove_tile((*tile).into());
vram.remove_tile(tile.tile_index(colours));
}
*tile = Default::default();
@ -82,18 +84,18 @@ where
fn commit(&mut self, vram: &mut VRamManager) {
let screenblock_memory = self.screenblock_memory();
let tile_count_divisor = self.colours().tile_size() / TileFormat::FourBpp.tile_size();
if *self.tiles_dirty() {
unsafe {
dma_copy16(
self.tiles_mut().as_ptr() as *const u16,
screenblock_memory,
self.map_size().num_tiles() / tile_count_divisor,
self.map_size().num_tiles(),
);
}
}
let tile_colour_flag: u16 = (tile_count_divisor == 2).into();
let tile_colour_flag: u16 = (self.colours() == TileFormat::EightBpp).into();
let new_bg_control_value = (self.priority() as u16)
| ((self.screenblock() as u16) << 8)
@ -127,17 +129,16 @@ pub struct RegularMap {
tiles_dirty: bool,
}
pub const TRANSPARENT_TILE_INDEX: u16 = (1 << 10) - 1;
pub(crate) const TRANSPARENT_TILE_INDEX: u16 = (1 << 10) - 1;
impl TiledMapTypes for RegularMap {
type Size = RegularBackgroundSize;
}
impl TiledMapPrivate for RegularMap {
type TileType = Tile;
type AffineMatrix = ();
fn tiles_mut(&mut self) -> &mut [Self::TileType] {
fn tiles_mut(&mut self) -> &mut [Tile] {
&mut self.tiles
}
fn tiles_dirty(&mut self) -> &mut bool {
@ -188,6 +189,34 @@ impl RegularMap {
}
}
pub fn fill_with(&mut self, vram: &mut VRamManager, tile_data: &TileData) {
assert!(
tile_data.tile_settings.len() >= 20 * 30,
"Don't have a full screen's worth of tile data"
);
assert_eq!(
tile_data.tiles.format(),
self.colours(),
"Cannot set a {:?} colour tile on a {:?} colour background",
tile_data.tiles.format(),
self.colours()
);
for y in 0..20 {
for x in 0..30 {
let tile_id = y * 30 + x;
let tile_pos = y * 32 + x;
self.set_tile_at_pos(
vram,
tile_pos,
&tile_data.tiles,
tile_data.tile_settings[tile_id],
);
}
}
}
pub fn set_tile(
&mut self,
vram: &mut VRamManager,
@ -195,19 +224,28 @@ impl RegularMap {
tileset: &TileSet<'_>,
tile_setting: TileSetting,
) {
if tileset.format() != self.colours() {
panic!(
"Cannot set a {:?} colour tile on a {:?} colour background",
tileset.format(),
self.colours()
);
}
assert_eq!(
tileset.format(),
self.colours(),
"Cannot set a {:?} colour tile on a {:?} colour background",
tileset.format(),
self.colours()
);
let pos = self.map_size().gba_offset(pos);
self.set_tile_at_pos(vram, pos, tileset, tile_setting);
}
fn set_tile_at_pos(
&mut self,
vram: &mut VRamManager,
pos: usize,
tileset: &TileSet<'_>,
tile_setting: TileSetting,
) {
let old_tile = self.tiles_mut()[pos];
if old_tile != Tile::default() {
vram.remove_tile(old_tile.into());
vram.remove_tile(old_tile.tile_index(self.colours()));
}
let tile_index = tile_setting.index();
@ -254,7 +292,7 @@ pub struct AffineMap {
transform: AffineMatrixBackground,
tiles: Vec<u8>,
tiles: Vec<Tile>,
tiles_dirty: bool,
}
@ -263,10 +301,9 @@ impl TiledMapTypes for AffineMap {
}
impl TiledMapPrivate for AffineMap {
type TileType = u8;
type AffineMatrix = AffineMatrixBackground;
fn tiles_mut(&mut self) -> &mut [Self::TileType] {
fn tiles_mut(&mut self) -> &mut [Tile] {
&mut self.tiles
}
fn tiles_dirty(&mut self) -> &mut bool {
@ -320,19 +357,20 @@ impl AffineMap {
tile_id: u8,
) {
let pos = self.map_size().gba_offset(pos);
let colours = self.colours();
let old_tile = self.tiles_mut()[pos];
if old_tile != 0 {
vram.remove_tile(old_tile.into());
if old_tile != Tile::default() {
vram.remove_tile(old_tile.tile_index(colours));
}
let tile_index = tile_id as u16;
let new_tile = if tile_index != TRANSPARENT_TILE_INDEX {
let new_tile_idx = vram.add_tile(tileset, tile_index);
new_tile_idx.raw_index() as u8
Tile::new(new_tile_idx, TileSetting(0))
} else {
0
Tile::default()
};
if old_tile == new_tile {

View file

@ -16,6 +16,8 @@ pub use tiled1::Tiled1;
pub use tiled2::Tiled2;
pub use vram_manager::{DynamicTile, TileFormat, TileIndex, TileSet, VRamManager};
use map::TRANSPARENT_TILE_INDEX;
// affine layers start at BG2
pub(crate) const AFFINE_BG_ID_OFFSET: usize = 2;
@ -156,8 +158,8 @@ impl Tile {
Self(idx.raw_index() | setting.setting())
}
fn tile_index(self) -> TileIndex {
TileIndex::new(self.0 as usize & ((1 << 10) - 1), TileFormat::FourBpp)
fn tile_index(self, format: TileFormat) -> TileIndex {
TileIndex::new(self.0 as usize & ((1 << 10) - 1), format)
}
}
@ -165,6 +167,8 @@ impl Tile {
pub struct TileSetting(u16);
impl TileSetting {
pub const BLANK: Self = TileSetting::new(TRANSPARENT_TILE_INDEX, false, false, 0);
#[must_use]
pub const fn new(tile_id: u16, hflip: bool, vflip: bool, palette_id: u8) -> Self {
Self(
@ -180,6 +184,16 @@ impl TileSetting {
Self(raw)
}
#[must_use]
pub const fn hflip(self, should_flip: bool) -> Self {
Self(self.0 ^ ((should_flip as u16) << 10))
}
#[must_use]
pub const fn vflip(self, should_flip: bool) -> Self {
Self(self.0 ^ ((should_flip as u16) << 11))
}
fn index(self) -> u16 {
self.0 & ((1 << 10) - 1)
}

View file

@ -2,7 +2,6 @@ use core::{alloc::Layout, ptr::NonNull};
use alloc::{slice, vec::Vec};
use crate::display::tiled::Tile;
use crate::{
agb_alloc::{block_allocator::BlockAllocator, bump_allocator::StartEnd},
display::palette16,
@ -11,6 +10,8 @@ use crate::{
memory_mapped::MemoryMapped1DArray,
};
use super::TileSetting;
const TILE_RAM_START: usize = 0x0600_0000;
const PALETTE_BACKGROUND: MemoryMapped1DArray<u16, 256> =
@ -29,17 +30,14 @@ const fn layout_of(format: TileFormat) -> Layout {
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum TileFormat {
FourBpp,
EightBpp,
FourBpp = 5,
EightBpp = 6,
}
impl TileFormat {
/// Returns the size of the tile in bytes
pub(crate) const fn tile_size(self) -> usize {
match self {
TileFormat::FourBpp => 8 * 8 / 2,
TileFormat::EightBpp => 8 * 8,
}
1 << self as usize
}
}
@ -50,37 +48,38 @@ pub struct TileSet<'a> {
impl<'a> TileSet<'a> {
#[must_use]
pub fn new(tiles: &'a [u8], format: TileFormat) -> Self {
pub const fn new(tiles: &'a [u8], format: TileFormat) -> Self {
Self { tiles, format }
}
#[must_use]
pub const fn format(&self) -> TileFormat {
self.format
}
fn reference(&self) -> NonNull<[u8]> {
self.tiles.into()
}
pub(crate) fn format(&self) -> TileFormat {
self.format
}
}
#[derive(Debug, Clone, Copy)]
pub enum TileIndex {
FourBpp(u16),
EightBpp(u8),
EightBpp(u16),
}
impl TileIndex {
pub(crate) const fn new(index: usize, format: TileFormat) -> Self {
match format {
TileFormat::FourBpp => Self::FourBpp(index as u16),
TileFormat::EightBpp => Self::EightBpp(index as u8),
TileFormat::EightBpp => Self::EightBpp(index as u16),
}
}
pub(crate) const fn raw_index(self) -> u16 {
match self {
TileIndex::FourBpp(x) => x,
TileIndex::EightBpp(x) => x as u16,
TileIndex::EightBpp(x) => x,
}
}
@ -99,18 +98,6 @@ impl TileIndex {
}
}
impl From<Tile> for TileIndex {
fn from(tile: Tile) -> Self {
tile.tile_index()
}
}
impl From<u8> for TileIndex {
fn from(index: u8) -> TileIndex {
TileIndex::new(usize::from(index), TileFormat::EightBpp)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
struct TileReference(NonNull<u32>);
@ -201,9 +188,11 @@ impl DynamicTile<'_> {
}
#[must_use]
pub fn tile_index(&self) -> u16 {
pub fn tile_setting(&self) -> TileSetting {
let difference = self.tile_data.as_ptr() as usize - TILE_RAM_START;
(difference / TileFormat::FourBpp.tile_size()) as u16
let tile_id = (difference / TileFormat::FourBpp.tile_size()) as u16;
TileSetting::new(tile_id, false, false, 0)
}
}
@ -302,7 +291,7 @@ impl VRamManager {
let new_reference: NonNull<u32> =
unsafe { TILE_ALLOCATOR.alloc(layout_of(tile_set.format)) }
.unwrap()
.expect("Ran out of video RAM for tiles")
.cast();
let tile_reference = TileReference(new_reference);
reference.or_insert(tile_reference);
@ -384,21 +373,41 @@ impl VRamManager {
tile_id: u16,
tile_reference: TileReference,
) {
let tile_size = tile_set.format.tile_size();
let tile_format = tile_set.format;
let tile_size = tile_format.tile_size();
let tile_offset = (tile_id as usize) * tile_size;
let tile_slice = &tile_set.tiles[tile_offset..(tile_offset + tile_size)];
let tile_size_in_half_words = tile_slice.len() / 2;
let tile_data_start = unsafe { tile_set.tiles.as_ptr().add(tile_offset) };
let target_location = tile_reference.0.as_ptr() as *mut _;
unsafe {
dma_copy16(
tile_slice.as_ptr() as *const u16,
target_location,
tile_size_in_half_words,
);
};
match tile_format {
TileFormat::FourBpp => core::arch::asm!(
".rept 2",
"ldmia {src}!, {{{tmp1},{tmp2},{tmp3},{tmp4}}}",
"stmia {dest}!, {{{tmp1},{tmp2},{tmp3},{tmp4}}}",
".endr",
src = inout(reg) tile_data_start => _,
dest = inout(reg) target_location => _,
tmp1 = out(reg) _,
tmp2 = out(reg) _,
tmp3 = out(reg) _,
tmp4 = out(reg) _,
),
TileFormat::EightBpp => core::arch::asm!(
".rept 4",
"ldmia {src}!, {{{tmp1},{tmp2},{tmp3},{tmp4}}}",
"stmia {dest}!, {{{tmp1},{tmp2},{tmp3},{tmp4}}}",
".endr",
src = inout(reg) tile_data_start => _,
dest = inout(reg) target_location => _,
tmp1 = out(reg) _,
tmp2 = out(reg) _,
tmp3 = out(reg) _,
tmp4 = out(reg) _,
),
}
}
}
/// Copies raw palettes to the background palette without any checks.

View file

@ -33,7 +33,7 @@
//!
//! To get started with agb, you should clone the [template repo](https://github.com/agbrs/template) and work from there.
/// This macro is used to convert a png or bmp into a format usable by the Game Boy Advance.
/// This macro is used to convert a png, bmp or aseprite file into a format usable by the Game Boy Advance.
///
/// Suppose you have a file in `examples/water_tiles.png` which contains some tiles you'd like to use.
///
@ -77,11 +77,11 @@
/// agb::include_background_gfx!(water_tiles, tiles => "examples/water_tiles.png");
///
/// # fn load_tileset(mut gfx: Tiled0, mut vram: VRamManager) {
/// let tileset = TileSet::new(water_tiles::tiles.tiles, TileFormat::FourBpp);
/// let tileset = water_tiles::tiles.tiles;
///
/// vram.set_background_palettes(water_tiles::PALETTES);
///
/// let mut bg = gfx.background(Priority::P0, RegularBackgroundSize::Background32x32, TileFormat::FourBpp);
/// let mut bg = gfx.background(Priority::P0, RegularBackgroundSize::Background32x32, tileset.format());
///
/// for y in 0..20u16 {
/// for x in 0..30u16 {
@ -89,7 +89,7 @@
/// &mut vram,
/// (x, y).into(),
/// &tileset,
/// TileSetting::new(0, false, false, 0),
/// water_tiles::tiles.tile_settings[0],
/// );
/// }
/// }
@ -231,6 +231,10 @@ pub struct Gba {
impl Gba {
#[doc(hidden)]
#[must_use]
/// # Safety
///
/// May only be called a single time. It is not needed to call this due to
/// it being called internally by the [`entry`] macro.
pub unsafe fn new_in_entry() -> Self {
Self::single_new()
}

View file

@ -64,6 +64,9 @@ agb_arm_func \fn_name
bne 4b
5:
cmp r2, #0
beq 3f
.irp reg, r7,r8,r9,r10
mov \reg, #0
.endr

View file

@ -33,6 +33,8 @@ pub fn memory_write_hint<T>(val: *mut T) {
/// This seems to be a problem caused by Rust issue #62256:
/// <https://github.com/rust-lang/rust/issues/62256>
///
/// # Safety
///
/// **WARNING FOR ANYONE WHO FINDS THIS**: This implementation will *only* be
/// correct on the GBA, and should not be used on any other platform. The GBA
/// is very old, and has no atomics to begin with - only a main thread and

View file

@ -154,9 +154,9 @@ checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
[[package]]
name = "bytemuck"
version = "1.13.1"
version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea"
checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6"
[[package]]
name = "byteorder"
@ -203,9 +203,9 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
[[package]]
name = "flate2"
version = "1.0.26"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743"
checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010"
dependencies = [
"crc32fast",
"miniz_oxide 0.7.1",
@ -390,9 +390,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.32"
version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
"proc-macro2",
]
@ -405,9 +405,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "syn"
version = "2.0.28"
version = "2.0.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567"
checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2"
dependencies = [
"proc-macro2",
"quote",
@ -422,9 +422,9 @@ checksum = "7b3e06c9b9d80ed6b745c7159c40b311ad2916abb34a49e9be2653b90db0d8dd"
[[package]]
name = "unicode-ident"
version = "1.0.11"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "version_check"

177
emulator/Cargo.lock generated
View file

@ -19,33 +19,32 @@ dependencies = [
[[package]]
name = "aho-corasick"
version = "1.0.3"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86b8f9420f797f2d9e935edf629310eb938a0d839f984e25327f3c7eed22300c"
checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783"
dependencies = [
"memchr",
]
[[package]]
name = "anstream"
version = "0.3.2"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163"
checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is-terminal",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.1"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd"
checksum = "b84bf0a05bbb2a83e5eb6fa36bb6e87baa08193c35ff52bbf6b38d8af2890e46"
[[package]]
name = "anstyle-parse"
@ -67,9 +66,9 @@ dependencies = [
[[package]]
name = "anstyle-wincon"
version = "1.0.2"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c677ab05e09154296dd37acecd46420c17b9713e8366facafa8fc0885167cf4c"
checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd"
dependencies = [
"anstyle",
"windows-sys",
@ -77,9 +76,9 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.72"
version = "1.0.75"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854"
checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
[[package]]
name = "autocfg"
@ -89,9 +88,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bindgen"
version = "0.66.1"
version = "0.68.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7"
checksum = "726e4313eb6ec35d2730258ad4e15b547ee75d6afaa1361a922e78e59b7d8078"
dependencies = [
"bitflags 2.4.0",
"cexpr",
@ -124,9 +123,9 @@ checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
[[package]]
name = "bytemuck"
version = "1.13.1"
version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea"
checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6"
[[package]]
name = "byteorder"
@ -136,9 +135,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "cc"
version = "1.0.82"
version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "305fe645edc1442a0fa8b6726ba61d422798d37a52e12eaecf4b022ebbb88f01"
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
dependencies = [
"libc",
]
@ -171,20 +170,19 @@ dependencies = [
[[package]]
name = "clap"
version = "4.3.21"
version = "4.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c27cdf28c0f604ba3f512b0c9a409f8de8513e4816705deb0498b627e7c3a3fd"
checksum = "84ed82781cea27b43c9b106a979fe450a13a31aab0500595fb3fc06616de08e6"
dependencies = [
"clap_builder",
"clap_derive",
"once_cell",
]
[[package]]
name = "clap_builder"
version = "4.3.21"
version = "4.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08a9f1ab5e9f01a9b81f202e8562eb9a10de70abf9eaeac1be465c28b75aa4aa"
checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08"
dependencies = [
"anstream",
"anstyle",
@ -194,9 +192,9 @@ dependencies = [
[[package]]
name = "clap_derive"
version = "4.3.12"
version = "4.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050"
checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873"
dependencies = [
"heck",
"proc-macro2",
@ -206,9 +204,9 @@ dependencies = [
[[package]]
name = "clap_lex"
version = "0.5.0"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b"
checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961"
[[package]]
name = "cmake"
@ -254,9 +252,9 @@ checksum = "e2b183d6ce6ca4cf30e3db37abf5b52568b5f9015c97d9fbdd7026aa5dcdd758"
[[package]]
name = "errno"
version = "0.3.2"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f"
checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd"
dependencies = [
"errno-dragonfly",
"libc",
@ -284,9 +282,9 @@ dependencies = [
[[package]]
name = "flate2"
version = "1.0.26"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743"
checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010"
dependencies = [
"crc32fast",
"miniz_oxide",
@ -305,10 +303,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "hermit-abi"
version = "0.3.2"
name = "home"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b"
checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb"
dependencies = [
"windows-sys",
]
[[package]]
name = "image"
@ -324,17 +325,6 @@ dependencies = [
"png",
]
[[package]]
name = "is-terminal"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
dependencies = [
"hermit-abi",
"rustix",
"windows-sys",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
@ -349,9 +339,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
version = "0.2.147"
version = "0.2.148"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b"
[[package]]
name = "libloading"
@ -365,9 +355,9 @@ dependencies = [
[[package]]
name = "linux-raw-sys"
version = "0.4.5"
version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503"
checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128"
[[package]]
name = "log"
@ -377,9 +367,9 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "memchr"
version = "2.5.0"
version = "2.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c"
[[package]]
name = "mgba"
@ -486,9 +476,9 @@ checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
[[package]]
name = "png"
version = "0.17.9"
version = "0.17.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59871cc5b6cce7eaccca5a802b4173377a1c2ba90654246789a8fa2334426d11"
checksum = "dd75bf2d8dd3702b9707cdbc56a5b9ef42cec752eb8b3bafc01234558442aa64"
dependencies = [
"bitflags 1.3.2",
"crc32fast",
@ -499,9 +489,9 @@ dependencies = [
[[package]]
name = "prettyplease"
version = "0.2.12"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c64d9ba0963cdcea2e1b2230fbae2bab30eb25a174be395c41e764bfb65dd62"
checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d"
dependencies = [
"proc-macro2",
"syn",
@ -518,18 +508,18 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.32"
version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
"proc-macro2",
]
[[package]]
name = "regex"
version = "1.9.3"
version = "1.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a"
checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47"
dependencies = [
"aho-corasick",
"memchr",
@ -539,9 +529,9 @@ dependencies = [
[[package]]
name = "regex-automata"
version = "0.3.6"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69"
checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795"
dependencies = [
"aho-corasick",
"memchr",
@ -550,9 +540,9 @@ dependencies = [
[[package]]
name = "regex-syntax"
version = "0.7.4"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2"
checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
[[package]]
name = "rustc-hash"
@ -562,9 +552,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustix"
version = "0.38.8"
version = "0.38.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19ed4fa021d81c8392ce04db050a3da9a60299050b7ae1cf482d862b54a7218f"
checksum = "d7db8590df6dfcd144d22afd1b83b36c21a18d7cbc1dc4bb5295a8712e9eb662"
dependencies = [
"bitflags 2.4.0",
"errno",
@ -575,9 +565,9 @@ dependencies = [
[[package]]
name = "shlex"
version = "1.1.0"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380"
[[package]]
name = "simd-adler32"
@ -593,9 +583,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "syn"
version = "2.0.28"
version = "2.0.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567"
checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2"
dependencies = [
"proc-macro2",
"quote",
@ -604,18 +594,18 @@ dependencies = [
[[package]]
name = "thiserror"
version = "1.0.44"
version = "1.0.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90"
checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.44"
version = "1.0.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96"
checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35"
dependencies = [
"proc-macro2",
"quote",
@ -624,9 +614,9 @@ dependencies = [
[[package]]
name = "unicode-ident"
version = "1.0.11"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "utf8parse"
@ -636,13 +626,14 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]]
name = "which"
version = "4.4.0"
version = "4.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269"
checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
dependencies = [
"either",
"libc",
"home",
"once_cell",
"rustix",
]
[[package]]
@ -678,9 +669,9 @@ dependencies = [
[[package]]
name = "windows-targets"
version = "0.48.1"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f"
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
@ -693,42 +684,42 @@ dependencies = [
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_i686_gnu"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_msvc"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"

View file

@ -15,6 +15,6 @@ exclude = [
[build-dependencies]
bindgen = "0.66"
bindgen = "0.68"
pkg-config = "0.3.27"
cmake = "0.1"

View file

@ -6,6 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
libc = "0.2.147"
libc = "0.2.148"
mgba-sys = { version = "0.1.0", path = "../mgba-sys" }
thiserror = "1"

View file

@ -161,9 +161,9 @@ checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
[[package]]
name = "bytemuck"
version = "1.13.1"
version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea"
checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6"
[[package]]
name = "byteorder"
@ -210,9 +210,9 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
[[package]]
name = "flate2"
version = "1.0.26"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743"
checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010"
dependencies = [
"crc32fast",
"miniz_oxide 0.7.1",
@ -390,9 +390,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.32"
version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
"proc-macro2",
]
@ -405,9 +405,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "syn"
version = "2.0.28"
version = "2.0.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567"
checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2"
dependencies = [
"proc-macro2",
"quote",
@ -422,9 +422,9 @@ checksum = "7b3e06c9b9d80ed6b745c7159c40b311ad2916abb34a49e9be2653b90db0d8dd"
[[package]]
name = "unicode-ident"
version = "1.0.11"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "version_check"

View file

@ -52,7 +52,7 @@ dependencies = [
"image",
"proc-macro2",
"quote",
"syn",
"syn 2.0.32",
]
[[package]]
@ -61,7 +61,7 @@ version = "0.16.0"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.32",
]
[[package]]
@ -71,7 +71,47 @@ dependencies = [
"hound",
"proc-macro2",
"quote",
"syn",
"syn 2.0.32",
]
[[package]]
name = "agb_tracker"
version = "0.16.0"
dependencies = [
"agb",
"agb_tracker_interop",
"agb_xm",
]
[[package]]
name = "agb_tracker_interop"
version = "0.16.0"
dependencies = [
"agb_fixnum",
"proc-macro2",
"quote",
]
[[package]]
name = "agb_xm"
version = "0.16.0"
dependencies = [
"agb_xm_core",
"proc-macro-error",
"proc-macro2",
]
[[package]]
name = "agb_xm_core"
version = "0.16.0"
dependencies = [
"agb_fixnum",
"agb_tracker_interop",
"proc-macro-error",
"proc-macro2",
"quote",
"syn 2.0.32",
"xmrs",
]
[[package]]
@ -133,6 +173,12 @@ dependencies = [
"byteorder",
]
[[package]]
name = "base64"
version = "0.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2"
[[package]]
name = "bilge"
version = "0.2.0"
@ -153,7 +199,16 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
"syn",
"syn 2.0.32",
]
[[package]]
name = "bincode"
version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
dependencies = [
"serde",
]
[[package]]
@ -170,9 +225,9 @@ checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
[[package]]
name = "bytemuck"
version = "1.13.1"
version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea"
checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6"
[[package]]
name = "byteorder"
@ -199,6 +254,7 @@ dependencies = [
"agb",
"amplitude",
"hyperspace-roll",
"the-dungeon-puzzlers-lament",
"the-hat-chooses-the-wizard",
"the-purple-night",
]
@ -229,10 +285,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
[[package]]
name = "flate2"
version = "1.0.26"
name = "equivalent"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "flate2"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010"
dependencies = [
"crc32fast",
"miniz_oxide 0.7.1",
@ -244,7 +306,7 @@ version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0793f5137567643cf65ea42043a538804ff0fbf288649e2141442b602d81f9bc"
dependencies = [
"hashbrown",
"hashbrown 0.13.2",
"ttf-parser",
]
@ -257,6 +319,17 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "getrandom"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427"
dependencies = [
"cfg-if",
"libc",
"wasi",
]
[[package]]
name = "hashbrown"
version = "0.13.2"
@ -266,6 +339,12 @@ dependencies = [
"ahash",
]
[[package]]
name = "hashbrown"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
[[package]]
name = "hound"
version = "3.5.0"
@ -294,6 +373,16 @@ dependencies = [
"png",
]
[[package]]
name = "indexmap"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d"
dependencies = [
"equivalent",
"hashbrown 0.14.0",
]
[[package]]
name = "itertools"
version = "0.11.0"
@ -309,6 +398,12 @@ version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
[[package]]
name = "libc"
version = "0.2.148"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b"
[[package]]
name = "libflate"
version = "0.1.27"
@ -321,12 +416,38 @@ dependencies = [
"take_mut",
]
[[package]]
name = "libflate"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ff4ae71b685bbad2f2f391fe74f6b7659a34871c08b210fdc039e43bee07d18"
dependencies = [
"adler32",
"crc32fast",
"libflate_lz77",
]
[[package]]
name = "libflate_lz77"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a52d3a8bfc85f250440e4424db7d857e241a3aebbbe301f3eb606ab15c39acbf"
dependencies = [
"rle-decode-fast",
]
[[package]]
name = "log"
version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "memchr"
version = "2.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c"
[[package]]
name = "miniz_oxide"
version = "0.3.7"
@ -392,6 +513,27 @@ dependencies = [
"autocfg",
]
[[package]]
name = "num_enum"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a015b430d3c108a207fd776d2e2196aaf8b1cf8cf93253e3a097ff3085076a1"
dependencies = [
"num_enum_derive",
]
[[package]]
name = "num_enum_derive"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96667db765a921f7b295ffee8b60472b686a51d4f21c2ee4ffdb94c7013b65a6"
dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote",
"syn 2.0.32",
]
[[package]]
name = "once_cell"
version = "1.18.0"
@ -410,6 +552,22 @@ dependencies = [
"miniz_oxide 0.3.7",
]
[[package]]
name = "ppv-lite86"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "proc-macro-crate"
version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919"
dependencies = [
"once_cell",
"toml_edit",
]
[[package]]
name = "proc-macro-error"
version = "1.0.4"
@ -419,6 +577,7 @@ dependencies = [
"proc-macro-error-attr",
"proc-macro2",
"quote",
"syn 1.0.109",
"version_check",
]
@ -444,13 +603,43 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.32"
version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rand"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
"libc",
"rand_chacha",
"rand_core",
]
[[package]]
name = "rand_chacha"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
"rand_core",
]
[[package]]
name = "rand_core"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [
"getrandom",
]
[[package]]
name = "rle-decode-fast"
version = "1.0.3"
@ -471,29 +660,38 @@ checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
[[package]]
name = "serde"
version = "1.0.183"
version = "1.0.188"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c"
checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.183"
name = "serde-big-array"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816"
checksum = "11fc7cc2c76d73e0f27ee52abbd64eec84d46f370c88371120433196934e4b7f"
dependencies = [
"serde",
]
[[package]]
name = "serde_derive"
version = "1.0.188"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.32",
]
[[package]]
name = "serde_json"
version = "1.0.104"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c"
checksum = "2cc66a619ed80bf7a0f6b17dd063a84b88f6dea1813737cf469aef1d081142c2"
dependencies = [
"itoa",
"ryu",
@ -501,10 +699,29 @@ dependencies = [
]
[[package]]
name = "syn"
version = "2.0.28"
name = "slotmap"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567"
checksum = "e1e08e261d0e8f5c43123b7adf3e4ca1690d655377ac93a03b2c9d3e98de1342"
dependencies = [
"version_check",
]
[[package]]
name = "syn"
version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2",
"unicode-ident",
]
[[package]]
name = "syn"
version = "2.0.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2"
dependencies = [
"proc-macro2",
"quote",
@ -517,6 +734,18 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60"
[[package]]
name = "the-dungeon-puzzlers-lament"
version = "0.1.0"
dependencies = [
"agb",
"agb_tracker",
"proc-macro2",
"quote",
"slotmap",
"tiled 0.11.1",
]
[[package]]
name = "the-hat-chooses-the-wizard"
version = "0.1.0"
@ -533,7 +762,7 @@ dependencies = [
"agb",
"generational-arena",
"quote",
"tiled",
"tiled 0.9.4",
]
[[package]]
@ -542,11 +771,39 @@ version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d2c30aeea9d8159cb461a17dba23ad28980a2a9c217a6784a14e931e4979d6f"
dependencies = [
"base64",
"libflate",
"base64 0.10.1",
"libflate 0.1.27",
"xml-rs",
]
[[package]]
name = "tiled"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "181e2402be287d74e951a8e81c8798d0737cc94b1a089237bb3b838be76c6b5b"
dependencies = [
"base64 0.21.4",
"libflate 1.4.0",
"xml-rs",
]
[[package]]
name = "toml_datetime"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b"
[[package]]
name = "toml_edit"
version = "0.19.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
dependencies = [
"indexmap",
"toml_datetime",
"winnow",
]
[[package]]
name = "ttf-parser"
version = "0.15.2"
@ -555,9 +812,9 @@ checksum = "7b3e06c9b9d80ed6b745c7159c40b311ad2916abb34a49e9be2653b90db0d8dd"
[[package]]
name = "unicode-ident"
version = "1.0.11"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "version_check"
@ -566,7 +823,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "xml-rs"
version = "0.8.16"
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47430998a7b5d499ccee752b41567bc3afc57e1327dc855b1a2aa44ce29b5fa1"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "winnow"
version = "0.5.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc"
dependencies = [
"memchr",
]
[[package]]
name = "xml-rs"
version = "0.8.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bab77e97b50aee93da431f2cee7cd0f43b4d1da3c408042f2d7d164187774f0a"
[[package]]
name = "xmrs"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fa1ec7c01e6bb4c716f84a418f4ced5f4a735b2ae6364f4bb5850da61321d16"
dependencies = [
"bincode",
"libflate 1.4.0",
"num_enum",
"rand",
"serde",
"serde-big-array",
]

View file

@ -11,6 +11,7 @@ the-purple-night = { path = "../the-purple-night" }
the-hat-chooses-the-wizard = { path = "../the-hat-chooses-the-wizard" }
hyperspace-roll = { path = "../hyperspace-roll" }
amplitude = { path = "../amplitude" }
the-dungeon-puzzlers-lament = { path = "../the-dungeon-puzzlers-lament" }
[profile.dev]
opt-level = 3

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

View file

@ -8,7 +8,7 @@ use alloc::boxed::Box;
use agb::{
display::{
tiled::{InfiniteScrolledMap, RegularBackgroundSize, TileFormat, TileSet, TileSetting},
tiled::{InfiniteScrolledMap, RegularBackgroundSize, TileFormat},
Priority,
},
fixnum::{Num, Vector2D},
@ -21,6 +21,7 @@ pub enum Game {
TheHatChoosesTheWizard,
ThePurpleNight,
HyperspaceRoll,
TheDungeonPuzzlersLament,
Amplitude,
}
@ -30,6 +31,7 @@ impl Game {
Game::TheHatChoosesTheWizard => the_hat_chooses_the_wizard::main(gba),
Game::ThePurpleNight => the_purple_night::main(gba),
Game::HyperspaceRoll => hyperspace_roll::main(gba),
Game::TheDungeonPuzzlersLament => the_dungeon_puzzlers_lament::entry(gba),
Game::Amplitude => amplitude::main(gba),
}
}
@ -39,7 +41,8 @@ impl Game {
0 => Game::TheHatChoosesTheWizard,
1 => Game::ThePurpleNight,
2 => Game::HyperspaceRoll,
3 => Game::Amplitude,
3 => Game::TheDungeonPuzzlersLament,
4 => Game::Amplitude,
_ => unreachable!("game out of index in an unreachable manner"),
}
}
@ -47,10 +50,11 @@ impl Game {
include_background_gfx!(
games, "121105",
hat => "gfx/hat.png",
purple => "gfx/purple.png",
hyperspace => "gfx/hyperspace.png",
amplitude => "gfx/amplitude.png"
hat => 256 deduplicate "gfx/hat.png",
purple => 256 deduplicate "gfx/purple.png",
hyperspace => 256 deduplicate "gfx/hyperspace.png",
dungeon_puzzler => 256 deduplicate "gfx/dungeon_puzzler.png",
amplitude => 256 deduplicate "gfx/amplitude.png",
);
fn get_game(gba: &mut agb::Gba) -> Game {
@ -59,18 +63,12 @@ fn get_game(gba: &mut agb::Gba) -> Game {
let (tile, mut vram) = gba.display.video.tiled0();
let hat = TileSet::new(games::hat.tiles, TileFormat::FourBpp);
let purple = TileSet::new(games::purple.tiles, TileFormat::FourBpp);
let hyperspace = TileSet::new(games::hyperspace.tiles, TileFormat::FourBpp);
let amplitude = TileSet::new(games::amplitude.tiles, TileFormat::FourBpp);
let tiles = [hat, purple, hyperspace, amplitude];
let palette_assignments = &[
games::hat.palette_assignments,
games::purple.palette_assignments,
games::hyperspace.palette_assignments,
games::amplitude.palette_assignments,
let tiles = [
games::hat,
games::purple,
games::hyperspace,
games::dungeon_puzzler,
games::amplitude,
];
vram.set_background_palettes(games::PALETTES);
@ -79,7 +77,7 @@ fn get_game(gba: &mut agb::Gba) -> Game {
tile.background(
Priority::P0,
RegularBackgroundSize::Background32x32,
TileFormat::FourBpp,
TileFormat::EightBpp,
),
Box::new(|pos| {
let y = pos.y.rem_euclid(20);
@ -87,15 +85,7 @@ fn get_game(gba: &mut agb::Gba) -> Game {
let game = (pos.x).rem_euclid(tiles.len() as i32 * 30) as usize / 30;
let tile_id = (y * 30 + x) as usize;
(
&tiles[game],
TileSetting::new(
tile_id as u16,
false,
false,
palette_assignments[game][tile_id],
),
)
(&tiles[game].tiles, tiles[game].tile_settings[tile_id])
}),
);

View file

@ -154,9 +154,9 @@ checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
[[package]]
name = "bytemuck"
version = "1.13.1"
version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea"
checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6"
[[package]]
name = "byteorder"
@ -203,9 +203,9 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
[[package]]
name = "flate2"
version = "1.0.26"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743"
checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010"
dependencies = [
"crc32fast",
"miniz_oxide 0.7.1",
@ -390,9 +390,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.32"
version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
"proc-macro2",
]
@ -405,9 +405,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "syn"
version = "2.0.28"
version = "2.0.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567"
checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2"
dependencies = [
"proc-macro2",
"quote",
@ -422,9 +422,9 @@ checksum = "7b3e06c9b9d80ed6b745c7159c40b311ad2916abb34a49e9be2653b90db0d8dd"
[[package]]
name = "unicode-ident"
version = "1.0.11"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "version_check"

View file

@ -1,16 +1,16 @@
use agb::{
display::tiled::{RegularMap, TileFormat, TileSet, TileSetting, TiledMap, VRamManager},
display::tiled::{RegularMap, TileSet, TileSetting, TiledMap, VRamManager},
include_background_gfx, rng,
};
use crate::sfx::Sfx;
include_background_gfx!(backgrounds, "121105",
stars => "gfx/stars.aseprite",
title => "gfx/title-screen.aseprite",
help => "gfx/help-text.aseprite",
descriptions1 => "gfx/descriptions1.png",
descriptions2 => "gfx/descriptions2.png",
stars => deduplicate "gfx/stars.aseprite",
title => deduplicate "gfx/title-screen.aseprite",
help => deduplicate "gfx/help-text.aseprite",
descriptions1 => deduplicate "gfx/descriptions1.png",
descriptions2 => deduplicate "gfx/descriptions2.png",
);
pub fn load_palettes(vram: &mut VRamManager) {
@ -23,10 +23,7 @@ pub(crate) fn load_help_text(
help_text_line: u16,
at_tile: (u16, u16),
) {
let help_tileset = TileSet::new(
backgrounds::help.tiles,
agb::display::tiled::TileFormat::FourBpp,
);
let help_tiledata = backgrounds::help;
for x in 0..16 {
let tile_id = help_text_line * 16 + x;
@ -34,13 +31,8 @@ pub(crate) fn load_help_text(
background.set_tile(
vram,
(x + at_tile.0, at_tile.1).into(),
&help_tileset,
TileSetting::new(
tile_id,
false,
false,
backgrounds::help.palette_assignments[tile_id as usize],
),
&help_tiledata.tiles,
help_tiledata.tile_settings[tile_id as usize],
)
}
}
@ -50,22 +42,10 @@ pub(crate) fn load_description(
descriptions_map: &mut RegularMap,
vram: &mut VRamManager,
) {
let (tileset, palette_assignments) = if face_id < 10 {
(
TileSet::new(
backgrounds::descriptions1.tiles,
agb::display::tiled::TileFormat::FourBpp,
),
backgrounds::descriptions1.palette_assignments,
)
let description_data = if face_id < 10 {
backgrounds::descriptions1
} else {
(
TileSet::new(
backgrounds::descriptions2.tiles,
agb::display::tiled::TileFormat::FourBpp,
),
backgrounds::descriptions2.palette_assignments,
)
backgrounds::descriptions2
};
for y in 0..11 {
@ -74,8 +54,8 @@ pub(crate) fn load_description(
descriptions_map.set_tile(
vram,
(x, y).into(),
&tileset,
TileSetting::new(tile_id, false, false, palette_assignments[tile_id as usize]),
&description_data.tiles,
description_data.tile_settings[tile_id as usize],
)
}
}
@ -87,16 +67,12 @@ fn create_background_map(map: &mut RegularMap, vram: &mut VRamManager, stars_til
for y in 0..32u16 {
let blank = rng::gen().rem_euclid(32) < 30;
let (tile_id, palette_id) = if blank {
((1 << 10) - 1, 0)
let tile_setting = if blank {
TileSetting::BLANK
} else {
let tile_id = rng::gen().rem_euclid(64) as u16;
(
tile_id,
backgrounds::stars.palette_assignments[tile_id as usize],
)
backgrounds::stars.tile_settings[tile_id as usize]
};
let tile_setting = TileSetting::new(tile_id, false, false, palette_id);
map.set_tile(vram, (x, y).into(), stars_tileset, tile_setting);
}
@ -108,31 +84,10 @@ fn create_background_map(map: &mut RegularMap, vram: &mut VRamManager, stars_til
pub fn show_title_screen(background: &mut RegularMap, vram: &mut VRamManager, sfx: &mut Sfx) {
background.set_scroll_pos((0i16, 0).into());
vram.set_background_palettes(backgrounds::PALETTES);
let tile_set = TileSet::new(
backgrounds::title.tiles,
agb::display::tiled::TileFormat::FourBpp,
);
background.hide();
for x in 0..30u16 {
for y in 0..20u16 {
let tile_id = y * 30 + x;
background.set_tile(
vram,
(x, y).into(),
&tile_set,
TileSetting::new(
tile_id,
false,
false,
backgrounds::title.palette_assignments[tile_id as usize],
),
);
}
sfx.frame();
}
background.fill_with(vram, &backgrounds::title);
background.commit(vram);
sfx.frame();
background.show();
@ -152,9 +107,8 @@ impl<'a> StarBackground<'a> {
background2: &'a mut RegularMap,
vram: &'_ mut VRamManager,
) -> Self {
let stars_tileset = TileSet::new(backgrounds::stars.tiles, TileFormat::FourBpp);
create_background_map(background1, vram, &stars_tileset);
create_background_map(background2, vram, &stars_tileset);
create_background_map(background1, vram, &backgrounds::stars.tiles);
create_background_map(background2, vram, &backgrounds::stars.tiles);
Self {
background1,

View file

@ -52,7 +52,7 @@ dependencies = [
"image",
"proc-macro2",
"quote",
"syn 2.0.28",
"syn 2.0.32",
]
[[package]]
@ -61,7 +61,7 @@ version = "0.16.0"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.28",
"syn 2.0.32",
]
[[package]]
@ -71,7 +71,7 @@ dependencies = [
"hound",
"proc-macro2",
"quote",
"syn 2.0.28",
"syn 2.0.32",
]
[[package]]
@ -110,7 +110,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
"syn 2.0.28",
"syn 2.0.32",
"xmrs",
]
@ -159,9 +159,9 @@ checksum = "f8fe8f5a8a398345e52358e18ff07cc17a568fbca5c6f73873d3a62056309603"
[[package]]
name = "base64"
version = "0.21.2"
version = "0.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d"
checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2"
[[package]]
name = "bilge"
@ -183,7 +183,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
"syn 2.0.28",
"syn 2.0.32",
]
[[package]]
@ -209,9 +209,9 @@ checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
[[package]]
name = "bytemuck"
version = "1.13.1"
version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea"
checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6"
[[package]]
name = "byteorder"
@ -264,9 +264,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "flate2"
version = "1.0.26"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743"
checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010"
dependencies = [
"crc32fast",
"miniz_oxide 0.7.1",
@ -350,9 +350,9 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.147"
version = "0.2.148"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b"
[[package]]
name = "libflate"
@ -382,9 +382,9 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "memchr"
version = "2.5.0"
version = "2.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c"
[[package]]
name = "miniz_oxide"
@ -469,7 +469,7 @@ dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote",
"syn 2.0.28",
"syn 2.0.32",
]
[[package]]
@ -541,9 +541,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.32"
version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
"proc-macro2",
]
@ -592,9 +592,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "serde"
version = "1.0.183"
version = "1.0.188"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c"
checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e"
dependencies = [
"serde_derive",
]
@ -610,13 +610,13 @@ dependencies = [
[[package]]
name = "serde_derive"
version = "1.0.183"
version = "1.0.188"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816"
checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.28",
"syn 2.0.32",
]
[[package]]
@ -640,9 +640,9 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.28"
version = "2.0.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567"
checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2"
dependencies = [
"proc-macro2",
"quote",
@ -680,9 +680,9 @@ checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b"
[[package]]
name = "toml_edit"
version = "0.19.14"
version = "0.19.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a"
checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
dependencies = [
"indexmap",
"toml_datetime",
@ -697,9 +697,9 @@ checksum = "7b3e06c9b9d80ed6b745c7159c40b311ad2916abb34a49e9be2653b90db0d8dd"
[[package]]
name = "unicode-ident"
version = "1.0.11"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "version_check"
@ -715,18 +715,18 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "winnow"
version = "0.5.10"
version = "0.5.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5504cc7644f4b593cbc05c4a55bf9bd4e94b867c3c0bd440934174d50482427d"
checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc"
dependencies = [
"memchr",
]
[[package]]
name = "xml-rs"
version = "0.8.16"
version = "0.8.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47430998a7b5d499ccee752b41567bc3afc57e1327dc855b1a2aa44ce29b5fa1"
checksum = "bab77e97b50aee93da431f2cee7cd0f43b4d1da3c408042f2d7d164187774f0a"
[[package]]
name = "xmrs"

View file

@ -407,12 +407,10 @@ fn export_tiles(map: &tiled::Map, background: TokenStream) -> TokenStream {
tile_tileset_x * 2 + x_offset + tile_tileset_y * 9 * 4 + y_offset * 9 * 2;
let gba_tile_id = gba_tile_id as u16;
let palette_id =
quote! { backgrounds::#background.palette_assignments[#gba_tile_id as usize] };
quote! { TileSetting::new(#gba_tile_id, #hflip, #vflip, #palette_id) }
quote! { backgrounds::#background.tile_settings[#gba_tile_id as usize].hflip(#hflip).vflip(#vflip) }
}
None => {
quote! { TileSetting::new(1023, false, false, 0) }
quote! { TileSetting::BLANK }
}
}
});
@ -437,12 +435,11 @@ fn export_ui_tiles(map: &tiled::Map, background: TokenStream) -> TokenStream {
let tile_id = tile.id() as u16;
let vflip = tile.flip_v;
let hflip = tile.flip_h;
let palette_id =
quote! { backgrounds::#background.palette_assignments[#tile_id as usize] };
quote! { TileSetting::new(#tile_id, #hflip, #vflip, #palette_id) }
quote! { backgrounds::#background.tile_settings[#tile_id as usize].hflip(#hflip).vflip(#vflip) }
}
None => {
quote! { TileSetting::new(1023, false, false, 0) }
quote! { TileSetting::BLANK }
}
}
});

View file

@ -1,12 +1,12 @@
use agb::{
display::tiled::{RegularMap, TileFormat, TileSet, TileSetting, VRamManager},
display::tiled::{RegularMap, VRamManager},
include_background_gfx,
};
include_background_gfx!(backgrounds, "1e151b",
ui => "maps/ui_tiles.png",
level => "maps/level.png",
ending => "gfx/ending_page.aseprite",
ui => deduplicate "maps/ui_tiles.png",
level => deduplicate "maps/level.png",
ending => deduplicate "gfx/ending_page.aseprite",
);
mod tilemaps {
@ -19,7 +19,7 @@ pub fn load_palettes(vram_manager: &mut VRamManager) {
}
pub fn load_ui(map: &mut RegularMap, vram_manager: &mut VRamManager) {
let ui_tileset = TileSet::new(backgrounds::ui.tiles, TileFormat::FourBpp);
let ui_tileset = backgrounds::ui.tiles;
for y in 0..20u16 {
for x in 0..30u16 {
@ -38,7 +38,7 @@ pub fn load_level_background(
) {
let level_map = &tilemaps::LEVELS_MAP[level_number];
let level_tileset = TileSet::new(backgrounds::level.tiles, TileFormat::FourBpp);
let level_tileset = backgrounds::level.tiles;
for y in 0..20u16 {
for x in 0..22u16 {
@ -51,18 +51,5 @@ pub fn load_level_background(
}
pub fn load_ending_page(map: &mut RegularMap, vram_manager: &mut VRamManager) {
let ending_tileset = TileSet::new(backgrounds::ending.tiles, TileFormat::FourBpp);
for y in 0..20u16 {
for x in 0..30u16 {
let tile_pos = y * 30 + x;
let tile_setting = TileSetting::new(
tile_pos,
false,
false,
backgrounds::ending.palette_assignments[tile_pos as usize],
);
map.set_tile(vram_manager, (x, y).into(), &ending_tileset, tile_setting);
}
}
map.fill_with(vram_manager, &backgrounds::ending);
}

View file

@ -109,7 +109,7 @@ pub fn entry(mut gba: agb::Gba) -> ! {
let _ = save::save_max_level(&mut gba.save, 0);
}
let mut mixer = gba.mixer.mixer(Frequency::Hz18157);
let mut mixer = gba.mixer.mixer(Frequency::Hz32768);
let sfx = Sfx::new(&mut mixer);
let mut g = Agb {

View file

@ -1,4 +1,5 @@
use agb::{
fixnum::num,
include_wav,
sound::mixer::{Mixer, SoundChannel},
};
@ -37,38 +38,38 @@ impl<'a> Sfx<'a> {
}
pub fn bad_selection(&mut self) {
self.mixer.play_sound(SoundChannel::new(BAD_SELECTION));
self.play_effect(BAD_SELECTION);
}
pub fn select(&mut self) {
self.mixer.play_sound(SoundChannel::new(SELECT));
self.play_effect(SELECT);
}
pub fn place(&mut self) {
self.mixer.play_sound(SoundChannel::new(PLACE));
self.play_effect(PLACE);
}
pub fn play_sound_effect(&mut self, effect: Option<SoundEffect>) {
if let Some(effect) = effect {
match effect {
SoundEffect::WallHit => {
self.mixer.play_sound(SoundChannel::new(WALL_HIT));
self.play_effect(WALL_HIT);
}
SoundEffect::SlimeDie => {
self.mixer.play_sound(SoundChannel::new(SLIME_DEATH));
self.play_effect(SLIME_DEATH);
}
SoundEffect::HeroDie => {}
SoundEffect::SquidDie => {}
SoundEffect::SwordPickup => {
self.mixer.play_sound(SoundChannel::new(SWORD_PICKUP));
self.play_effect(SWORD_PICKUP);
}
SoundEffect::SwordKill => {}
SoundEffect::KeyPickup => {}
SoundEffect::DoorOpen => {
self.mixer.play_sound(SoundChannel::new(DOOR_OPEN));
self.play_effect(DOOR_OPEN);
}
SoundEffect::SwitchToggle => {
self.mixer.play_sound(SoundChannel::new(SWICTH_TOGGLES[0]));
self.play_effect(SWICTH_TOGGLES[0]);
}
SoundEffect::KeyDrop => {}
SoundEffect::SwordDrop => {}
@ -78,6 +79,12 @@ impl<'a> Sfx<'a> {
}
}
}
fn play_effect(&mut self, effect: &'static [u8]) {
let mut channel = SoundChannel::new(effect);
channel.playback(num!(0.5));
self.mixer.play_sound(channel);
}
}
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]

View file

@ -154,9 +154,9 @@ checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
[[package]]
name = "bytemuck"
version = "1.13.1"
version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea"
checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6"
[[package]]
name = "byteorder"
@ -203,9 +203,9 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
[[package]]
name = "flate2"
version = "1.0.26"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743"
checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010"
dependencies = [
"crc32fast",
"miniz_oxide 0.7.1",
@ -389,9 +389,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.32"
version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
"proc-macro2",
]
@ -410,18 +410,18 @@ checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
[[package]]
name = "serde"
version = "1.0.183"
version = "1.0.188"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c"
checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.183"
version = "1.0.188"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816"
checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2"
dependencies = [
"proc-macro2",
"quote",
@ -430,9 +430,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.104"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c"
checksum = "2cc66a619ed80bf7a0f6b17dd063a84b88f6dea1813737cf469aef1d081142c2"
dependencies = [
"itoa",
"ryu",
@ -441,9 +441,9 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.28"
version = "2.0.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567"
checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2"
dependencies = [
"proc-macro2",
"quote",
@ -467,9 +467,9 @@ checksum = "7b3e06c9b9d80ed6b745c7159c40b311ad2916abb34a49e9be2653b90db0d8dd"
[[package]]
name = "unicode-ident"
version = "1.0.11"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "version_check"

View file

@ -3,10 +3,10 @@ use agb::display::{
HEIGHT, WIDTH,
};
const LEVEL_START: u16 = 12 * 28;
const NUMBERS_START: u16 = 12 * 28 + 3;
const HYPHEN: u16 = 12 * 28 + 11;
pub const BLANK: u16 = 11 * 28;
const LEVEL_START: usize = 12 * 28;
const NUMBERS_START: usize = 12 * 28 + 3;
const HYPHEN: usize = 12 * 28 + 11;
pub const BLANK: usize = 11 * 28;
pub fn write_level(
map: &mut RegularMap,
@ -14,25 +14,21 @@ pub fn write_level(
level: u32,
tileset: &'_ TileSet<'_>,
vram: &mut VRamManager,
tile_settings: &[TileSetting],
) {
for (i, &tile) in [
LEVEL_START,
LEVEL_START + 1,
LEVEL_START + 2,
BLANK,
world as u16 + NUMBERS_START - 1,
world as usize + NUMBERS_START - 1,
HYPHEN,
level as u16 + NUMBERS_START - 1,
level as usize + NUMBERS_START - 1,
]
.iter()
.enumerate()
{
map.set_tile(
vram,
(i as u16, 0).into(),
tileset,
TileSetting::from_raw(tile),
);
map.set_tile(vram, (i as u16, 0).into(), tileset, tile_settings[tile]);
}
map.set_scroll_pos((-(WIDTH / 2 - 7 * 8 / 2) as i16, -(HEIGHT / 2 - 4) as i16).into());

View file

@ -10,8 +10,8 @@ use agb::{
display::{
object::{Graphics, OamManaged, Object, Tag, TagMap},
tiled::{
InfiniteScrolledMap, PartialUpdateStatus, RegularBackgroundSize, TileFormat, TileSet,
TileSetting, TiledMap, VRamManager,
InfiniteScrolledMap, PartialUpdateStatus, RegularBackgroundSize, TileFormat, TiledMap,
VRamManager,
},
Priority, HEIGHT, WIDTH,
},
@ -101,7 +101,7 @@ mod map_tiles {
}
}
agb::include_background_gfx!(tile_sheet, "2ce8f4", background => "gfx/tile_sheet.png");
agb::include_background_gfx!(tile_sheet, "2ce8f4", background => deduplicate "gfx/tile_sheet.png");
const GRAPHICS: &Graphics = agb::include_aseprite!("gfx/sprites.aseprite");
const TAG_MAP: &TagMap = GRAPHICS.tags();
@ -793,7 +793,7 @@ pub fn main(mut agb: agb::Gba) -> ! {
TileFormat::FourBpp,
);
let tileset = TileSet::new(tile_sheet::background.tiles, TileFormat::FourBpp);
let tileset = tile_sheet::background.tiles;
for y in 0..32u16 {
for x in 0..32u16 {
@ -801,7 +801,7 @@ pub fn main(mut agb: agb::Gba) -> ! {
&mut vram,
(x, y).into(),
&tileset,
TileSetting::from_raw(level_display::BLANK),
tile_sheet::background.tile_settings[level_display::BLANK],
);
}
}
@ -846,6 +846,7 @@ pub fn main(mut agb: agb::Gba) -> ! {
current_level % 8 + 1,
&tileset,
&mut vram,
tile_sheet::background.tile_settings,
);
world_display.commit(&mut vram);
@ -865,12 +866,11 @@ pub fn main(mut agb: agb::Gba) -> ! {
let level = &map_tiles::LEVELS[map_current_level as usize];
(
&tileset,
TileSetting::from_raw(
*level
.background
.get((pos.y * level.dimensions.x as i32 + pos.x) as usize)
.unwrap_or(&0),
),
tile_sheet::background.tile_settings[*level
.background
.get((pos.y * level.dimensions.x as i32 + pos.x) as usize)
.unwrap_or(&0)
as usize],
)
}),
);
@ -884,12 +884,11 @@ pub fn main(mut agb: agb::Gba) -> ! {
let level = &map_tiles::LEVELS[map_current_level as usize];
(
&tileset,
TileSetting::from_raw(
*level
.foreground
.get((pos.y * level.dimensions.x as i32 + pos.x) as usize)
.unwrap_or(&0),
),
tile_sheet::background.tile_settings[*level
.foreground
.get((pos.y * level.dimensions.x as i32 + pos.x) as usize)
.unwrap_or(&0)
as usize],
)
}),
);

View file

@ -1,9 +1,9 @@
use super::sfx::SfxPlayer;
use agb::display::tiled::{RegularMap, TileFormat, TileSet, TileSetting, TiledMap, VRamManager};
use agb::display::tiled::{RegularMap, TiledMap, VRamManager};
agb::include_background_gfx!(splash_screens,
splash => "gfx/splash.png",
thanks_for_playing => "gfx/thanks_for_playing.png",
splash => deduplicate "gfx/splash.png",
thanks_for_playing => deduplicate "gfx/thanks_for_playing.png",
);
pub enum SplashScreen {
@ -18,13 +18,9 @@ pub fn show_splash_screen(
vram: &mut VRamManager,
) {
map.set_scroll_pos((0i16, 0i16).into());
let tileset = match which {
SplashScreen::Start => TileSet::new(splash_screens::splash.tiles, TileFormat::FourBpp),
SplashScreen::End => TileSet::new(
splash_screens::thanks_for_playing.tiles,
TileFormat::FourBpp,
),
let tile_data = match which {
SplashScreen::Start => splash_screens::splash,
SplashScreen::End => splash_screens::thanks_for_playing,
};
let vblank = agb::interrupt::VBlank::get();
@ -34,19 +30,7 @@ pub fn show_splash_screen(
sfx.frame();
vblank.wait_for_vblank();
for y in 0..20u16 {
for x in 0..30u16 {
map.set_tile(
vram,
(x, y).into(),
&tileset,
TileSetting::from_raw(y * 30 + x),
);
}
sfx.frame();
vblank.wait_for_vblank();
}
map.fill_with(vram, &tile_data);
map.commit(vram);
vram.set_background_palettes(splash_screens::PALETTES);

View file

@ -163,9 +163,9 @@ checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
[[package]]
name = "bytemuck"
version = "1.13.1"
version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea"
checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6"
[[package]]
name = "byteorder"
@ -212,9 +212,9 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
[[package]]
name = "flate2"
version = "1.0.26"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743"
checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010"
dependencies = [
"crc32fast",
"miniz_oxide 0.7.1",
@ -413,9 +413,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.32"
version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
"proc-macro2",
]
@ -434,9 +434,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "syn"
version = "2.0.28"
version = "2.0.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567"
checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2"
dependencies = [
"proc-macro2",
"quote",
@ -478,9 +478,9 @@ checksum = "7b3e06c9b9d80ed6b745c7159c40b311ad2916abb34a49e9be2653b90db0d8dd"
[[package]]
name = "unicode-ident"
version = "1.0.11"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "version_check"
@ -490,6 +490,6 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "xml-rs"
version = "0.8.16"
version = "0.8.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47430998a7b5d499ccee752b41567bc3afc57e1327dc855b1a2aa44ce29b5fa1"
checksum = "bab77e97b50aee93da431f2cee7cd0f43b4d1da3c408042f2d7d164187774f0a"

View file

@ -15,10 +15,7 @@ use alloc::{boxed::Box, vec::Vec};
use agb::{
display::{
object::{Graphics, OamManaged, Object, Sprite, Tag, TagMap},
tiled::{
InfiniteScrolledMap, RegularBackgroundSize, TileFormat, TileSet, TileSetting,
VRamManager,
},
tiled::{InfiniteScrolledMap, RegularBackgroundSize, TileFormat, VRamManager},
Priority, HEIGHT, WIDTH,
},
fixnum::{num, FixedNum, Rect, Vector2D},
@ -57,7 +54,7 @@ const SWORDLESS_JUMP: &Tag = TAG_MAP.get("jump swordless");
const SWORDLESS_ATTACK: &Tag = KNIFE_ATTACK;
const SWORDLESS_JUMP_ATTACK: &Tag = KNIFE_JUMP_ATTACK;
agb::include_background_gfx!(background, "53269a", background => "gfx/background.aseprite");
agb::include_background_gfx!(background, "53269a", background => deduplicate "gfx/background.aseprite");
type Number = FixedNum<8>;
@ -2194,7 +2191,7 @@ fn game_with_level(gba: &mut agb::Gba) {
let (background, mut vram) = gba.display.video.tiled0();
vram.set_background_palettes(background::PALETTES);
let tileset = TileSet::new(background::background.tiles, TileFormat::FourBpp);
let tileset = background::background.tiles;
let object = gba.display.object.get_managed();
loop {
@ -2207,11 +2204,10 @@ fn game_with_level(gba: &mut agb::Gba) {
Box::new(|pos| {
(
&tileset,
TileSetting::from_raw(
*tilemap::BACKGROUND_MAP
.get((pos.x + tilemap::WIDTH * pos.y) as usize)
.unwrap_or(&0),
),
background::background.tile_settings[*tilemap::BACKGROUND_MAP
.get((pos.x + tilemap::WIDTH * pos.y) as usize)
.unwrap_or(&0)
as usize],
)
}),
);
@ -2225,11 +2221,10 @@ fn game_with_level(gba: &mut agb::Gba) {
Box::new(|pos| {
(
&tileset,
TileSetting::from_raw(
*tilemap::FOREGROUND_MAP
.get((pos.x + tilemap::WIDTH * pos.y) as usize)
.unwrap_or(&0),
),
background::background.tile_settings[*tilemap::FOREGROUND_MAP
.get((pos.x + tilemap::WIDTH * pos.y) as usize)
.unwrap_or(&0)
as usize],
)
}),
);
@ -2243,11 +2238,10 @@ fn game_with_level(gba: &mut agb::Gba) {
Box::new(|pos| {
(
&tileset,
TileSetting::from_raw(
*tilemap::CLOUD_MAP
.get((pos.x + tilemap::WIDTH * pos.y) as usize)
.unwrap_or(&0),
),
background::background.tile_settings[*tilemap::CLOUD_MAP
.get((pos.x + tilemap::WIDTH * pos.y) as usize)
.unwrap_or(&0)
as usize],
)
}),
);

224
tools/Cargo.lock generated
View file

@ -19,24 +19,23 @@ dependencies = [
[[package]]
name = "anstream"
version = "0.3.2"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163"
checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is-terminal",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.1"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd"
checksum = "b84bf0a05bbb2a83e5eb6fa36bb6e87baa08193c35ff52bbf6b38d8af2890e46"
[[package]]
name = "anstyle-parse"
@ -58,9 +57,9 @@ dependencies = [
[[package]]
name = "anstyle-wincon"
version = "1.0.2"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c677ab05e09154296dd37acecd46420c17b9713e8366facafa8fc0885167cf4c"
checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd"
dependencies = [
"anstyle",
"windows-sys",
@ -72,12 +71,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bitflags"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
[[package]]
name = "bumpalo"
version = "3.13.0"
@ -86,9 +79,9 @@ checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1"
[[package]]
name = "cc"
version = "1.0.82"
version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "305fe645edc1442a0fa8b6726ba61d422798d37a52e12eaecf4b022ebbb88f01"
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
dependencies = [
"libc",
]
@ -101,33 +94,32 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.26"
version = "0.4.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5"
checksum = "defd4e7873dbddba6c7c91e199c7fcb946abc4a6a4ac3195400bcfb01b5de877"
dependencies = [
"android-tzdata",
"iana-time-zone",
"js-sys",
"num-traits",
"time",
"wasm-bindgen",
"winapi",
"windows-targets",
]
[[package]]
name = "clap"
version = "4.3.21"
version = "4.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c27cdf28c0f604ba3f512b0c9a409f8de8513e4816705deb0498b627e7c3a3fd"
checksum = "84ed82781cea27b43c9b106a979fe450a13a31aab0500595fb3fc06616de08e6"
dependencies = [
"clap_builder",
]
[[package]]
name = "clap_builder"
version = "4.3.21"
version = "4.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08a9f1ab5e9f01a9b81f202e8562eb9a10de70abf9eaeac1be465c28b75aa4aa"
checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08"
dependencies = [
"anstream",
"anstyle",
@ -137,9 +129,9 @@ dependencies = [
[[package]]
name = "clap_lex"
version = "0.5.0"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b"
checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961"
[[package]]
name = "colorchoice"
@ -168,27 +160,6 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "errno"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f"
dependencies = [
"errno-dragonfly",
"libc",
"windows-sys",
]
[[package]]
name = "errno-dragonfly"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
dependencies = [
"cc",
"libc",
]
[[package]]
name = "fixedbitset"
version = "0.4.2"
@ -201,24 +172,12 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]]
name = "hashbrown"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "hashbrown"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
[[package]]
name = "hermit-abi"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b"
[[package]]
name = "iana-time-zone"
version = "0.1.57"
@ -242,16 +201,6 @@ dependencies = [
"cc",
]
[[package]]
name = "indexmap"
version = "1.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
dependencies = [
"autocfg",
"hashbrown 0.12.3",
]
[[package]]
name = "indexmap"
version = "2.0.0"
@ -259,18 +208,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d"
dependencies = [
"equivalent",
"hashbrown 0.14.0",
]
[[package]]
name = "is-terminal"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
dependencies = [
"hermit-abi",
"rustix",
"windows-sys",
"hashbrown",
]
[[package]]
@ -284,15 +222,9 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.147"
version = "0.2.148"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
[[package]]
name = "linux-raw-sys"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503"
checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b"
[[package]]
name = "log"
@ -302,9 +234,9 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "memchr"
version = "2.5.0"
version = "2.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c"
[[package]]
name = "num-traits"
@ -323,12 +255,12 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
[[package]]
name = "petgraph"
version = "0.6.3"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4"
checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9"
dependencies = [
"fixedbitset",
"indexmap 1.9.3",
"indexmap",
]
[[package]]
@ -342,26 +274,13 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.32"
version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rustix"
version = "0.38.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19ed4fa021d81c8392ce04db050a3da9a60299050b7ae1cf482d862b54a7218f"
dependencies = [
"bitflags",
"errno",
"libc",
"linux-raw-sys",
"windows-sys",
]
[[package]]
name = "strsim"
version = "0.10.0"
@ -370,26 +289,15 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "syn"
version = "2.0.28"
version = "2.0.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567"
checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "time"
version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a"
dependencies = [
"libc",
"wasi",
"winapi",
]
[[package]]
name = "toml_datetime"
version = "0.6.3"
@ -398,11 +306,11 @@ checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b"
[[package]]
name = "toml_edit"
version = "0.19.14"
version = "0.19.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a"
checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
dependencies = [
"indexmap 2.0.0",
"indexmap",
"toml_datetime",
"winnow",
]
@ -420,9 +328,9 @@ dependencies = [
[[package]]
name = "unicode-ident"
version = "1.0.11"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "utf8parse"
@ -430,12 +338,6 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]]
name = "wasi"
version = "0.10.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
[[package]]
name = "wasm-bindgen"
version = "0.2.87"
@ -490,28 +392,6 @@ version = "0.2.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1"
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows"
version = "0.48.0"
@ -532,9 +412,9 @@ dependencies = [
[[package]]
name = "windows-targets"
version = "0.48.1"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f"
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
@ -547,51 +427,51 @@ dependencies = [
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_i686_gnu"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_msvc"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]]
name = "winnow"
version = "0.5.10"
version = "0.5.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5504cc7644f4b593cbc05c4a55bf9bd4e94b867c3c0bd440934174d50482427d"
checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc"
dependencies = [
"memchr",
]

View file

@ -12,7 +12,7 @@ const DB_TOFFE: Track = include_xm!("examples/db_toffe.xm");
fn main(mut gba: Gba) -> ! {
let vblank_provider = agb::interrupt::VBlank::get();
let mut mixer = gba.mixer.mixer(Frequency::Hz18157);
let mut mixer = gba.mixer.mixer(Frequency::Hz32768);
mixer.enable();
let mut tracker = Tracker::new(&DB_TOFFE);

View file

@ -18,7 +18,7 @@ fn main(mut gba: Gba) -> ! {
timer.set_enabled(true);
timer2.set_cascade(true).set_enabled(true);
let mut mixer = gba.mixer.mixer(Frequency::Hz18157);
let mut mixer = gba.mixer.mixer(Frequency::Hz32768);
mixer.enable();
let mut tracker = Tracker::new(&DB_TOFFE);

View file

@ -35,7 +35,7 @@
//! fn main(mut gba: Gba) -> ! {
//! let vblank_provider = agb::interrupt::VBlank::get();
//!
//! let mut mixer = gba.mixer.mixer(Frequency::Hz18157);
//! let mut mixer = gba.mixer.mixer(Frequency::Hz32768);
//! mixer.enable();
//!
//! let mut tracker = Tracker::new(&DB_TOFFE);
@ -49,7 +49,7 @@
//! }
//! ```
//!
//! Note that currently you have to select 18157Hz as the frequency for the mixer.
//! Note that currently you have to select 32768Hz as the frequency for the mixer.
//! This restriction will be lifted in a future version.
//!
//! # Concepts

View file

@ -475,7 +475,7 @@ fn note_to_speed(
FrequencyType::AmigaFrequencies => note_to_frequency_amega(note, fine_tune, relative_note),
};
let gba_audio_frequency = 18157f64;
let gba_audio_frequency = 32768f64;
let speed = frequency / gba_audio_frequency;
Num::from_f64(speed)