mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
Use static rather than const (#529)
This commit is contained in:
commit
9cbddfec80
|
@ -15,6 +15,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
- Export the `dma` module correctly so you can write the types from it and use it in more complex cases.
|
||||
|
||||
### Changed
|
||||
|
||||
- Many macros now emit statics rather than consts OR can be used as statics OR
|
||||
have had examples changed to use statics. You should use statics where possble
|
||||
for assets as consts can lead to them being included multiple times in the
|
||||
ROM.
|
||||
|
||||
## [0.19.1] - 2024/03/06
|
||||
|
||||
### Added
|
||||
|
|
|
@ -414,15 +414,15 @@ pub fn include_aseprite_inner(input: TokenStream) -> TokenStream {
|
|||
#(#include_paths)*
|
||||
|
||||
|
||||
const PALETTES: &[Palette16] = &[
|
||||
static PALETTES: &[Palette16] = &[
|
||||
#(#palette_data),*
|
||||
];
|
||||
|
||||
pub const SPRITES: &[Sprite] = &[
|
||||
static SPRITES: &[Sprite] = &[
|
||||
#(#sprites),*
|
||||
];
|
||||
|
||||
const TAGS: &TagMap = &TagMap::new(
|
||||
static TAGS: TagMap = TagMap::new(
|
||||
&[
|
||||
#(#tags),*
|
||||
]
|
||||
|
|
|
@ -31,7 +31,7 @@ pub(crate) fn generate_palette_code(
|
|||
});
|
||||
|
||||
quote! {
|
||||
pub const PALETTES: &[#crate_prefix::display::palette16::Palette16] = &[#(#palettes),*];
|
||||
pub static PALETTES: &[#crate_prefix::display::palette16::Palette16] = &[#(#palettes),*];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ pub(crate) fn generate_code(
|
|||
|
||||
quote! {
|
||||
#[allow(non_upper_case_globals)]
|
||||
pub const #output_variable_name: #crate_prefix::display::tile_data::TileData = {
|
||||
pub static #output_variable_name: #crate_prefix::display::tile_data::TileData = {
|
||||
const _: &[u8] = include_bytes!(#image_filename);
|
||||
|
||||
const TILE_DATA: &[u8] = {
|
||||
|
|
|
@ -18,7 +18,7 @@ fn main(mut gba: agb::Gba) -> ! {
|
|||
let (gfx, mut vram) = gba.display.video.tiled1();
|
||||
let vblank = agb::interrupt::VBlank::get();
|
||||
|
||||
let tileset = affine_tiles::water_tiles.tiles;
|
||||
let tileset = &affine_tiles::water_tiles.tiles;
|
||||
|
||||
vram.set_background_palettes(affine_tiles::PALETTES);
|
||||
|
||||
|
@ -26,7 +26,7 @@ fn main(mut gba: agb::Gba) -> ! {
|
|||
|
||||
for y in 0..32u16 {
|
||||
for x in 0..32u16 {
|
||||
bg.set_tile(&mut vram, (x, y), &tileset, 1);
|
||||
bg.set_tile(&mut vram, (x, y), tileset, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ fn main(mut gba: agb::Gba) -> ! {
|
|||
let (gfx, mut vram) = gba.display.video.tiled0();
|
||||
let vblank = agb::interrupt::VBlank::get();
|
||||
|
||||
let tileset = water_tiles::water_tiles.tiles;
|
||||
let tileset = &water_tiles::water_tiles.tiles;
|
||||
|
||||
vram.set_background_palettes(water_tiles::PALETTES);
|
||||
|
||||
|
@ -31,7 +31,7 @@ fn main(mut gba: agb::Gba) -> ! {
|
|||
bg.set_tile(
|
||||
&mut vram,
|
||||
(x, y),
|
||||
&tileset,
|
||||
tileset,
|
||||
water_tiles::water_tiles.tile_settings[0],
|
||||
);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ fn main(mut gba: agb::Gba) -> ! {
|
|||
loop {
|
||||
i = (i + 1) % 8;
|
||||
|
||||
vram.replace_tile(&tileset, 0, &tileset, i);
|
||||
vram.replace_tile(tileset, 0, tileset, i);
|
||||
|
||||
vblank.wait_for_vblank();
|
||||
}
|
||||
|
|
|
@ -14,9 +14,9 @@ use agb::{
|
|||
use core::fmt::Write;
|
||||
|
||||
// Music - "Crazy glue" by Josh Woodward, free download at http://joshwoodward.com
|
||||
const CRAZY_GLUE: &[u8] = include_wav!("examples/JoshWoodward-CrazyGlue.wav");
|
||||
static CRAZY_GLUE: &[u8] = include_wav!("examples/JoshWoodward-CrazyGlue.wav");
|
||||
|
||||
const FONT: Font = include_font!("examples/font/yoster.ttf", 12);
|
||||
static FONT: Font = include_font!("examples/font/yoster.ttf", 12);
|
||||
|
||||
#[agb::entry]
|
||||
fn main(mut gba: Gba) -> ! {
|
||||
|
|
|
@ -7,7 +7,7 @@ use agb::sound::mixer::{Frequency, SoundChannel};
|
|||
use agb::{fixnum::num, include_wav, Gba};
|
||||
|
||||
// Music - "Dead Code" by Josh Woodward, free download at http://joshwoodward.com
|
||||
const DEAD_CODE: &[u8] = include_wav!("examples/JoshWoodward-DeadCode.wav");
|
||||
static DEAD_CODE: &[u8] = include_wav!("examples/JoshWoodward-DeadCode.wav");
|
||||
|
||||
#[agb::entry]
|
||||
fn main(mut gba: Gba) -> ! {
|
||||
|
|
|
@ -11,14 +11,14 @@ use agb::fixnum::num;
|
|||
use agb_fixnum::Num;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
const GRAPHICS: &Graphics = agb::include_aseprite!(
|
||||
static GRAPHICS: &Graphics = agb::include_aseprite!(
|
||||
"examples/gfx/objects.aseprite",
|
||||
"examples/gfx/boss.aseprite",
|
||||
"examples/gfx/wide.aseprite",
|
||||
"examples/gfx/tall.aseprite"
|
||||
);
|
||||
const SPRITES: &[Sprite] = GRAPHICS.sprites();
|
||||
const TAG_MAP: &TagMap = GRAPHICS.tags();
|
||||
static SPRITES: &[Sprite] = GRAPHICS.sprites();
|
||||
static TAG_MAP: &TagMap = GRAPHICS.tags();
|
||||
|
||||
fn all_sprites(gfx: &OamManaged, rotation_speed: Num<i32, 16>) {
|
||||
let mut input = agb::input::ButtonController::new();
|
||||
|
|
|
@ -14,9 +14,9 @@ use agb::{
|
|||
use core::fmt::Write;
|
||||
|
||||
// Music - "Let it in" by Josh Woodward, free download at http://joshwoodward.com
|
||||
const LET_IT_IN: &[u8] = include_wav!("examples/JoshWoodward-LetItIn.wav");
|
||||
static LET_IT_IN: &[u8] = include_wav!("examples/JoshWoodward-LetItIn.wav");
|
||||
|
||||
const FONT: Font = include_font!("examples/font/yoster.ttf", 12);
|
||||
static FONT: Font = include_font!("examples/font/yoster.ttf", 12);
|
||||
|
||||
#[agb::entry]
|
||||
fn main(mut gba: Gba) -> ! {
|
||||
|
|
|
@ -127,7 +127,7 @@ fn is_private_use(c: char) -> bool {
|
|||
///
|
||||
/// use core::fmt::Write;
|
||||
///
|
||||
/// const EXAMPLE_FONT: Font = agb::include_font!("examples/font/yoster.ttf", 12);
|
||||
/// static EXAMPLE_FONT: Font = agb::include_font!("examples/font/yoster.ttf", 12);
|
||||
///
|
||||
/// # fn foo() {
|
||||
/// let mut palette = [0x0; 16];
|
||||
|
@ -214,7 +214,7 @@ impl BufferedRender<'_> {
|
|||
///
|
||||
/// use core::fmt::Write;
|
||||
///
|
||||
/// const EXAMPLE_FONT: Font = agb::include_font!("examples/font/yoster.ttf", 12);
|
||||
/// static EXAMPLE_FONT: Font = agb::include_font!("examples/font/yoster.ttf", 12);
|
||||
///
|
||||
/// #[agb::entry]
|
||||
/// fn main(gba: &mut agb::Gba) -> ! {
|
||||
|
|
|
@ -528,9 +528,9 @@ mod tests {
|
|||
|
||||
use super::*;
|
||||
|
||||
const TEST_SPRITES: &Graphics = include_aseprite!("examples/gfx/tall.aseprite");
|
||||
static TEST_SPRITES: &Graphics = include_aseprite!("examples/gfx/tall.aseprite");
|
||||
|
||||
const TEST_SPRITE: &Sprite = &TEST_SPRITES.sprites()[0];
|
||||
static TEST_SPRITE: &Sprite = &TEST_SPRITES.sprites()[0];
|
||||
|
||||
#[test_case]
|
||||
fn test_always_ordered(gba: &mut crate::Gba) {
|
||||
|
|
|
@ -82,7 +82,7 @@ macro_rules! align_bytes {
|
|||
/// # #![no_std]
|
||||
/// # #![no_main]
|
||||
/// # use agb::{display::object::Graphics, include_aseprite};
|
||||
/// const GRAPHICS: &Graphics = include_aseprite!(
|
||||
/// static GRAPHICS: &Graphics = include_aseprite!(
|
||||
/// "examples/gfx/boss.aseprite",
|
||||
/// "examples/gfx/objects.aseprite"
|
||||
/// );
|
||||
|
@ -112,7 +112,7 @@ macro_rules! include_aseprite {
|
|||
|
||||
$crate::include_aseprite_inner!($($aseprite_path),*);
|
||||
|
||||
&Graphics::new(SPRITES, TAGS)
|
||||
&Graphics::new(SPRITES, &TAGS)
|
||||
}};
|
||||
}
|
||||
|
||||
|
@ -151,12 +151,12 @@ impl Graphics {
|
|||
/// # #![no_std]
|
||||
/// # #![no_main]
|
||||
/// # use agb::{display::object::{Graphics, Tag}, include_aseprite};
|
||||
/// const GRAPHICS: &Graphics = include_aseprite!(
|
||||
/// static GRAPHICS: &Graphics = include_aseprite!(
|
||||
/// "examples/gfx/boss.aseprite",
|
||||
/// "examples/gfx/objects.aseprite"
|
||||
/// );
|
||||
///
|
||||
/// const EMU_WALK: &Tag = GRAPHICS.tags().get("emu-walk");
|
||||
/// static EMU_WALK: &Tag = GRAPHICS.tags().get("emu-walk");
|
||||
/// ```
|
||||
/// This being the whole animation associated with the walk sequence of the emu.
|
||||
/// See [Tag] for details on how to use this.
|
||||
|
@ -213,12 +213,12 @@ impl TagMap {
|
|||
/// # #![no_std]
|
||||
/// # #![no_main]
|
||||
/// # use agb::{display::object::{Graphics, Tag}, include_aseprite};
|
||||
/// const GRAPHICS: &Graphics = include_aseprite!(
|
||||
/// static GRAPHICS: &Graphics = include_aseprite!(
|
||||
/// "examples/gfx/boss.aseprite",
|
||||
/// "examples/gfx/objects.aseprite"
|
||||
/// );
|
||||
///
|
||||
/// const EMU_WALK: &Tag = GRAPHICS.tags().get("emu-walk");
|
||||
/// static EMU_WALK: &Tag = GRAPHICS.tags().get("emu-walk");
|
||||
/// ```
|
||||
///
|
||||
/// See [Tag] for more details.
|
||||
|
@ -262,6 +262,8 @@ pub struct Tag {
|
|||
direction: Direction,
|
||||
}
|
||||
|
||||
unsafe impl Sync for Tag {}
|
||||
|
||||
impl Tag {
|
||||
/// The individual sprites that make up the animation themselves.
|
||||
#[must_use]
|
||||
|
|
|
@ -398,12 +398,12 @@ mod tests {
|
|||
|
||||
#[test_case]
|
||||
fn object_usage(gba: &mut crate::Gba) {
|
||||
const GRAPHICS: &Graphics = include_aseprite!(
|
||||
static GRAPHICS: &Graphics = include_aseprite!(
|
||||
"../examples/the-purple-night/gfx/objects.aseprite",
|
||||
"../examples/the-purple-night/gfx/boss.aseprite"
|
||||
);
|
||||
|
||||
const BOSS: &Tag = GRAPHICS.tags().get("Boss");
|
||||
static BOSS: &Tag = GRAPHICS.tags().get("Boss");
|
||||
|
||||
let (mut gfx, mut loader) = gba.display.object.get_unmanaged();
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ use crate::{
|
|||
/// use agb::display::Priority;
|
||||
///
|
||||
/// mod tilemap {
|
||||
/// pub const BACKGROUND_MAP: &[usize] = &[ // Probably load this from a file
|
||||
/// pub static BACKGROUND_MAP: &[usize] = &[ // Probably load this from a file
|
||||
/// # 0, 1, 2];
|
||||
/// pub const WIDTH: i32 = // set it to some width
|
||||
/// # 12;
|
||||
|
@ -51,7 +51,7 @@ use crate::{
|
|||
/// # fn foo(mut gba: agb::Gba) {
|
||||
/// let (gfx, mut vram) = gba.display.video.tiled0();
|
||||
///
|
||||
/// let tile_data = water_tiles::tiles;
|
||||
/// let tile_data = &water_tiles::tiles;
|
||||
///
|
||||
/// let mut backdrop = InfiniteScrolledMap::new(
|
||||
/// gfx.background(Priority::P2, RegularBackgroundSize::Background32x32, TileFormat::FourBpp),
|
||||
|
@ -133,9 +133,9 @@ impl<'a> InfiniteScrolledMap<'a> {
|
|||
/// # use agb::display::Priority;
|
||||
/// #
|
||||
/// # mod tilemap {
|
||||
/// # pub const BACKGROUND_MAP: &[usize] = &[0, 1, 2];
|
||||
/// # pub static BACKGROUND_MAP: &[usize] = &[0, 1, 2];
|
||||
/// # pub const WIDTH: i32 = 12;
|
||||
/// # pub const MAP_TILES: &[u8] = &[0];
|
||||
/// # pub static MAP_TILES: &[u8] = &[0];
|
||||
/// # }
|
||||
/// #
|
||||
/// # agb::include_background_gfx!(water_tiles, tiles => "examples/water_tiles.png");
|
||||
|
@ -143,7 +143,7 @@ impl<'a> InfiniteScrolledMap<'a> {
|
|||
/// # fn foo(mut gba: agb::Gba) {
|
||||
/// # let (gfx, mut vram) = gba.display.video.tiled0();
|
||||
/// #
|
||||
/// # let tile_data = water_tiles::tiles;
|
||||
/// # let tile_data = &water_tiles::tiles;
|
||||
/// #
|
||||
/// # let mut backdrop = InfiniteScrolledMap::new(
|
||||
/// # gfx.background(Priority::P2, RegularBackgroundSize::Background32x32, TileFormat::FourBpp),
|
||||
|
@ -209,9 +209,9 @@ impl<'a> InfiniteScrolledMap<'a> {
|
|||
/// # use agb::display::Priority;
|
||||
/// #
|
||||
/// # mod tilemap {
|
||||
/// # pub const BACKGROUND_MAP: &[usize] = &[0, 1, 2];
|
||||
/// # pub static BACKGROUND_MAP: &[usize] = &[0, 1, 2];
|
||||
/// # pub const WIDTH: i32 = 12;
|
||||
/// # pub const MAP_TILES: &[u8] = &[0];
|
||||
/// # pub static MAP_TILES: &[u8] = &[0];
|
||||
/// # }
|
||||
/// #
|
||||
/// # agb::include_background_gfx!(water_tiles, tiles => "examples/water_tiles.png");
|
||||
|
@ -219,7 +219,7 @@ impl<'a> InfiniteScrolledMap<'a> {
|
|||
/// # fn foo(mut gba: agb::Gba) {
|
||||
/// # let (gfx, mut vram) = gba.display.video.tiled0();
|
||||
/// #
|
||||
/// # let tile_data = water_tiles::tiles;
|
||||
/// # let tile_data = &water_tiles::tiles;
|
||||
/// #
|
||||
/// # let mut backdrop = InfiniteScrolledMap::new(
|
||||
/// # gfx.background(Priority::P2, RegularBackgroundSize::Background32x32, TileFormat::FourBpp),
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
/// ```rust,ignore
|
||||
/// // module name comes from the first argument, name of the constant from the arrow
|
||||
/// mod water_tiles {
|
||||
/// pub const tiles = /* ... */;
|
||||
/// pub static tiles = /* ... */;
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
|
@ -77,7 +77,7 @@
|
|||
/// agb::include_background_gfx!(water_tiles, tiles => "examples/water_tiles.png");
|
||||
///
|
||||
/// # fn load_tileset(mut gfx: Tiled0, mut vram: VRamManager) {
|
||||
/// let tileset = water_tiles::tiles.tiles;
|
||||
/// let tileset = &water_tiles::tiles.tiles;
|
||||
///
|
||||
/// vram.set_background_palettes(water_tiles::PALETTES);
|
||||
///
|
||||
|
@ -88,7 +88,7 @@
|
|||
/// bg.set_tile(
|
||||
/// &mut vram,
|
||||
/// (x, y),
|
||||
/// &tileset,
|
||||
/// tileset,
|
||||
/// water_tiles::tiles.tile_settings[0],
|
||||
/// );
|
||||
/// }
|
||||
|
|
|
@ -12,7 +12,7 @@ use crate::{
|
|||
interrupt::VBlank,
|
||||
};
|
||||
|
||||
const PALETTE: &[u16] = &include_palette!("gfx/pastel.png");
|
||||
static PALETTE: &[u16] = &include_palette!("gfx/pastel.png");
|
||||
|
||||
fn letters() -> Vec<Vec<Vector2D<Num<i32, 8>>>> {
|
||||
vec![
|
||||
|
|
|
@ -82,7 +82,7 @@
|
|||
//! # let vblank = agb::interrupt::VBlank::get();
|
||||
//! # use agb::{*, sound::mixer::*};
|
||||
//! // Outside your main function in global scope:
|
||||
//! const MY_CRAZY_SOUND: &[u8] = include_wav!("examples/sfx/jump.wav");
|
||||
//! static MY_CRAZY_SOUND: &[u8] = include_wav!("examples/sfx/jump.wav");
|
||||
//!
|
||||
//! // Then to play the sound:
|
||||
//! let mut channel = SoundChannel::new(MY_CRAZY_SOUND);
|
||||
|
@ -194,7 +194,7 @@ impl Frequency {
|
|||
/// # use agb::sound::mixer::*;
|
||||
/// # use agb::*;
|
||||
/// // in global scope:
|
||||
/// const MY_BGM: &[u8] = include_wav!("examples/sfx/my_bgm.wav");
|
||||
/// static MY_BGM: &[u8] = include_wav!("examples/sfx/my_bgm.wav");
|
||||
///
|
||||
/// // somewhere in code
|
||||
/// # fn foo(gba: &mut Gba) {
|
||||
|
@ -213,7 +213,7 @@ impl Frequency {
|
|||
/// # use agb::sound::mixer::*;
|
||||
/// # use agb::*;
|
||||
/// // in global scope:
|
||||
/// const JUMP_SOUND: &[u8] = include_wav!("examples/sfx/jump.wav");
|
||||
/// static JUMP_SOUND: &[u8] = include_wav!("examples/sfx/jump.wav");
|
||||
///
|
||||
/// // somewhere in code
|
||||
/// # fn foo(gba: &mut Gba) {
|
||||
|
@ -258,7 +258,7 @@ impl SoundChannel {
|
|||
/// # fn foo(gba: &mut Gba) {
|
||||
/// # let mut mixer = gba.mixer.mixer(agb::sound::mixer::Frequency::Hz10512);
|
||||
/// // in global scope:
|
||||
/// const JUMP_SOUND: &[u8] = include_wav!("examples/sfx/jump.wav");
|
||||
/// static JUMP_SOUND: &[u8] = include_wav!("examples/sfx/jump.wav");
|
||||
///
|
||||
/// // somewhere in code
|
||||
/// let jump_sound = SoundChannel::new(JUMP_SOUND);
|
||||
|
@ -302,7 +302,7 @@ impl SoundChannel {
|
|||
/// # fn foo(gba: &mut Gba) {
|
||||
/// # let mut mixer = gba.mixer.mixer(agb::sound::mixer::Frequency::Hz10512);
|
||||
/// // in global scope:
|
||||
/// const MY_BGM: &[u8] = include_wav!("examples/sfx/my_bgm.wav");
|
||||
/// static MY_BGM: &[u8] = include_wav!("examples/sfx/my_bgm.wav");
|
||||
///
|
||||
/// // somewhere in code
|
||||
/// let mut bgm = SoundChannel::new_high_priority(MY_BGM);
|
||||
|
|
|
@ -89,7 +89,7 @@ extern "C" {
|
|||
/// # let mut mixer = gba.mixer.mixer(agb::sound::mixer::Frequency::Hz10512);
|
||||
/// # let vblank = agb::interrupt::VBlank::get();
|
||||
/// // Outside your main function in global scope:
|
||||
/// const MY_CRAZY_SOUND: &[u8] = include_wav!("examples/sfx/jump.wav");
|
||||
/// static MY_CRAZY_SOUND: &[u8] = include_wav!("examples/sfx/jump.wav");
|
||||
///
|
||||
/// // in your main function:
|
||||
/// let mut mixer = gba.mixer.mixer(Frequency::Hz10512);
|
||||
|
@ -133,7 +133,7 @@ pub struct Mixer<'gba> {
|
|||
/// # use agb::*;
|
||||
/// # fn foo(gba: &mut Gba) {
|
||||
/// # let mut mixer = gba.mixer.mixer(agb::sound::mixer::Frequency::Hz10512);
|
||||
/// # const MY_BGM: &[u8] = include_wav!("examples/sfx/my_bgm.wav");
|
||||
/// # static MY_BGM: &[u8] = include_wav!("examples/sfx/my_bgm.wav");
|
||||
/// let mut channel = SoundChannel::new_high_priority(MY_BGM);
|
||||
/// let bgm_channel_id = mixer.play_sound(channel).unwrap(); // will always be Some if high priority
|
||||
///
|
||||
|
@ -258,7 +258,7 @@ impl Mixer<'_> {
|
|||
/// # use agb::*;
|
||||
/// # fn foo(gba: &mut Gba) {
|
||||
/// # let mut mixer = gba.mixer.mixer(agb::sound::mixer::Frequency::Hz10512);
|
||||
/// # const MY_BGM: &[u8] = include_wav!("examples/sfx/my_bgm.wav");
|
||||
/// # static MY_BGM: &[u8] = include_wav!("examples/sfx/my_bgm.wav");
|
||||
/// let mut channel = SoundChannel::new_high_priority(MY_BGM);
|
||||
/// let bgm_channel_id = mixer.play_sound(channel).unwrap(); // will always be Some if high priority
|
||||
/// # }
|
||||
|
@ -307,7 +307,7 @@ impl Mixer<'_> {
|
|||
/// # use agb::*;
|
||||
/// # fn foo(gba: &mut Gba) {
|
||||
/// # let mut mixer = gba.mixer.mixer(agb::sound::mixer::Frequency::Hz10512);
|
||||
/// # const MY_BGM: &[u8] = include_wav!("examples/sfx/my_bgm.wav");
|
||||
/// # static MY_BGM: &[u8] = include_wav!("examples/sfx/my_bgm.wav");
|
||||
/// let mut channel = SoundChannel::new_high_priority(MY_BGM);
|
||||
/// let bgm_channel_id = mixer.play_sound(channel).unwrap(); // will always be Some if high priority
|
||||
///
|
||||
|
|
|
@ -15,16 +15,16 @@ use agb::{
|
|||
include_aseprite,
|
||||
};
|
||||
|
||||
// Import the sprites in to this constant. This holds the sprite
|
||||
// Import the sprites in to this static. This holds the sprite
|
||||
// and palette data in a way that is manageable by agb.
|
||||
const GRAPHICS: &Graphics = include_aseprite!("gfx/sprites.aseprite");
|
||||
static GRAPHICS: &Graphics = include_aseprite!("gfx/sprites.aseprite");
|
||||
|
||||
// We define some easy ways of referencing the sprites
|
||||
#[allow(dead_code)]
|
||||
const PADDLE_END: &Tag = GRAPHICS.tags().get("Paddle End");
|
||||
static PADDLE_END: &Tag = GRAPHICS.tags().get("Paddle End");
|
||||
#[allow(dead_code)]
|
||||
const PADDLE_MID: &Tag = GRAPHICS.tags().get("Paddle Mid");
|
||||
const BALL: &Tag = GRAPHICS.tags().get("Ball");
|
||||
static PADDLE_MID: &Tag = GRAPHICS.tags().get("Paddle Mid");
|
||||
static BALL: &Tag = GRAPHICS.tags().get("Ball");
|
||||
|
||||
// The main function must take 0 arguments and never return. The agb::entry decorator
|
||||
// ensures that everything is in order. `agb` will call this after setting up the stack
|
||||
|
|
|
@ -46,14 +46,14 @@ use agb::{
|
|||
display::object::{Graphics, Tag}
|
||||
};
|
||||
|
||||
// Import the sprites in to this constant. This holds the sprite
|
||||
// Import the sprites in to this static. This holds the sprite
|
||||
// and palette data in a way that is manageable by agb.
|
||||
const GRAPHICS: &Graphics = include_aseprite!("gfx/sprites.aseprite");
|
||||
static GRAPHICS: &Graphics = include_aseprite!("gfx/sprites.aseprite");
|
||||
|
||||
// We define some easy ways of referencing the sprites
|
||||
const PADDLE_END: &Tag = GRAPHICS.tags().get("Paddle End");
|
||||
const PADDLE_MID: &Tag = GRAPHICS.tags().get("Paddle Mid");
|
||||
const BALL: &Tag = GRAPHICS.tags().get("Ball");
|
||||
static PADDLE_END: &Tag = GRAPHICS.tags().get("Paddle End");
|
||||
static PADDLE_MID: &Tag = GRAPHICS.tags().get("Paddle Mid");
|
||||
static BALL: &Tag = GRAPHICS.tags().get("Ball");
|
||||
```
|
||||
|
||||
This uses the `include_aseprite` macro to include the sprites in the given aseprite file.
|
||||
|
|
|
@ -133,7 +133,7 @@ fn draw_number(
|
|||
|
||||
impl SpriteCache {
|
||||
fn new(loader: &mut SpriteLoader) -> Self {
|
||||
const SPRITES: &Graphics = include_aseprite!(
|
||||
static SPRITES: &Graphics = include_aseprite!(
|
||||
"gfx/circles.aseprite",
|
||||
"gfx/saw.aseprite",
|
||||
"gfx/numbers.aseprite",
|
||||
|
@ -152,12 +152,12 @@ impl SpriteCache {
|
|||
.into_boxed_slice()
|
||||
}
|
||||
|
||||
const NUMBERS: &Tag = SPRITES.tags().get("numbers");
|
||||
const BLUE_CIRCLE: &Sprite = SPRITES.tags().get("Blue").sprite(0);
|
||||
const RED_CIRCLE: &Sprite = SPRITES.tags().get("Red").sprite(0);
|
||||
const SAW: &Sprite = SPRITES.tags().get("Saw").sprite(0);
|
||||
const BAR_RED: &Tag = SPRITES.tags().get("Red Bar");
|
||||
const BAR_BLUE: &Tag = SPRITES.tags().get("Blue Bar");
|
||||
static NUMBERS: &Tag = SPRITES.tags().get("numbers");
|
||||
static BLUE_CIRCLE: &Sprite = SPRITES.tags().get("Blue").sprite(0);
|
||||
static RED_CIRCLE: &Sprite = SPRITES.tags().get("Red").sprite(0);
|
||||
static SAW: &Sprite = SPRITES.tags().get("Saw").sprite(0);
|
||||
static BAR_RED: &Tag = SPRITES.tags().get("Red Bar");
|
||||
static BAR_BLUE: &Tag = SPRITES.tags().get("Blue Bar");
|
||||
|
||||
Self {
|
||||
saw: loader.get_vram_sprite(SAW),
|
||||
|
|
|
@ -21,21 +21,21 @@ type Game = fn(agb::Gba) -> !;
|
|||
|
||||
struct GameWithTiles {
|
||||
game: fn(agb::Gba) -> !,
|
||||
tiles: TileData,
|
||||
tiles: &'static TileData,
|
||||
}
|
||||
|
||||
impl GameWithTiles {
|
||||
const fn new(tiles: TileData, game: fn(agb::Gba) -> !) -> Self {
|
||||
const fn new(tiles: &'static TileData, game: fn(agb::Gba) -> !) -> Self {
|
||||
GameWithTiles { game, tiles }
|
||||
}
|
||||
}
|
||||
|
||||
const GAMES: &[GameWithTiles] = &[
|
||||
GameWithTiles::new(games::hat, the_hat_chooses_the_wizard::main),
|
||||
GameWithTiles::new(games::purple, the_purple_night::main),
|
||||
GameWithTiles::new(games::hyperspace, hyperspace_roll::main),
|
||||
GameWithTiles::new(games::dungeon_puzzler, the_dungeon_puzzlers_lament::entry),
|
||||
GameWithTiles::new(games::amplitude, amplitude::main),
|
||||
static GAMES: &[GameWithTiles] = &[
|
||||
GameWithTiles::new(&games::hat, the_hat_chooses_the_wizard::main),
|
||||
GameWithTiles::new(&games::purple, the_purple_night::main),
|
||||
GameWithTiles::new(&games::hyperspace, hyperspace_roll::main),
|
||||
GameWithTiles::new(&games::dungeon_puzzler, the_dungeon_puzzlers_lament::entry),
|
||||
GameWithTiles::new(&games::amplitude, amplitude::main),
|
||||
];
|
||||
|
||||
include_background_gfx!(
|
||||
|
|
|
@ -23,7 +23,7 @@ pub(crate) fn load_help_text(
|
|||
help_text_line: u16,
|
||||
at_tile: (u16, u16),
|
||||
) {
|
||||
let help_tiledata = backgrounds::help;
|
||||
let help_tiledata = &backgrounds::help;
|
||||
|
||||
for x in 0..16 {
|
||||
let tile_id = help_text_line * 16 + x;
|
||||
|
@ -43,9 +43,9 @@ pub(crate) fn load_description(
|
|||
vram: &mut VRamManager,
|
||||
) {
|
||||
let description_data = if face_id < 10 {
|
||||
backgrounds::descriptions1
|
||||
&backgrounds::descriptions1
|
||||
} else {
|
||||
backgrounds::descriptions2
|
||||
&backgrounds::descriptions2
|
||||
};
|
||||
|
||||
for y in 0..11 {
|
||||
|
|
|
@ -6,73 +6,88 @@ use alloc::vec::Vec;
|
|||
|
||||
use crate::{EnemyAttackType, Face, Ship};
|
||||
|
||||
const SPRITES: &agb::display::object::Graphics = agb::include_aseprite!(
|
||||
static SPRITES: &agb::display::object::Graphics = agb::include_aseprite!(
|
||||
"gfx/dice-faces.aseprite",
|
||||
"gfx/ships.aseprite",
|
||||
"gfx/small-sprites.aseprite"
|
||||
);
|
||||
pub const FACE_SPRITES: &FaceSprites = &FaceSprites::load_face_sprites();
|
||||
pub const ENEMY_ATTACK_SPRITES: &EnemyAttackSprites = &EnemyAttackSprites::new();
|
||||
pub const SELECT_BOX: &Tag = SPRITES.tags().get("selection");
|
||||
pub const SELECTED_BOX: &Sprite = SPRITES.tags().get("selected").sprite(0);
|
||||
pub const MODIFIED_BOX: &Sprite = SPRITES.tags().get("modified").sprite(0);
|
||||
pub static FACE_SPRITES: &FaceSprites = {
|
||||
static S_SHOOT: &Sprite = SPRITES.tags().get("shoot").sprite(0);
|
||||
static S_SHIELD: &Sprite = SPRITES.tags().get("shield").sprite(0);
|
||||
static S_MALFUNCTION: &Sprite = SPRITES.tags().get("malfunction").sprite(0);
|
||||
static S_HEAL: &Sprite = SPRITES.tags().get("player_heal").sprite(0);
|
||||
static S_BYPASS: &Sprite = SPRITES.tags().get("shield bypass").sprite(0);
|
||||
static S_DOUBLE_SHOT: &Sprite = SPRITES.tags().get("double shoot").sprite(0);
|
||||
static S_TRIPLE_SHOT: &Sprite = SPRITES.tags().get("triple shoot").sprite(0);
|
||||
static S_BLANK: &Sprite = SPRITES.tags().get("blank").sprite(0);
|
||||
static S_DISRUPT: &Sprite = SPRITES.tags().get("disruption").sprite(0);
|
||||
static S_MALFUNCTION_SHOOT: &Sprite = SPRITES.tags().get("malfunction shot").sprite(0);
|
||||
static S_DOUBLE_SHIELD: &Sprite = SPRITES.tags().get("double shield").sprite(0);
|
||||
static S_TRIPLE_SHIELD: &Sprite = SPRITES.tags().get("triple shield").sprite(0);
|
||||
static S_DOUBLE_SHIELD_VALUE: &Sprite = SPRITES.tags().get("double shield value").sprite(0);
|
||||
static S_DOUBLE_SHOT_VALUE: &Sprite = SPRITES.tags().get("double shoot power").sprite(0);
|
||||
static S_TRIPLE_SHOT_VALUE: &Sprite = SPRITES.tags().get("triple shoot power").sprite(0);
|
||||
static S_BURST_SHIELD: &Sprite = SPRITES.tags().get("burst shield").sprite(0);
|
||||
static S_INVERT: &Sprite = SPRITES.tags().get("swap shield and shoot").sprite(0);
|
||||
|
||||
pub const BULLET_SPRITE: &Sprite = SPRITES.tags().get("bullet").sprite(0);
|
||||
pub const DISRUPT_BULLET: &Sprite = SPRITES.tags().get("disrupt bullet").sprite(0);
|
||||
pub const BURST_BULLET: &Sprite = SPRITES.tags().get("burst shield bullet").sprite(0);
|
||||
pub const SHIELD: &Tag = SPRITES.tags().get("ship shield");
|
||||
&FaceSprites {
|
||||
sprites: [
|
||||
S_SHOOT,
|
||||
S_SHIELD,
|
||||
S_MALFUNCTION,
|
||||
S_HEAL,
|
||||
S_BYPASS,
|
||||
S_DOUBLE_SHOT,
|
||||
S_TRIPLE_SHOT,
|
||||
S_BLANK,
|
||||
S_DISRUPT,
|
||||
S_MALFUNCTION_SHOOT,
|
||||
S_DOUBLE_SHIELD,
|
||||
S_TRIPLE_SHIELD,
|
||||
S_DOUBLE_SHIELD_VALUE,
|
||||
S_DOUBLE_SHOT_VALUE,
|
||||
S_TRIPLE_SHOT_VALUE,
|
||||
S_BURST_SHIELD,
|
||||
S_INVERT,
|
||||
],
|
||||
}
|
||||
};
|
||||
pub static ENEMY_ATTACK_SPRITES: &EnemyAttackSprites = {
|
||||
static S_SHOOT: &Sprite = SPRITES.tags().get("enemy shoot").sprite(0);
|
||||
static S_SHIELD: &Sprite = SPRITES.tags().get("enemy shield").sprite(0);
|
||||
static S_HEAL: &Sprite = SPRITES.tags().get("enemy heal").sprite(0);
|
||||
|
||||
pub const SHIP_SPRITES: &ShipSprites = &ShipSprites::load_ship_sprites();
|
||||
&EnemyAttackSprites {
|
||||
sprites: [S_SHOOT, S_SHIELD, S_HEAL],
|
||||
}
|
||||
};
|
||||
pub static SELECT_BOX: &Tag = SPRITES.tags().get("selection");
|
||||
pub static SELECTED_BOX: &Sprite = SPRITES.tags().get("selected").sprite(0);
|
||||
pub static MODIFIED_BOX: &Sprite = SPRITES.tags().get("modified").sprite(0);
|
||||
|
||||
pub const SMALL_SPRITES: &SmallSprites = &SmallSprites {};
|
||||
pub static BULLET_SPRITE: &Sprite = SPRITES.tags().get("bullet").sprite(0);
|
||||
pub static DISRUPT_BULLET: &Sprite = SPRITES.tags().get("disrupt bullet").sprite(0);
|
||||
pub static BURST_BULLET: &Sprite = SPRITES.tags().get("burst shield bullet").sprite(0);
|
||||
pub static SHIELD: &Tag = SPRITES.tags().get("ship shield");
|
||||
|
||||
pub static SHIP_SPRITES: &ShipSprites = {
|
||||
static S_PLAYER: &Sprite = SPRITES.tags().get("player").sprite(0);
|
||||
static S_DRONE: &Sprite = SPRITES.tags().get("drone").sprite(0);
|
||||
static S_PILOTED_SHIP: &Sprite = SPRITES.tags().get("piloted ship").sprite(0);
|
||||
static S_SHIELD: &Sprite = SPRITES.tags().get("ship shield").sprite(0);
|
||||
|
||||
&ShipSprites {
|
||||
sprites: [S_PLAYER, S_DRONE, S_PILOTED_SHIP, S_SHIELD],
|
||||
}
|
||||
};
|
||||
|
||||
pub static SMALL_SPRITES: &SmallSprites = &SmallSprites {};
|
||||
|
||||
pub struct FaceSprites {
|
||||
sprites: [&'static Sprite; 17],
|
||||
}
|
||||
|
||||
impl FaceSprites {
|
||||
const fn load_face_sprites() -> Self {
|
||||
const S_SHOOT: &Sprite = SPRITES.tags().get("shoot").sprite(0);
|
||||
const S_SHIELD: &Sprite = SPRITES.tags().get("shield").sprite(0);
|
||||
const S_MALFUNCTION: &Sprite = SPRITES.tags().get("malfunction").sprite(0);
|
||||
const S_HEAL: &Sprite = SPRITES.tags().get("player_heal").sprite(0);
|
||||
const S_BYPASS: &Sprite = SPRITES.tags().get("shield bypass").sprite(0);
|
||||
const S_DOUBLE_SHOT: &Sprite = SPRITES.tags().get("double shoot").sprite(0);
|
||||
const S_TRIPLE_SHOT: &Sprite = SPRITES.tags().get("triple shoot").sprite(0);
|
||||
const S_BLANK: &Sprite = SPRITES.tags().get("blank").sprite(0);
|
||||
const S_DISRUPT: &Sprite = SPRITES.tags().get("disruption").sprite(0);
|
||||
const S_MALFUNCTION_SHOOT: &Sprite = SPRITES.tags().get("malfunction shot").sprite(0);
|
||||
const S_DOUBLE_SHIELD: &Sprite = SPRITES.tags().get("double shield").sprite(0);
|
||||
const S_TRIPLE_SHIELD: &Sprite = SPRITES.tags().get("triple shield").sprite(0);
|
||||
const S_DOUBLE_SHIELD_VALUE: &Sprite = SPRITES.tags().get("double shield value").sprite(0);
|
||||
const S_DOUBLE_SHOT_VALUE: &Sprite = SPRITES.tags().get("double shoot power").sprite(0);
|
||||
const S_TRIPLE_SHOT_VALUE: &Sprite = SPRITES.tags().get("triple shoot power").sprite(0);
|
||||
const S_BURST_SHIELD: &Sprite = SPRITES.tags().get("burst shield").sprite(0);
|
||||
const S_INVERT: &Sprite = SPRITES.tags().get("swap shield and shoot").sprite(0);
|
||||
|
||||
Self {
|
||||
sprites: [
|
||||
S_SHOOT,
|
||||
S_SHIELD,
|
||||
S_MALFUNCTION,
|
||||
S_HEAL,
|
||||
S_BYPASS,
|
||||
S_DOUBLE_SHOT,
|
||||
S_TRIPLE_SHOT,
|
||||
S_BLANK,
|
||||
S_DISRUPT,
|
||||
S_MALFUNCTION_SHOOT,
|
||||
S_DOUBLE_SHIELD,
|
||||
S_TRIPLE_SHIELD,
|
||||
S_DOUBLE_SHIELD_VALUE,
|
||||
S_DOUBLE_SHOT_VALUE,
|
||||
S_TRIPLE_SHOT_VALUE,
|
||||
S_BURST_SHIELD,
|
||||
S_INVERT,
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sprite_for_face(&self, face: Face) -> &'static Sprite {
|
||||
self.sprites[face as usize]
|
||||
}
|
||||
|
@ -83,17 +98,6 @@ pub struct ShipSprites {
|
|||
}
|
||||
|
||||
impl ShipSprites {
|
||||
const fn load_ship_sprites() -> Self {
|
||||
const S_PLAYER: &Sprite = SPRITES.tags().get("player").sprite(0);
|
||||
const S_DRONE: &Sprite = SPRITES.tags().get("drone").sprite(0);
|
||||
const S_PILOTED_SHIP: &Sprite = SPRITES.tags().get("piloted ship").sprite(0);
|
||||
const S_SHIELD: &Sprite = SPRITES.tags().get("ship shield").sprite(0);
|
||||
|
||||
Self {
|
||||
sprites: [S_PLAYER, S_DRONE, S_PILOTED_SHIP, S_SHIELD],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sprite_for_ship(&self, ship: Ship) -> &'static Sprite {
|
||||
self.sprites[ship as usize]
|
||||
}
|
||||
|
@ -101,17 +105,19 @@ impl ShipSprites {
|
|||
|
||||
pub struct SmallSprites;
|
||||
|
||||
static NUMBERS: &Tag = SPRITES.tags().get("numbers");
|
||||
static RED_BAR: &Tag = SPRITES.tags().get("red bar");
|
||||
impl SmallSprites {
|
||||
pub const fn number(&self, i: u32) -> &'static Sprite {
|
||||
SPRITES.tags().get("numbers").sprite(i as usize)
|
||||
pub fn number(&self, i: u32) -> &'static Sprite {
|
||||
NUMBERS.sprite(i as usize)
|
||||
}
|
||||
|
||||
pub const fn slash(&self) -> &'static Sprite {
|
||||
SPRITES.tags().get("numbers").sprite(10)
|
||||
pub fn slash(&self) -> &'static Sprite {
|
||||
NUMBERS.sprite(10)
|
||||
}
|
||||
|
||||
pub const fn red_bar(&self, i: usize) -> &'static Sprite {
|
||||
SPRITES.tags().get("red bar").sprite(i)
|
||||
pub fn red_bar(&self, i: usize) -> &'static Sprite {
|
||||
RED_BAR.sprite(i)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,16 +126,6 @@ pub struct EnemyAttackSprites {
|
|||
}
|
||||
|
||||
impl EnemyAttackSprites {
|
||||
const fn new() -> Self {
|
||||
const S_SHOOT: &Sprite = SPRITES.tags().get("enemy shoot").sprite(0);
|
||||
const S_SHIELD: &Sprite = SPRITES.tags().get("enemy shield").sprite(0);
|
||||
const S_HEAL: &Sprite = SPRITES.tags().get("enemy heal").sprite(0);
|
||||
|
||||
Self {
|
||||
sprites: [S_SHOOT, S_SHIELD, S_HEAL],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sprite_for_attack(&self, attack: EnemyAttackType) -> &'static Sprite {
|
||||
self.sprites[attack as usize]
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ use agb::fixnum::num;
|
|||
use agb::sound::mixer::{ChannelId, Mixer, SoundChannel};
|
||||
use agb::{include_wav, rng};
|
||||
|
||||
const DICE_ROLLS: &[&[u8]] = &[
|
||||
static DICE_ROLLS: &[&[u8]] = &[
|
||||
include_wav!("sfx/SingleRoll_1.wav"),
|
||||
include_wav!("sfx/SingleRoll_2.wav"),
|
||||
include_wav!("sfx/SingleRoll_3.wav"),
|
||||
|
@ -10,7 +10,7 @@ const DICE_ROLLS: &[&[u8]] = &[
|
|||
include_wav!("sfx/SingleRoll_5.wav"),
|
||||
];
|
||||
|
||||
const MULTI_ROLLS: &[&[u8]] = &[
|
||||
static MULTI_ROLLS: &[&[u8]] = &[
|
||||
include_wav!("sfx/MultiRoll_1.wav"),
|
||||
include_wav!("sfx/MultiRoll_2.wav"),
|
||||
include_wav!("sfx/MultiRoll_3.wav"),
|
||||
|
@ -18,24 +18,24 @@ const MULTI_ROLLS: &[&[u8]] = &[
|
|||
include_wav!("sfx/MultiRoll_5.wav"),
|
||||
];
|
||||
|
||||
const MENU_BGM: &[u8] = include_wav!("sfx/BGM_Menu.wav");
|
||||
const BATTLE_BGM: &[u8] = include_wav!("sfx/BGM_Fight.wav");
|
||||
const TITLE_BGM: &[u8] = include_wav!("sfx/BGM_Title.wav");
|
||||
static MENU_BGM: &[u8] = include_wav!("sfx/BGM_Menu.wav");
|
||||
static BATTLE_BGM: &[u8] = include_wav!("sfx/BGM_Fight.wav");
|
||||
static TITLE_BGM: &[u8] = include_wav!("sfx/BGM_Title.wav");
|
||||
|
||||
const SHOOT: &[u8] = include_wav!("sfx/shoot.wav");
|
||||
const SHOT_HIT: &[u8] = include_wav!("sfx/shot_hit.wav");
|
||||
const SHIP_EXPLODE: &[u8] = include_wav!("sfx/ship_explode.wav");
|
||||
const MOVE_CURSOR: &[u8] = include_wav!("sfx/move_cursor.wav");
|
||||
const SELECT: &[u8] = include_wav!("sfx/select.wav");
|
||||
const BACK: &[u8] = include_wav!("sfx/back.wav");
|
||||
const ACCEPT: &[u8] = include_wav!("sfx/accept.wav");
|
||||
const SHIELD_DOWN: &[u8] = include_wav!("sfx/shield_down.wav");
|
||||
const SHIELD_UP: &[u8] = include_wav!("sfx/shield_up.wav");
|
||||
const SHIELD_DEFEND: &[u8] = include_wav!("sfx/shield_defend.wav");
|
||||
const DISRUPT: &[u8] = include_wav!("sfx/disrupt.wav");
|
||||
const HEAL: &[u8] = include_wav!("sfx/heal.wav");
|
||||
const SEND_BURST_SHIELD: &[u8] = include_wav!("sfx/send_burst_shield.wav");
|
||||
const BURST_SHIELD_HIT: &[u8] = include_wav!("sfx/burst_shield_hit.wav");
|
||||
static SHOOT: &[u8] = include_wav!("sfx/shoot.wav");
|
||||
static SHOT_HIT: &[u8] = include_wav!("sfx/shot_hit.wav");
|
||||
static SHIP_EXPLODE: &[u8] = include_wav!("sfx/ship_explode.wav");
|
||||
static MOVE_CURSOR: &[u8] = include_wav!("sfx/move_cursor.wav");
|
||||
static SELECT: &[u8] = include_wav!("sfx/select.wav");
|
||||
static BACK: &[u8] = include_wav!("sfx/back.wav");
|
||||
static ACCEPT: &[u8] = include_wav!("sfx/accept.wav");
|
||||
static SHIELD_DOWN: &[u8] = include_wav!("sfx/shield_down.wav");
|
||||
static SHIELD_UP: &[u8] = include_wav!("sfx/shield_up.wav");
|
||||
static SHIELD_DEFEND: &[u8] = include_wav!("sfx/shield_defend.wav");
|
||||
static DISRUPT: &[u8] = include_wav!("sfx/disrupt.wav");
|
||||
static HEAL: &[u8] = include_wav!("sfx/heal.wav");
|
||||
static SEND_BURST_SHIELD: &[u8] = include_wav!("sfx/send_burst_shield.wav");
|
||||
static BURST_SHIELD_HIT: &[u8] = include_wav!("sfx/burst_shield_hit.wav");
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
enum BattleOrMenu {
|
||||
|
|
|
@ -78,12 +78,12 @@ fn main() {
|
|||
let tilemaps_output = quote! {
|
||||
use agb::display::tiled::TileSetting;
|
||||
|
||||
pub const UI_BACKGROUND_MAP: &[TileSetting] = #ui_tiles;
|
||||
pub const LEVELS_MAP: &[&[TileSetting]] = &[#(#levels_tiles),*];
|
||||
pub static UI_BACKGROUND_MAP: &[TileSetting] = #ui_tiles;
|
||||
pub static LEVELS_MAP: &[&[TileSetting]] = &[#(#levels_tiles),*];
|
||||
};
|
||||
|
||||
let levels_output = quote! {
|
||||
pub const LEVELS: &[Level] = &[#(#levels_data),*];
|
||||
pub static LEVELS: &[Level] = &[#(#levels_data),*];
|
||||
};
|
||||
|
||||
{
|
||||
|
|
|
@ -19,14 +19,14 @@ pub fn load_palettes(vram_manager: &mut VRamManager) {
|
|||
}
|
||||
|
||||
pub fn load_ui(map: &mut RegularMap, vram_manager: &mut VRamManager) {
|
||||
let ui_tileset = backgrounds::ui.tiles;
|
||||
let ui_tileset = &backgrounds::ui.tiles;
|
||||
|
||||
for y in 0..20u16 {
|
||||
for x in 0..30u16 {
|
||||
let tile_pos = y * 30 + x;
|
||||
let tile_setting = tilemaps::UI_BACKGROUND_MAP[tile_pos as usize];
|
||||
|
||||
map.set_tile(vram_manager, (x, y), &ui_tileset, tile_setting);
|
||||
map.set_tile(vram_manager, (x, y), ui_tileset, tile_setting);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,14 +38,14 @@ pub fn load_level_background(
|
|||
) {
|
||||
let level_map = &tilemaps::LEVELS_MAP[level_number];
|
||||
|
||||
let level_tileset = backgrounds::level.tiles;
|
||||
let level_tileset = &backgrounds::level.tiles;
|
||||
|
||||
for y in 0..20u16 {
|
||||
for x in 0..22u16 {
|
||||
let tile_pos = y * 22 + x;
|
||||
let tile_setting = level_map[tile_pos as usize];
|
||||
|
||||
map.set_tile(vram_manager, (x, y), &level_tileset, tile_setting);
|
||||
map.set_tile(vram_manager, (x, y), level_tileset, tile_setting);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -429,7 +429,7 @@ impl CursorState {
|
|||
}
|
||||
}
|
||||
|
||||
const fn arrow_for_direction(direction: Direction) -> &'static Tag {
|
||||
fn arrow_for_direction(direction: Direction) -> &'static Tag {
|
||||
match direction {
|
||||
Direction::Up => resources::ARROW_UP,
|
||||
Direction::Down => resources::ARROW_DOWN,
|
||||
|
|
|
@ -151,11 +151,11 @@ impl Level {
|
|||
}
|
||||
}
|
||||
|
||||
pub const fn get_level(level_number: usize) -> &'static Level {
|
||||
pub fn get_level(level_number: usize) -> &'static Level {
|
||||
&levels::LEVELS[level_number]
|
||||
}
|
||||
|
||||
pub const fn num_levels() -> usize {
|
||||
pub fn num_levels() -> usize {
|
||||
levels::LEVELS.len()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ use agb::{
|
|||
include_aseprite, include_font,
|
||||
};
|
||||
|
||||
const SPRITES: &Graphics = include_aseprite!(
|
||||
static SPRITES: &Graphics = include_aseprite!(
|
||||
"gfx/sprites16x16.aseprite",
|
||||
"gfx/sprites8x8.aseprite",
|
||||
"gfx/countdown.aseprite"
|
||||
|
@ -16,7 +16,7 @@ macro_rules! named_tag {
|
|||
] $(,)?
|
||||
) => {
|
||||
$(
|
||||
pub const $name: &agb::display::object::Tag = $sprites.tags().get(stringify!($name));
|
||||
pub static $name: &agb::display::object::Tag = $sprites.tags().get(stringify!($name));
|
||||
)+
|
||||
};
|
||||
}
|
||||
|
@ -68,4 +68,4 @@ named_tag!(
|
|||
]
|
||||
);
|
||||
|
||||
pub const FONT: Font = include_font!("fnt/yoster.ttf", 12);
|
||||
pub static FONT: Font = include_font!("fnt/yoster.ttf", 12);
|
||||
|
|
|
@ -5,18 +5,18 @@ use agb::{
|
|||
};
|
||||
use agb_tracker::{include_xm, Track, Tracker};
|
||||
|
||||
const MUSIC: Track = include_xm!("sfx/gwilym-theme2.xm");
|
||||
static MUSIC: Track = include_xm!("sfx/gwilym-theme2.xm");
|
||||
|
||||
const BAD_SELECTION: &[u8] = include_wav!("sfx/bad.wav");
|
||||
const SELECT: &[u8] = include_wav!("sfx/select.wav");
|
||||
const PLACE: &[u8] = include_wav!("sfx/place.wav");
|
||||
static BAD_SELECTION: &[u8] = include_wav!("sfx/bad.wav");
|
||||
static SELECT: &[u8] = include_wav!("sfx/select.wav");
|
||||
static PLACE: &[u8] = include_wav!("sfx/place.wav");
|
||||
|
||||
const SLIME_DEATH: &[u8] = include_wav!("sfx/slime_death.wav");
|
||||
const SWORD_PICKUP: &[u8] = include_wav!("sfx/sword_pickup.wav");
|
||||
const WALL_HIT: &[u8] = include_wav!("sfx/wall_hit.wav");
|
||||
const DOOR_OPEN: &[u8] = include_wav!("sfx/door_open.wav");
|
||||
static SLIME_DEATH: &[u8] = include_wav!("sfx/slime_death.wav");
|
||||
static SWORD_PICKUP: &[u8] = include_wav!("sfx/sword_pickup.wav");
|
||||
static WALL_HIT: &[u8] = include_wav!("sfx/wall_hit.wav");
|
||||
static DOOR_OPEN: &[u8] = include_wav!("sfx/door_open.wav");
|
||||
|
||||
const SWICTH_TOGGLES: &[&[u8]] = &[include_wav!("sfx/switch_toggle1.wav")];
|
||||
static SWICTH_TOGGLES: &[&[u8]] = &[include_wav!("sfx/switch_toggle1.wav")];
|
||||
|
||||
pub struct Sfx<'a> {
|
||||
mixer: &'a mut Mixer<'a>,
|
||||
|
|
|
@ -164,8 +164,8 @@ mod tiled_export {
|
|||
use crate::Level;
|
||||
use agb::fixnum::Vector2D;
|
||||
|
||||
pub const fn get_level() -> Level {{
|
||||
Level {{
|
||||
pub const fn get_level() -> &'static Level {{
|
||||
&Level {{
|
||||
background: TILEMAP,
|
||||
foreground: BACKGROUND,
|
||||
dimensions: Vector2D {{x: WIDTH, y: HEIGHT}},
|
||||
|
|
|
@ -6,14 +6,14 @@ use agb::{
|
|||
fixnum::Vector2D,
|
||||
};
|
||||
|
||||
const SLIME_IDLE: &Tag = TAG_MAP.get("Slime Idle");
|
||||
const SLIME_JUMP: &Tag = TAG_MAP.get("Slime Jump");
|
||||
const SLIME_SPLAT: &Tag = TAG_MAP.get("Slime splat");
|
||||
static SLIME_IDLE: &Tag = TAG_MAP.get("Slime Idle");
|
||||
static SLIME_JUMP: &Tag = TAG_MAP.get("Slime Jump");
|
||||
static SLIME_SPLAT: &Tag = TAG_MAP.get("Slime splat");
|
||||
|
||||
const SNAIL_EMERGE: &Tag = TAG_MAP.get("Snail Emerge");
|
||||
const SNAIL_MOVE: &Tag = TAG_MAP.get("Snail Move");
|
||||
const SNAIL_DEATH: &Tag = TAG_MAP.get("Snail Death");
|
||||
const SNAIL_IDLE: &Tag = TAG_MAP.get("Snail Idle");
|
||||
static SNAIL_EMERGE: &Tag = TAG_MAP.get("Snail Emerge");
|
||||
static SNAIL_MOVE: &Tag = TAG_MAP.get("Snail Move");
|
||||
static SNAIL_DEATH: &Tag = TAG_MAP.get("Snail Death");
|
||||
static SNAIL_IDLE: &Tag = TAG_MAP.get("Snail Idle");
|
||||
|
||||
enum UpdateState {
|
||||
Nothing,
|
||||
|
|
|
@ -42,7 +42,7 @@ pub struct Level {
|
|||
mod map_tiles {
|
||||
|
||||
use super::Level;
|
||||
pub const LEVELS: &[Level] = &[
|
||||
pub static LEVELS: &[&Level] = &[
|
||||
l1_1::get_level(),
|
||||
l1_2::get_level(),
|
||||
l1_3::get_level(),
|
||||
|
@ -103,16 +103,16 @@ mod map_tiles {
|
|||
|
||||
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();
|
||||
static GRAPHICS: &Graphics = agb::include_aseprite!("gfx/sprites.aseprite");
|
||||
static TAG_MAP: &TagMap = GRAPHICS.tags();
|
||||
|
||||
const WALKING: &Tag = TAG_MAP.get("Walking");
|
||||
const JUMPING: &Tag = TAG_MAP.get("Jumping");
|
||||
const FALLING: &Tag = TAG_MAP.get("Falling");
|
||||
const PLAYER_DEATH: &Tag = TAG_MAP.get("Player Death");
|
||||
const HAT_SPIN_1: &Tag = TAG_MAP.get("HatSpin");
|
||||
const HAT_SPIN_2: &Tag = TAG_MAP.get("HatSpin2");
|
||||
const HAT_SPIN_3: &Tag = TAG_MAP.get("HatSpin3");
|
||||
static WALKING: &Tag = TAG_MAP.get("Walking");
|
||||
static JUMPING: &Tag = TAG_MAP.get("Jumping");
|
||||
static FALLING: &Tag = TAG_MAP.get("Falling");
|
||||
static PLAYER_DEATH: &Tag = TAG_MAP.get("Player Death");
|
||||
static HAT_SPIN_1: &Tag = TAG_MAP.get("HatSpin");
|
||||
static HAT_SPIN_2: &Tag = TAG_MAP.get("HatSpin2");
|
||||
static HAT_SPIN_3: &Tag = TAG_MAP.get("HatSpin3");
|
||||
|
||||
type FixedNumberType = FixedNum<10>;
|
||||
|
||||
|
@ -788,14 +788,14 @@ pub fn main(mut agb: agb::Gba) -> ! {
|
|||
TileFormat::FourBpp,
|
||||
);
|
||||
|
||||
let tileset = tile_sheet::background.tiles;
|
||||
let tileset = &tile_sheet::background.tiles;
|
||||
|
||||
for y in 0..32u16 {
|
||||
for x in 0..32u16 {
|
||||
world_display.set_tile(
|
||||
&mut vram,
|
||||
(x, y),
|
||||
&tileset,
|
||||
tileset,
|
||||
tile_sheet::background.tile_settings[level_display::BLANK],
|
||||
);
|
||||
}
|
||||
|
@ -839,7 +839,7 @@ pub fn main(mut agb: agb::Gba) -> ! {
|
|||
&mut world_display,
|
||||
current_level / 8 + 1,
|
||||
current_level % 8 + 1,
|
||||
&tileset,
|
||||
tileset,
|
||||
&mut vram,
|
||||
tile_sheet::background.tile_settings,
|
||||
);
|
||||
|
@ -860,7 +860,7 @@ pub fn main(mut agb: agb::Gba) -> ! {
|
|||
Box::new(|pos: Vector2D<i32>| {
|
||||
let level = &map_tiles::LEVELS[map_current_level as usize];
|
||||
(
|
||||
&tileset,
|
||||
tileset,
|
||||
tile_sheet::background.tile_settings[*level
|
||||
.background
|
||||
.get((pos.y * level.dimensions.x as i32 + pos.x) as usize)
|
||||
|
@ -878,7 +878,7 @@ pub fn main(mut agb: agb::Gba) -> ! {
|
|||
Box::new(|pos: Vector2D<i32>| {
|
||||
let level = &map_tiles::LEVELS[map_current_level as usize];
|
||||
(
|
||||
&tileset,
|
||||
tileset,
|
||||
tile_sheet::background.tile_settings[*level
|
||||
.foreground
|
||||
.get((pos.y * level.dimensions.x as i32 + pos.x) as usize)
|
||||
|
@ -889,7 +889,7 @@ pub fn main(mut agb: agb::Gba) -> ! {
|
|||
);
|
||||
|
||||
let mut level = PlayingLevel::open_level(
|
||||
&map_tiles::LEVELS[current_level as usize],
|
||||
map_tiles::LEVELS[current_level as usize],
|
||||
&object,
|
||||
&mut background,
|
||||
&mut foreground,
|
||||
|
|
|
@ -7,9 +7,9 @@ mod music_data {
|
|||
// 1. Play the intro.
|
||||
// 2. When the intro reaches approximately 11.080 seconds, trigger the main loop and let the intro finish underneath it.
|
||||
// 3. Re-trigger the main loop every time it reaches 1 minute 26.080 seconds, and let the old instance finish underneath the new one.
|
||||
pub const INTRO_MUSIC: &[u8] =
|
||||
pub static INTRO_MUSIC: &[u8] =
|
||||
agb::include_wav!("sfx/Otto Halmén - Sylvan Waltz (loop intro).wav");
|
||||
pub const LOOP: &[u8] = agb::include_wav!("sfx/Otto Halmén - Sylvan Waltz (loop main).wav");
|
||||
pub static LOOP: &[u8] = agb::include_wav!("sfx/Otto Halmén - Sylvan Waltz (loop main).wav");
|
||||
|
||||
// These are based on the instructions above and a frame rate of 59.73Hz
|
||||
pub const TRIGGER_MUSIC_POINT: i32 = 662;
|
||||
|
@ -17,24 +17,24 @@ mod music_data {
|
|||
}
|
||||
|
||||
mod effects {
|
||||
const WOOSH1: &[u8] = agb::include_wav!("sfx/woosh1.wav");
|
||||
const WOOSH2: &[u8] = agb::include_wav!("sfx/woosh2.wav");
|
||||
const WOOSH3: &[u8] = agb::include_wav!("sfx/woosh3.wav");
|
||||
static WOOSH1: &[u8] = agb::include_wav!("sfx/woosh1.wav");
|
||||
static WOOSH2: &[u8] = agb::include_wav!("sfx/woosh2.wav");
|
||||
static WOOSH3: &[u8] = agb::include_wav!("sfx/woosh3.wav");
|
||||
|
||||
pub const WHOOSHES: &[&[u8]] = &[WOOSH1, WOOSH2, WOOSH3];
|
||||
pub static WHOOSHES: &[&[u8]] = &[WOOSH1, WOOSH2, WOOSH3];
|
||||
|
||||
pub const CATCH: &[u8] = agb::include_wav!("sfx/catch.wav");
|
||||
pub static CATCH: &[u8] = agb::include_wav!("sfx/catch.wav");
|
||||
|
||||
pub const JUMP: &[u8] = agb::include_wav!("sfx/jump.wav");
|
||||
pub const LAND: &[u8] = agb::include_wav!("sfx/land.wav");
|
||||
pub static JUMP: &[u8] = agb::include_wav!("sfx/jump.wav");
|
||||
pub static LAND: &[u8] = agb::include_wav!("sfx/land.wav");
|
||||
|
||||
pub const SLIME_JUMP: &[u8] = agb::include_wav!("sfx/slime-jump.wav");
|
||||
pub const SLIME_DEATH: &[u8] = agb::include_wav!("sfx/slime-death.wav");
|
||||
pub static SLIME_JUMP: &[u8] = agb::include_wav!("sfx/slime-jump.wav");
|
||||
pub static SLIME_DEATH: &[u8] = agb::include_wav!("sfx/slime-death.wav");
|
||||
|
||||
pub const SNAIL_EMERGE: &[u8] = agb::include_wav!("sfx/snail-emerge.wav");
|
||||
pub const SNAIL_RETREAT: &[u8] = agb::include_wav!("sfx/snail-retreat.wav");
|
||||
pub const SNAIL_HAT_BOUNCE: &[u8] = agb::include_wav!("sfx/snail-hat-bounce.wav");
|
||||
pub const SNAIL_DEATH: &[u8] = agb::include_wav!("sfx/snail-death.wav");
|
||||
pub static SNAIL_EMERGE: &[u8] = agb::include_wav!("sfx/snail-emerge.wav");
|
||||
pub static SNAIL_RETREAT: &[u8] = agb::include_wav!("sfx/snail-retreat.wav");
|
||||
pub static SNAIL_HAT_BOUNCE: &[u8] = agb::include_wav!("sfx/snail-hat-bounce.wav");
|
||||
pub static SNAIL_DEATH: &[u8] = agb::include_wav!("sfx/snail-death.wav");
|
||||
}
|
||||
|
||||
pub struct SfxPlayer<'a> {
|
||||
|
|
|
@ -19,8 +19,8 @@ pub fn show_splash_screen(
|
|||
) {
|
||||
map.set_scroll_pos((0i16, 0i16));
|
||||
let tile_data = match which {
|
||||
SplashScreen::Start => splash_screens::splash,
|
||||
SplashScreen::End => splash_screens::thanks_for_playing,
|
||||
SplashScreen::Start => &splash_screens::splash,
|
||||
SplashScreen::End => &splash_screens::thanks_for_playing,
|
||||
};
|
||||
|
||||
let vblank = agb::interrupt::VBlank::get();
|
||||
|
@ -30,7 +30,7 @@ pub fn show_splash_screen(
|
|||
sfx.frame();
|
||||
vblank.wait_for_vblank();
|
||||
|
||||
map.fill_with(vram, &tile_data);
|
||||
map.fill_with(vram, tile_data);
|
||||
|
||||
map.commit(vram);
|
||||
vram.set_background_palettes(splash_screens::PALETTES);
|
||||
|
|
|
@ -42,22 +42,22 @@ fn main() {
|
|||
(0..map.tilesets[0].tilecount.unwrap()).map(|id| tile_types.get(&(id + 1)).unwrap_or(&0));
|
||||
|
||||
let output = quote! {
|
||||
pub const CLOUD_MAP: &[u16] = &[#(#cloud_tiles),*];
|
||||
pub const BACKGROUND_MAP: &[u16] = &[#(#background_tiles),*];
|
||||
pub const FOREGROUND_MAP: &[u16] = &[#(#foreground_tiles),*];
|
||||
pub static CLOUD_MAP: &[u16] = &[#(#cloud_tiles),*];
|
||||
pub static BACKGROUND_MAP: &[u16] = &[#(#background_tiles),*];
|
||||
pub static FOREGROUND_MAP: &[u16] = &[#(#foreground_tiles),*];
|
||||
pub const WIDTH: i32 = #width as i32;
|
||||
pub const HEIGHT: i32 = #height as i32;
|
||||
|
||||
pub const SLIME_SPAWNS_X: &[u16] = &[#(#slimes_x),*];
|
||||
pub const SLIME_SPAWNS_Y: &[u16] = &[#(#slimes_y),*];
|
||||
pub static SLIME_SPAWNS_X: &[u16] = &[#(#slimes_x),*];
|
||||
pub static SLIME_SPAWNS_Y: &[u16] = &[#(#slimes_y),*];
|
||||
|
||||
pub const BAT_SPAWNS_X: &[u16] = &[#(#bats_x),*];
|
||||
pub const BAT_SPAWNS_Y: &[u16] = &[#(#bats_y),*];
|
||||
pub static BAT_SPAWNS_X: &[u16] = &[#(#bats_x),*];
|
||||
pub static BAT_SPAWNS_Y: &[u16] = &[#(#bats_y),*];
|
||||
|
||||
pub const EMU_SPAWNS_X: &[u16] = &[#(#emus_x),*];
|
||||
pub const EMU_SPAWNS_Y: &[u16] = &[#(#emus_y),*];
|
||||
pub static EMU_SPAWNS_X: &[u16] = &[#(#emus_x),*];
|
||||
pub static EMU_SPAWNS_Y: &[u16] = &[#(#emus_y),*];
|
||||
|
||||
pub const TILE_TYPES: &[u8] = &[#(#tile_types),*];
|
||||
pub static TILE_TYPES: &[u8] = &[#(#tile_types),*];
|
||||
};
|
||||
|
||||
let output_file = File::create(format!("{out_dir}/tilemap.rs"))
|
||||
|
|
|
@ -27,32 +27,32 @@ use agb::{
|
|||
use generational_arena::Arena;
|
||||
use sfx::Sfx;
|
||||
|
||||
const GRAPHICS: &Graphics = agb::include_aseprite!("gfx/objects.aseprite", "gfx/boss.aseprite");
|
||||
const TAG_MAP: &TagMap = GRAPHICS.tags();
|
||||
static GRAPHICS: &Graphics = agb::include_aseprite!("gfx/objects.aseprite", "gfx/boss.aseprite");
|
||||
static TAG_MAP: &TagMap = GRAPHICS.tags();
|
||||
|
||||
const LONG_SWORD_IDLE: &Tag = TAG_MAP.get("Idle - longsword");
|
||||
const LONG_SWORD_WALK: &Tag = TAG_MAP.get("Walk - longsword");
|
||||
const LONG_SWORD_JUMP: &Tag = TAG_MAP.get("Jump - longsword");
|
||||
const LONG_SWORD_ATTACK: &Tag = TAG_MAP.get("Attack - longsword");
|
||||
const LONG_SWORD_JUMP_ATTACK: &Tag = TAG_MAP.get("Jump attack - longsword");
|
||||
static LONG_SWORD_IDLE: &Tag = TAG_MAP.get("Idle - longsword");
|
||||
static LONG_SWORD_WALK: &Tag = TAG_MAP.get("Walk - longsword");
|
||||
static LONG_SWORD_JUMP: &Tag = TAG_MAP.get("Jump - longsword");
|
||||
static LONG_SWORD_ATTACK: &Tag = TAG_MAP.get("Attack - longsword");
|
||||
static LONG_SWORD_JUMP_ATTACK: &Tag = TAG_MAP.get("Jump attack - longsword");
|
||||
|
||||
const SHORT_SWORD_IDLE: &Tag = TAG_MAP.get("Idle - shortsword");
|
||||
const SHORT_SWORD_WALK: &Tag = TAG_MAP.get("Walk - shortsword");
|
||||
const SHORT_SWORD_JUMP: &Tag = TAG_MAP.get("jump - shortsword");
|
||||
const SHORT_SWORD_ATTACK: &Tag = TAG_MAP.get("attack - shortsword");
|
||||
const SHORT_SWORD_JUMP_ATTACK: &Tag = TAG_MAP.get("jump attack - shortsword");
|
||||
static SHORT_SWORD_IDLE: &Tag = TAG_MAP.get("Idle - shortsword");
|
||||
static SHORT_SWORD_WALK: &Tag = TAG_MAP.get("Walk - shortsword");
|
||||
static SHORT_SWORD_JUMP: &Tag = TAG_MAP.get("jump - shortsword");
|
||||
static SHORT_SWORD_ATTACK: &Tag = TAG_MAP.get("attack - shortsword");
|
||||
static SHORT_SWORD_JUMP_ATTACK: &Tag = TAG_MAP.get("jump attack - shortsword");
|
||||
|
||||
const KNIFE_IDLE: &Tag = TAG_MAP.get("idle - knife");
|
||||
const KNIFE_WALK: &Tag = TAG_MAP.get("walk - knife");
|
||||
const KNIFE_JUMP: &Tag = TAG_MAP.get("jump - knife");
|
||||
const KNIFE_ATTACK: &Tag = TAG_MAP.get("attack - knife");
|
||||
const KNIFE_JUMP_ATTACK: &Tag = TAG_MAP.get("jump attack - knife");
|
||||
static KNIFE_IDLE: &Tag = TAG_MAP.get("idle - knife");
|
||||
static KNIFE_WALK: &Tag = TAG_MAP.get("walk - knife");
|
||||
static KNIFE_JUMP: &Tag = TAG_MAP.get("jump - knife");
|
||||
static KNIFE_ATTACK: &Tag = TAG_MAP.get("attack - knife");
|
||||
static KNIFE_JUMP_ATTACK: &Tag = TAG_MAP.get("jump attack - knife");
|
||||
|
||||
const SWORDLESS_IDLE: &Tag = TAG_MAP.get("idle swordless");
|
||||
const SWORDLESS_WALK: &Tag = TAG_MAP.get("walk swordless");
|
||||
const SWORDLESS_JUMP: &Tag = TAG_MAP.get("jump swordless");
|
||||
const SWORDLESS_ATTACK: &Tag = KNIFE_ATTACK;
|
||||
const SWORDLESS_JUMP_ATTACK: &Tag = KNIFE_JUMP_ATTACK;
|
||||
static SWORDLESS_IDLE: &Tag = TAG_MAP.get("idle swordless");
|
||||
static SWORDLESS_WALK: &Tag = TAG_MAP.get("walk swordless");
|
||||
static SWORDLESS_JUMP: &Tag = TAG_MAP.get("jump swordless");
|
||||
static SWORDLESS_ATTACK: &Tag = KNIFE_ATTACK;
|
||||
static SWORDLESS_JUMP_ATTACK: &Tag = KNIFE_JUMP_ATTACK;
|
||||
|
||||
agb::include_background_gfx!(background, "53269a", background => deduplicate "gfx/background.aseprite");
|
||||
|
||||
|
@ -809,7 +809,7 @@ impl BatData {
|
|||
.unwrap_or(false);
|
||||
let should_damage = entity.collider().touches(player.entity.collider());
|
||||
|
||||
const BAT_IDLE: &Tag = TAG_MAP.get("bat");
|
||||
static BAT_IDLE: &Tag = TAG_MAP.get("bat");
|
||||
|
||||
match &mut self.bat_state {
|
||||
BatState::Idle => {
|
||||
|
@ -883,7 +883,7 @@ impl BatData {
|
|||
}
|
||||
}
|
||||
BatState::Dead => {
|
||||
const BAT_DEAD: &Tag = TAG_MAP.get("bat dead");
|
||||
static BAT_DEAD: &Tag = TAG_MAP.get("bat dead");
|
||||
let sprite = BAT_DEAD.sprite(0);
|
||||
let sprite = controller.sprite(sprite);
|
||||
|
||||
|
@ -950,7 +950,7 @@ impl SlimeData {
|
|||
self.sprite_offset = 0;
|
||||
}
|
||||
|
||||
const IDLE: &Tag = TAG_MAP.get("slime idle");
|
||||
static IDLE: &Tag = TAG_MAP.get("slime idle");
|
||||
|
||||
let sprite = IDLE.sprite(self.sprite_offset as usize / 16);
|
||||
let sprite = controller.sprite(sprite);
|
||||
|
@ -990,7 +990,7 @@ impl SlimeData {
|
|||
sfx.slime_boing();
|
||||
}
|
||||
|
||||
const CHASE: &Tag = TAG_MAP.get("Slime jump");
|
||||
static CHASE: &Tag = TAG_MAP.get("Slime jump");
|
||||
|
||||
let sprite = CHASE.sprite(frame as usize);
|
||||
let sprite = controller.sprite(sprite);
|
||||
|
@ -1021,7 +1021,7 @@ impl SlimeData {
|
|||
}
|
||||
SlimeState::Dead(count) => {
|
||||
if *count < 5 * 4 {
|
||||
const DEATH: &Tag = TAG_MAP.get("Slime death");
|
||||
static DEATH: &Tag = TAG_MAP.get("Slime death");
|
||||
let sprite = DEATH.sprite(*count as usize / 4);
|
||||
let sprite = controller.sprite(sprite);
|
||||
|
||||
|
@ -1074,7 +1074,7 @@ impl MiniFlameData {
|
|||
|
||||
self.sprite_offset += 1;
|
||||
|
||||
const ANGRY: &Tag = TAG_MAP.get("angry boss");
|
||||
static ANGRY: &Tag = TAG_MAP.get("angry boss");
|
||||
|
||||
match &mut self.state {
|
||||
MiniFlameState::Idle(frames) => {
|
||||
|
@ -1148,7 +1148,7 @@ impl MiniFlameData {
|
|||
instruction = UpdateInstruction::Remove;
|
||||
}
|
||||
|
||||
const DEATH: &Tag = TAG_MAP.get("angry boss dead");
|
||||
static DEATH: &Tag = TAG_MAP.get("angry boss dead");
|
||||
|
||||
let sprite = DEATH.animation_sprite(self.sprite_offset as usize / 12);
|
||||
let sprite = controller.sprite(sprite);
|
||||
|
@ -1209,7 +1209,7 @@ impl EmuData {
|
|||
self.sprite_offset = 0;
|
||||
}
|
||||
|
||||
const IDLE: &Tag = TAG_MAP.get("emu - idle");
|
||||
static IDLE: &Tag = TAG_MAP.get("emu - idle");
|
||||
|
||||
let sprite = IDLE.sprite(self.sprite_offset as usize / 16);
|
||||
let sprite = controller.sprite(sprite);
|
||||
|
@ -1256,7 +1256,7 @@ impl EmuData {
|
|||
sfx.emu_step();
|
||||
}
|
||||
|
||||
const WALK: &Tag = TAG_MAP.get("emu-walk");
|
||||
static WALK: &Tag = TAG_MAP.get("emu-walk");
|
||||
|
||||
let sprite = WALK.sprite(self.sprite_offset as usize / 2);
|
||||
let sprite = controller.sprite(sprite);
|
||||
|
@ -1311,7 +1311,7 @@ impl EmuData {
|
|||
instruction = UpdateInstruction::Remove;
|
||||
}
|
||||
|
||||
const DEATH: &Tag = TAG_MAP.get("emu - die");
|
||||
static DEATH: &Tag = TAG_MAP.get("emu - die");
|
||||
|
||||
let sprite = DEATH.animation_sprite(self.sprite_offset as usize / 4);
|
||||
let sprite = controller.sprite(sprite);
|
||||
|
@ -1345,10 +1345,10 @@ impl EnemyData {
|
|||
}
|
||||
|
||||
fn sprite(&self) -> &'static Sprite {
|
||||
const SLIME: &Tag = TAG_MAP.get("slime idle");
|
||||
const BAT: &Tag = TAG_MAP.get("bat");
|
||||
const MINI_FLAME: &Tag = TAG_MAP.get("angry boss");
|
||||
const EMU: &Tag = TAG_MAP.get("emu - idle");
|
||||
static SLIME: &Tag = TAG_MAP.get("slime idle");
|
||||
static BAT: &Tag = TAG_MAP.get("bat");
|
||||
static MINI_FLAME: &Tag = TAG_MAP.get("angry boss");
|
||||
static EMU: &Tag = TAG_MAP.get("emu - idle");
|
||||
match self {
|
||||
EnemyData::Slime(_) => SLIME.sprite(0),
|
||||
EnemyData::Bat(_) => BAT.sprite(0),
|
||||
|
@ -1436,7 +1436,7 @@ impl ParticleData {
|
|||
return UpdateInstruction::Remove;
|
||||
}
|
||||
|
||||
const DUST: &Tag = TAG_MAP.get("dust");
|
||||
static DUST: &Tag = TAG_MAP.get("dust");
|
||||
let sprite = DUST.sprite(*frame as usize / 3);
|
||||
let sprite = controller.sprite(sprite);
|
||||
|
||||
|
@ -1450,7 +1450,7 @@ impl ParticleData {
|
|||
return UpdateInstruction::Remove; // have played the animation 6 times
|
||||
}
|
||||
|
||||
const HEALTH: &Tag = TAG_MAP.get("Heath");
|
||||
static HEALTH: &Tag = TAG_MAP.get("Heath");
|
||||
let sprite = HEALTH.animation_sprite(*frame as usize / 3);
|
||||
let sprite = controller.sprite(sprite);
|
||||
|
||||
|
@ -1476,7 +1476,7 @@ impl ParticleData {
|
|||
UpdateInstruction::None
|
||||
}
|
||||
ParticleData::BossHealer(frame, target) => {
|
||||
const HEALTH: &Tag = TAG_MAP.get("Heath");
|
||||
static HEALTH: &Tag = TAG_MAP.get("Heath");
|
||||
let sprite = HEALTH.animation_sprite(*frame as usize / 3);
|
||||
let sprite = controller.sprite(sprite);
|
||||
|
||||
|
@ -1633,7 +1633,7 @@ impl<'a> FollowingBoss<'a> {
|
|||
self.timer / 16
|
||||
};
|
||||
|
||||
const BOSS: &Tag = TAG_MAP.get("happy boss");
|
||||
static BOSS: &Tag = TAG_MAP.get("happy boss");
|
||||
|
||||
let sprite = BOSS.animation_sprite(frame as usize);
|
||||
let sprite = controller.sprite(sprite);
|
||||
|
@ -1766,7 +1766,7 @@ impl<'a> Boss<'a> {
|
|||
self.timer += 1;
|
||||
let frame = self.timer / animation_rate;
|
||||
|
||||
const BOSS: &Tag = TAG_MAP.get("Boss");
|
||||
static BOSS: &Tag = TAG_MAP.get("Boss");
|
||||
|
||||
let sprite = BOSS.animation_sprite(frame as usize);
|
||||
let sprite = object_controller.sprite(sprite);
|
||||
|
@ -2192,7 +2192,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 = background::background.tiles;
|
||||
let tileset = &background::background.tiles;
|
||||
let object = gba.display.object.get_managed();
|
||||
|
||||
loop {
|
||||
|
@ -2204,7 +2204,7 @@ fn game_with_level(gba: &mut agb::Gba) {
|
|||
),
|
||||
Box::new(|pos| {
|
||||
(
|
||||
&tileset,
|
||||
tileset,
|
||||
background::background.tile_settings[*tilemap::BACKGROUND_MAP
|
||||
.get((pos.x + tilemap::WIDTH * pos.y) as usize)
|
||||
.unwrap_or(&0)
|
||||
|
@ -2221,7 +2221,7 @@ fn game_with_level(gba: &mut agb::Gba) {
|
|||
),
|
||||
Box::new(|pos| {
|
||||
(
|
||||
&tileset,
|
||||
tileset,
|
||||
background::background.tile_settings[*tilemap::FOREGROUND_MAP
|
||||
.get((pos.x + tilemap::WIDTH * pos.y) as usize)
|
||||
.unwrap_or(&0)
|
||||
|
@ -2238,7 +2238,7 @@ fn game_with_level(gba: &mut agb::Gba) {
|
|||
),
|
||||
Box::new(|pos| {
|
||||
(
|
||||
&tileset,
|
||||
tileset,
|
||||
background::background.tile_settings[*tilemap::CLOUD_MAP
|
||||
.get((pos.x + tilemap::WIDTH * pos.y) as usize)
|
||||
.unwrap_or(&0)
|
||||
|
|
|
@ -2,28 +2,28 @@ use agb::fixnum::num;
|
|||
use agb::rng;
|
||||
use agb::sound::mixer::{ChannelId, Mixer, SoundChannel};
|
||||
|
||||
const BAT_DEATH: &[u8] = agb::include_wav!("sfx/BatDeath.wav");
|
||||
const BAT_FLAP: &[u8] = agb::include_wav!("sfx/BatFlap.wav");
|
||||
const JUMP1: &[u8] = agb::include_wav!("sfx/Jump1.wav");
|
||||
const JUMP2: &[u8] = agb::include_wav!("sfx/Jump2.wav");
|
||||
const JUMP3: &[u8] = agb::include_wav!("sfx/Jump3.wav");
|
||||
const PLAYER_GETS_HIT: &[u8] = agb::include_wav!("sfx/PlayerGetsHit.wav");
|
||||
const PLAYER_HEAL: &[u8] = agb::include_wav!("sfx/PlayerHeal.wav");
|
||||
const PLAYER_LANDS: &[u8] = agb::include_wav!("sfx/PlayerLands.wav");
|
||||
const SLIME_BOING: &[u8] = agb::include_wav!("sfx/SlimeBoing.wav");
|
||||
const SLIME_DEATH: &[u8] = agb::include_wav!("sfx/SlimeDeath.wav");
|
||||
const SWORD_SWING: &[u8] = agb::include_wav!("sfx/SwordSwing.wav");
|
||||
const FLAME_CHARGE: &[u8] = agb::include_wav!("sfx/FlameCharge.wav");
|
||||
const BOSS_FLAME_MOVE: &[u8] = agb::include_wav!("sfx/FlameMove.wav");
|
||||
const BURNING_FLAME: &[u8] = agb::include_wav!("sfx/Burning.wav");
|
||||
static BAT_DEATH: &[u8] = agb::include_wav!("sfx/BatDeath.wav");
|
||||
static BAT_FLAP: &[u8] = agb::include_wav!("sfx/BatFlap.wav");
|
||||
static JUMP1: &[u8] = agb::include_wav!("sfx/Jump1.wav");
|
||||
static JUMP2: &[u8] = agb::include_wav!("sfx/Jump2.wav");
|
||||
static JUMP3: &[u8] = agb::include_wav!("sfx/Jump3.wav");
|
||||
static PLAYER_GETS_HIT: &[u8] = agb::include_wav!("sfx/PlayerGetsHit.wav");
|
||||
static PLAYER_HEAL: &[u8] = agb::include_wav!("sfx/PlayerHeal.wav");
|
||||
static PLAYER_LANDS: &[u8] = agb::include_wav!("sfx/PlayerLands.wav");
|
||||
static SLIME_BOING: &[u8] = agb::include_wav!("sfx/SlimeBoing.wav");
|
||||
static SLIME_DEATH: &[u8] = agb::include_wav!("sfx/SlimeDeath.wav");
|
||||
static SWORD_SWING: &[u8] = agb::include_wav!("sfx/SwordSwing.wav");
|
||||
static FLAME_CHARGE: &[u8] = agb::include_wav!("sfx/FlameCharge.wav");
|
||||
static BOSS_FLAME_MOVE: &[u8] = agb::include_wav!("sfx/FlameMove.wav");
|
||||
static BURNING_FLAME: &[u8] = agb::include_wav!("sfx/Burning.wav");
|
||||
|
||||
const EMU_CRASH: &[u8] = agb::include_wav!("sfx/EmuCrash.wav");
|
||||
const EMU_STEP: &[u8] = agb::include_wav!("sfx/EmuStep.wav");
|
||||
const EMU_DEATH: &[u8] = agb::include_wav!("sfx/EmuDeath.wav");
|
||||
static EMU_CRASH: &[u8] = agb::include_wav!("sfx/EmuCrash.wav");
|
||||
static EMU_STEP: &[u8] = agb::include_wav!("sfx/EmuStep.wav");
|
||||
static EMU_DEATH: &[u8] = agb::include_wav!("sfx/EmuDeath.wav");
|
||||
|
||||
const PURPLE_NIGHT: &[u8] = agb::include_wav!("sfx/01 - The Purple Night (Main Loop).wav");
|
||||
const SUNRISE: &[u8] = agb::include_wav!("sfx/02 - Sunrise (Main Loop).wav");
|
||||
const BLUE_SPIRIT: &[u8] = agb::include_wav!("sfx/03 - Blue Spirit (Main Loop).wav");
|
||||
static PURPLE_NIGHT: &[u8] = agb::include_wav!("sfx/01 - The Purple Night (Main Loop).wav");
|
||||
static SUNRISE: &[u8] = agb::include_wav!("sfx/02 - Sunrise (Main Loop).wav");
|
||||
static BLUE_SPIRIT: &[u8] = agb::include_wav!("sfx/03 - Blue Spirit (Main Loop).wav");
|
||||
|
||||
pub struct Sfx<'a> {
|
||||
bgm: Option<ChannelId>,
|
||||
|
|
|
@ -94,11 +94,11 @@ impl<'a> quote::ToTokens for Track<'a> {
|
|||
|
||||
tokens.append_all(quote! {
|
||||
{
|
||||
const SAMPLES: &[agb_tracker::__private::agb_tracker_interop::Sample<'static>] = &[#(#samples),*];
|
||||
const PATTERN_DATA: &[agb_tracker::__private::agb_tracker_interop::PatternSlot] = &[#(#pattern_data),*];
|
||||
const PATTERNS: &[agb_tracker::__private::agb_tracker_interop::Pattern] = &[#(#patterns),*];
|
||||
const PATTERNS_TO_PLAY: &[usize] = &[#(#patterns_to_play),*];
|
||||
const ENVELOPES: &[agb_tracker::__private::agb_tracker_interop::Envelope<'static>] = &[#(#envelopes),*];
|
||||
static SAMPLES: &[agb_tracker::__private::agb_tracker_interop::Sample<'static>] = &[#(#samples),*];
|
||||
static PATTERN_DATA: &[agb_tracker::__private::agb_tracker_interop::PatternSlot] = &[#(#pattern_data),*];
|
||||
static PATTERNS: &[agb_tracker::__private::agb_tracker_interop::Pattern] = &[#(#patterns),*];
|
||||
static PATTERNS_TO_PLAY: &[usize] = &[#(#patterns_to_play),*];
|
||||
static ENVELOPES: &[agb_tracker::__private::agb_tracker_interop::Envelope<'static>] = &[#(#envelopes),*];
|
||||
|
||||
agb_tracker::Track {
|
||||
samples: SAMPLES,
|
||||
|
@ -149,7 +149,7 @@ impl quote::ToTokens for Envelope<'_> {
|
|||
|
||||
tokens.append_all(quote! {
|
||||
{
|
||||
const AMOUNTS: &[agb_tracker::__private::Num<i16, 8>] = &[#(#amount),*];
|
||||
static AMOUNTS: &[agb_tracker::__private::Num<i16, 8>] = &[#(#amount),*];
|
||||
|
||||
agb_tracker::__private::agb_tracker_interop::Envelope {
|
||||
amount: AMOUNTS,
|
||||
|
@ -201,7 +201,7 @@ impl<'a> quote::ToTokens for Sample<'a> {
|
|||
#[repr(align(4))]
|
||||
struct AlignmentWrapper<const N: usize>([u8; N]);
|
||||
|
||||
const SAMPLE_DATA: &[u8] = &AlignmentWrapper(*#samples).0;
|
||||
static SAMPLE_DATA: &[u8] = &AlignmentWrapper(*#samples).0;
|
||||
agb_tracker::__private::agb_tracker_interop::Sample {
|
||||
data: SAMPLE_DATA,
|
||||
should_loop: #should_loop,
|
||||
|
|
|
@ -6,7 +6,7 @@ use agb::Gba;
|
|||
use agb_tracker::{include_xm, Track, Tracker};
|
||||
|
||||
// Found on: https://modarchive.org/index.php?request=view_by_moduleid&query=36662
|
||||
const DB_TOFFE: Track = include_xm!("examples/db_toffe.xm");
|
||||
static DB_TOFFE: Track = include_xm!("examples/db_toffe.xm");
|
||||
|
||||
#[agb::entry]
|
||||
fn main(mut gba: Gba) -> ! {
|
||||
|
|
|
@ -6,7 +6,7 @@ use agb::Gba;
|
|||
use agb_tracker::{include_xm, Track, Tracker};
|
||||
|
||||
// Found on: https://modarchive.org/index.php?request=view_by_moduleid&query=36662
|
||||
const DB_TOFFE: Track = include_xm!("examples/db_toffe.xm");
|
||||
static DB_TOFFE: Track = include_xm!("examples/db_toffe.xm");
|
||||
|
||||
#[agb::entry]
|
||||
fn main(mut gba: Gba) -> ! {
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
//! use agb::{Gba, sound::mixer::Frequency};
|
||||
//! use agb_tracker::{include_xm, Track, Tracker};
|
||||
//!
|
||||
//! const DB_TOFFE: Track = include_xm!("examples/db_toffe.xm");
|
||||
//! static DB_TOFFE: Track = include_xm!("examples/db_toffe.xm");
|
||||
//!
|
||||
//! #[agb::entry]
|
||||
//! fn main(mut gba: Gba) -> ! {
|
||||
|
|
|
@ -502,7 +502,7 @@ fn note_to_frequency_amega(note: Note, fine_tune: f64, relative_note: i8) -> f64
|
|||
8363.0 * 1712.0 / period
|
||||
}
|
||||
|
||||
const AMEGA_FREQUENCIES: &[u32] = &[
|
||||
static AMEGA_FREQUENCIES: &[u32] = &[
|
||||
907, 900, 894, 887, 881, 875, 868, 862, 856, 850, 844, 838, 832, 826, 820, 814, 808, 802, 796,
|
||||
791, 785, 779, 774, 768, 762, 757, 752, 746, 741, 736, 730, 725, 720, 715, 709, 704, 699, 694,
|
||||
689, 684, 678, 675, 670, 665, 660, 655, 651, 646, 640, 636, 632, 628, 623, 619, 614, 610, 604,
|
||||
|
|
Loading…
Reference in a new issue