diff --git a/CHANGELOG.md b/CHANGELOG.md index 558f9674..09775179 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ # Changelog + All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), @@ -7,22 +8,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added + - New `include_palette` macro for including every colour in an image as a `u16` slice. - New object based text renderer. ### Changed + - Changed the default template game. - `DynamicSprite` has a new API which changes the constructor and adds a `set_pixel` and `clear` methods. - You no longer need to install arm-none-eabi-binutils. In order to write games using `agb`, you now only need to install rust nightly. - 10% performance improvement with the software mixer. +### Fixed + +- Compile error if you tried to import a larger sprite which uses more than 15 colours between frames. + ## [0.15.0] - 2023/04/25 ### Added + - You can now import aseprite files directly (in addition to the already supported png and bmp files) when importing background tiles. - New additional unmanaged object API for interacting with a more straightforward manner with the underlying hardware. ### Changed + - Importing background tiles has been improved. You no longer need to use `include_gfx!` with the toml file. Instead, use `include_background_gfx`. See the documentation for usage. - The hashmap implementation is now it its own crate, `agb-hashmap`. There is no change in API, but you can now use this for interop between non-agb code and agb code. - Moved the existing object API to be the OamManaged API. The old names persist with deprecated notices on them. @@ -30,9 +39,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.14.0] - 2023/04/11 ### Added + - Added custom `gbafix` implementation which can take the elf file produced by `cargo build` directly, removing the need for the objcopy step. ### Changed + - Made Vector2D::new a const function. - The template now uses rust 2021 edition by default. - All objects which should only be created once now have the correct lifetimes to only allow one to exist. @@ -41,6 +52,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Soundness issues with interrupts resolved which makes them unsafe and require the closure to be static (breaking change). ### Fixed + - Alpha channel is now considered by `include_gfx!()` even when `transparent_colour` is absent. - 256 colour backgrounds are now correctly rendered (breaking change). - The `#[agb::entry]` macro now reports errors better. @@ -49,14 +61,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.13.0] - 2023/01/19 ### Added + - Added missed implementations of `regular()` and `affine()` to `Tiled1` which made `Tiled1` impossible to use. ### Changed + - Text renderer can now be re-used which is useful for rpg style character/word at a time text boxes. - Audio now automatically uses interrupts, so you can remove the `setup_interrupt_handler` or `after_vblank` calls to the mixer. - If a vblank happens outside of `wait_for_vblank`, then next call will immediately return. ### Fixed + - Zero volume now plays no sound. - Fixed issue where volume was incorrect for volumes which were powers of 2. @@ -65,6 +80,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 This is a minor release to fix an alignment issue with background tiles. ### Fixed + - Corrected alignment of background tiles which was causing issues with rendering tiles in some cases. ## [0.12.1] - 2022/10/12 @@ -72,6 +88,7 @@ This is a minor release to fix an alignment issue with background tiles. This is a minor release to fix the build of the docs on [docs.rs/agb](https://docs.rs/agb). ### Fixed + - Fixed the agb crate's docs.rs build ## [0.12.0] - 2022/10/11 @@ -84,6 +101,7 @@ This version of `agb` has some exciting new features we'd like to highlight and We also had a contribution by @ijc8. We can't thank you all enough! ### Added + - Custom allocator support using the `Allocator` trait for `HashMap`. This means the `HashMap` can be used with `InternalAllocator` to allocate to IWRAM or the `ExternalAllocator` to explicitly allocate to EWRAM. - Support for using windows on the GBA. Windows are used to selectively enable rendering of certain layers or effects. - Support for the blend mode of the GBA. Blending allows for alpha blending between layers and fading to black and white. @@ -96,6 +114,7 @@ We also had a contribution by @ijc8. We can't thank you all enough! - Added support for dynamic sprites generated at runtime, some parts of this may change significantly so breaking changes are expected here. ### Changed + - Many of the places that originally disabled IRQs now use the `sync` module, reducing the chance of missed interrupts. - HashMap iterators now implement `size_hint` which should result in slightly better generation of code using those iterators. - Transparency of backgrounds is now set once in the toml file rather than once for every image. @@ -104,6 +123,7 @@ We also had a contribution by @ijc8. We can't thank you all enough! - `testing` is now a default feature, so you no longer need to add a separate `dev-dependencies` line for `agb` in order to enable unit tests for your project. ### Fixed + - Fixed the fast magnitude function in agb_fixnum. This is also used in fast_normalise. Previously only worked for positive (x, y). - Fixed formatting of fixed point numbers in the range (-1, 0), which previously appeared positive. @@ -112,14 +132,17 @@ We also had a contribution by @ijc8. We can't thank you all enough! Version 0.11.1 brings documentation for fixed point numbers. We recommend all users upgrade to this version since it also includes fixes to a few functions in fixnum. See changed section for breaking changes. ### Added + - Support for sprites that are not square. - Docs for fixed point numbers. ### Changed + - `Rect::contains_point` now considers points on the boundary to be part of the rectangle. - Signature of `Rect::overlapping_rect` changed to return an Option. Returns None if rectangles don't overlap. ### Fixed + - Fixed point sine calculates the sine correctly. ## [0.10.0] - 2022/07/31 @@ -127,6 +150,7 @@ Version 0.11.1 brings documentation for fixed point numbers. We recommend all us Version 0.10.0 brings about many new features. As with most `agb` upgrades, you will need to update your `gba.ld` and `gba_mb.ld` files which you can find in the [template repo](https://github.com/agbrs/template). We would also recommend copying the `[profile.dev]` and `[profile.release]` sections from `Cargo.toml` if you don't have these values already. ### Added + - [Hyperspace roll](https://lostimmortal.itch.io/hyperspace-roll), a new game built for the GMTK Game Jam 2022 using `agb`. The source code can be found in the `examples` directory. - Started using GitHub discussions as a forum - Many functions previously undocumented are now documented @@ -143,6 +167,7 @@ Version 0.10.0 brings about many new features. As with most `agb` upgrades, you - Random number generator in agb::rng ### Changed + - Audio system optimisations - reduced CPU usage by more than 50% - Background tiles are now removed from Video RAM during `commit()` if they are no longer used rather than immediately reducing flickering - Improved the README for both the main agb crate and the template @@ -152,9 +177,11 @@ Version 0.10.0 brings about many new features. As with most `agb` upgrades, you - A few methods accepting `Num<..>` have been changed to accept `impl Into>` to make them easier to use ### Removed + - The ability to use timer0 and timer1 through the `timer` module. This was done in order to fully support 32kHz audio ### Fixed + - Sprite data is now correctly aligned so fast copies will always work - A few methods which should really be internal have had `pub` removed - The crate now compiles (but does not run) doctests in CI which pointed out a large number of non-compiling examples diff --git a/agb-image-converter/src/lib.rs b/agb-image-converter/src/lib.rs index 26c9a582..6e227d1d 100644 --- a/agb-image-converter/src/lib.rs +++ b/agb-image-converter/src/lib.rs @@ -183,6 +183,7 @@ fn include_gfx_from_config( &mut optimiser, &image, tile_size, + tile_size, config.transparent_colour(), ); @@ -305,7 +306,13 @@ pub fn include_aseprite_inner(input: TokenStream) -> TokenStream { ); let image = Image::load_from_dyn_image(frame); - add_to_optimiser(&mut optimiser, &image, 8, Some(transparent_colour)); + add_to_optimiser( + &mut optimiser, + &image, + width as usize, + height as usize, + Some(transparent_colour), + ); images.push(image); } } @@ -413,19 +420,20 @@ fn convert_image( fn add_to_optimiser( palette_optimiser: &mut palette16::Palette16Optimiser, image: &Image, - tile_size: usize, + tile_width: usize, + tile_height: usize, transparent_colour: Option, ) { - let tiles_x = image.width / tile_size; - let tiles_y = image.height / tile_size; + let tiles_x = image.width / tile_width; + let tiles_y = image.height / tile_height; for y in 0..tiles_y { for x in 0..tiles_x { let mut palette = palette16::Palette16::new(); - for j in 0..tile_size { - for i in 0..tile_size { - let colour = image.colour(x * tile_size + i, y * tile_size + j); + for j in 0..tile_height { + for i in 0..tile_width { + let colour = image.colour(x * tile_width + i, y * tile_height + j); palette.add_colour(match (colour.is_transparent(), transparent_colour) { (true, Some(transparent_colour)) => transparent_colour, @@ -460,7 +468,7 @@ 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) + add_image_to_tile_data(&mut tile_data, image, optimiser, image_idx, true) } let tile_data = collapse_to_4bpp(&tile_data); @@ -482,6 +490,7 @@ fn add_image_to_tile_data( image: &Image, optimiser: &Palette16OptimisationResults, assignment_offset: usize, + is_sprite: bool, ) { let tile_size = 8; let tiles_x = image.width / tile_size; @@ -489,7 +498,13 @@ fn add_image_to_tile_data( for y in 0..tiles_y { for x in 0..tiles_x { - let palette_index = optimiser.assignments[y * tiles_x + x + assignment_offset]; + let assignment = if is_sprite { + assignment_offset + } else { + y * tiles_x + x + assignment_offset + }; + + let palette_index = optimiser.assignments[assignment]; let palette = &optimiser.optimised_palettes[palette_index]; for inner_y in 0..tile_size / 8 { diff --git a/agb-image-converter/src/rust_generator.rs b/agb-image-converter/src/rust_generator.rs index 49c55001..9a7de049 100644 --- a/agb-image-converter/src/rust_generator.rs +++ b/agb-image-converter/src/rust_generator.rs @@ -47,7 +47,7 @@ pub(crate) fn generate_code( 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); + add_image_to_tile_data(&mut tile_data, image, results, assignment_offset, false); let tile_data = collapse_to_4bpp(&tile_data);