mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
Fix the combo rom (#507)
Previously amplitude could not be played! This will make sure that we don't mess up as easily as the old version.
This commit is contained in:
commit
4199e22c5e
|
@ -8,6 +8,7 @@ use alloc::boxed::Box;
|
||||||
|
|
||||||
use agb::{
|
use agb::{
|
||||||
display::{
|
display::{
|
||||||
|
tile_data::TileData,
|
||||||
tiled::{InfiniteScrolledMap, RegularBackgroundSize, TileFormat},
|
tiled::{InfiniteScrolledMap, RegularBackgroundSize, TileFormat},
|
||||||
Priority,
|
Priority,
|
||||||
},
|
},
|
||||||
|
@ -16,38 +17,27 @@ use agb::{
|
||||||
input::Button,
|
input::Button,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
type Game = fn(agb::Gba) -> !;
|
||||||
pub enum Game {
|
|
||||||
TheHatChoosesTheWizard,
|
struct GameWithTiles {
|
||||||
ThePurpleNight,
|
game: fn(agb::Gba) -> !,
|
||||||
HyperspaceRoll,
|
tiles: TileData,
|
||||||
TheDungeonPuzzlersLament,
|
|
||||||
Amplitude,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Game {
|
impl GameWithTiles {
|
||||||
fn launch_game(self, gba: agb::Gba) -> ! {
|
const fn new(tiles: TileData, game: fn(agb::Gba) -> !) -> Self {
|
||||||
match self {
|
GameWithTiles { game, tiles }
|
||||||
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),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn from_index(index: i32) -> Game {
|
|
||||||
match index.rem_euclid(4) {
|
|
||||||
0 => Game::TheHatChoosesTheWizard,
|
|
||||||
1 => Game::ThePurpleNight,
|
|
||||||
2 => Game::HyperspaceRoll,
|
|
||||||
3 => Game::TheDungeonPuzzlersLament,
|
|
||||||
4 => Game::Amplitude,
|
|
||||||
_ => unreachable!("game out of index in an unreachable manner"),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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),
|
||||||
|
];
|
||||||
|
|
||||||
include_background_gfx!(
|
include_background_gfx!(
|
||||||
games, "121105",
|
games, "121105",
|
||||||
hat => 256 deduplicate "gfx/hat.png",
|
hat => 256 deduplicate "gfx/hat.png",
|
||||||
|
@ -63,14 +53,6 @@ fn get_game(gba: &mut agb::Gba) -> Game {
|
||||||
|
|
||||||
let (tile, mut vram) = gba.display.video.tiled0();
|
let (tile, mut vram) = gba.display.video.tiled0();
|
||||||
|
|
||||||
let tiles = [
|
|
||||||
games::hat,
|
|
||||||
games::purple,
|
|
||||||
games::hyperspace,
|
|
||||||
games::dungeon_puzzler,
|
|
||||||
games::amplitude,
|
|
||||||
];
|
|
||||||
|
|
||||||
vram.set_background_palettes(games::PALETTES);
|
vram.set_background_palettes(games::PALETTES);
|
||||||
|
|
||||||
let mut bg = InfiniteScrolledMap::new(
|
let mut bg = InfiniteScrolledMap::new(
|
||||||
|
@ -83,9 +65,12 @@ fn get_game(gba: &mut agb::Gba) -> Game {
|
||||||
let y = pos.y.rem_euclid(20);
|
let y = pos.y.rem_euclid(20);
|
||||||
let x = pos.x.rem_euclid(30);
|
let x = pos.x.rem_euclid(30);
|
||||||
|
|
||||||
let game = (pos.x).rem_euclid(tiles.len() as i32 * 30) as usize / 30;
|
let game = (pos.x).rem_euclid(GAMES.len() as i32 * 30) as usize / 30;
|
||||||
let tile_id = (y * 30 + x) as usize;
|
let tile_id = (y * 30 + x) as usize;
|
||||||
(&tiles[game].tiles, tiles[game].tile_settings[tile_id])
|
(
|
||||||
|
&GAMES[game].tiles.tiles,
|
||||||
|
GAMES[game].tiles.tile_settings[tile_id],
|
||||||
|
)
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -120,7 +105,7 @@ fn get_game(gba: &mut agb::Gba) -> Game {
|
||||||
input.update();
|
input.update();
|
||||||
|
|
||||||
if input.is_just_pressed(Button::A) {
|
if input.is_just_pressed(Button::A) {
|
||||||
break Game::from_index(game_idx);
|
break GAMES[game_idx.rem_euclid(GAMES.len() as i32) as usize].game;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -132,5 +117,5 @@ fn get_game(gba: &mut agb::Gba) -> Game {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main(mut gba: agb::Gba) -> ! {
|
pub fn main(mut gba: agb::Gba) -> ! {
|
||||||
get_game(&mut gba).launch_game(gba)
|
get_game(&mut gba)(gba)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue