Skip to content

Commit

Permalink
modify asm command into multiple commands, add ability to create new …
Browse files Browse the repository at this point in the history
…blank fat32 images
  • Loading branch information
yeastplume committed Feb 21, 2020
1 parent 7ca67d5 commit d926c91
Show file tree
Hide file tree
Showing 23 changed files with 272 additions and 28 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/ex_001.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Now we have a palette imported, ready for future operations. But first let's tak
The ultimate output of Aloevera is assembled data ready for inclusion by popular assemblers or concatenated into a BASIC program. This is done with the `asm` command as follows:

```.sh
aloevera -p project.av asm ./output
aloevera -p project.av asm ./output all
```

This assembles all the resources in the project file (which in this example is only a palette), and places them into the target directory in the order in which they were included. There should now be a directory `output` which should contain a `palette` directory that contains a single file with the ID of the palette we imported earlier, that is to say `palette_1.ca65.inc`. Let's look at the contents of this file:
Expand Down Expand Up @@ -130,7 +130,7 @@ To make it simpler to play around with VERA concepts, Aloevera can also 'assembl
To assemble data into basic, use the `--format, -f` command with the `asm` command as follows:

```.sh
aloevera -p project.av asm -f basic ./output
aloevera -p project.av asm -f basic ./output all
```

This will create a file called `./output/palettes/palette_1.basic.inc`, that looks much like this:
Expand Down
2 changes: 1 addition & 1 deletion docs/ex_002.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Then, it uses the `imageset import` command to import the `pixel-font.png` file
Just for the same of example, let's try and do something with this Imageset, like assemble it.

```.sh
aloevera -p project.av asm ./output
aloevera -p project.av asm ./output all
```

This should result in an error.
Expand Down
4 changes: 2 additions & 2 deletions docs/ex_005.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ aloevera -p project.av palette import terra_pal terra.png
aloevera -p project.av imageset import terra_imageset 16 32 terra.png
aloevera -p project.av imageset format terra_imageset terra_pal 4
aloevera -p project.av sprite init terra_sprite terra_imageset
aloevera -p project.av asm ./output/
aloevera -p project.av asm -f basic ./output/
aloevera -p project.av asm ./output/ all
aloevera -p project.av asm -f basic ./output/ all
```

During our `imageset import` command, we've specified the frame width and height. Unlike Tilemaps, acceptable values for Sprite frame widths and height are 8, 16, 32 and 64 pixels. Further, Sprites can only be 4 or 8 BPP, there's no 2BPP mode (again, differing from Tilemaps). Sprites also need to have their intended palette offsets specified at programming time, whereas Tilemaps contain per-tile palette offsets in each entry.
Expand Down
2 changes: 1 addition & 1 deletion docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ All Aloevera concepts and commands are explored and illustrated via a series of
### [Example 3: Simple Tilemaps - Displaying a custom banner](./ex_003.md)
### [Example 4: Higher Depth Tilemaps - A more game-like tilemap](./ex_004.md)
### [Example 5: Sprites](./ex_005.md)
### [Example 6: Bitmaps](./ex_006.md)
### [Example 6: Bitmaps](./ex_006.md)
4 changes: 2 additions & 2 deletions samples/bitmap/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ project.av: $(RESOURCES)
$(ALOEVERA) -p project.av imageset import kq5_screen 320 100 kq5-halved.png
$(ALOEVERA) -p project.av imageset format kq5_screen kq5_pal 8
$(ALOEVERA) -p project.av bitmap init kq5_bmp kq5_screen
$(ALOEVERA) -p project.av asm ./output/
$(ALOEVERA) -p project.av asm -f basic ./output/
$(ALOEVERA) -p project.av asm ./output/ all
$(ALOEVERA) -p project.av asm -f basic ./output/ all

generate_resources: project.av

Expand Down
4 changes: 2 additions & 2 deletions samples/palette/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ RESOURCES = nes-palette.png
project.av: $(RESOURCES)
$(ALOEVERA) create project project.av
$(ALOEVERA) -p project.av palette import palette_1 nes-palette.png
$(ALOEVERA) -p project.av asm ./output/
$(ALOEVERA) -p project.av asm -f basic ./output/
$(ALOEVERA) -p project.av asm ./output/ all
$(ALOEVERA) -p project.av asm -f basic ./output/ all

generate_resources: project.av

Expand Down
4 changes: 2 additions & 2 deletions samples/scratch/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ project.av:
# $(ALOEVERA) -p project.gx16 palette import palette_1 pixel-font.png
# $(ALOEVERA) -p project.gx16 imageset import text_set_1 8 8 pixel-font.png
# $(ALOEVERA) -p project.gx16 imageset format text_set_1 palette_1 1
# $(ALOEVERA) -p project.gx16 asm ./output/
# $(ALOEVERA) -p project.gx16 asm -f basic ./output/
# $(ALOEVERA) -p project.gx16 asm ./output/ all
# $(ALOEVERA) -p project.gx16 asm -f basic ./output/ all

generate_resources: project.av

Expand Down
6 changes: 3 additions & 3 deletions samples/sprites/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ project.av: $(RESOURCES)
$(ALOEVERA) -p project.av imageset import terra_imageset 16 32 terra.png
$(ALOEVERA) -p project.av imageset format terra_imageset terra_pal 4
$(ALOEVERA) -p project.av sprite init terra_sprite terra_imageset
$(ALOEVERA) -p project.av asm ./output/
$(ALOEVERA) -p project.av asm -f basic ./output/
$(ALOEVERA) -p project.av asm -f bin ./output/
$(ALOEVERA) -p project.av asm ./output/ all
$(ALOEVERA) -p project.av asm -f basic ./output/ all
$(ALOEVERA) -p project.av asm -f bin ./output/ all

generate_resources: project.av

Expand Down
4 changes: 2 additions & 2 deletions samples/tile_text/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ project.av: $(RESOURCES)
$(ALOEVERA) -p project.av tilemap init tilemap_1 text_set_1 128 64 text_16
$(ALOEVERA) -p project.av palette import palette_tilemap tilemap-banner-1bpp.png
$(ALOEVERA) -p project.av tilemap load -p palette_tilemap -x 1 -y 10 -c 6 tilemap_1 tilemap-banner-1bpp.png
$(ALOEVERA) -p project.av asm ./output/
$(ALOEVERA) -p project.av asm -f basic ./output/
$(ALOEVERA) -p project.av asm ./output/ all
$(ALOEVERA) -p project.av asm -f basic ./output/ all

generate_resources: project.av

Expand Down
4 changes: 2 additions & 2 deletions samples/tile_wall/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ project.av: $(RESOURCES)
$(ALOEVERA) -p project.av imageset format wall_tiles tile_wall_pal 4
$(ALOEVERA) -p project.av tilemap init wall_tilemap wall_tiles 64 32 tile_4bpp
$(ALOEVERA) -p project.av tilemap load -x 0 -y 10 wall_tilemap tile_wall-map.png
$(ALOEVERA) -p project.av asm ./output/
$(ALOEVERA) -p project.av asm -f basic ./output/
$(ALOEVERA) -p project.av asm ./output/ all
$(ALOEVERA) -p project.av asm -f basic ./output/ all

generate_resources: project.av

Expand Down
4 changes: 4 additions & 0 deletions src/bin/aloevera.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ subcommands:
- bin
default_value: ca65
takes_value: true
- sd_image:
help: If provided, output assets into the given FAT32 Image file instead of the local filesystem
subcommands:
- all: Export all assets in the project file
- palette:
about: Import and manipulate palette files
subcommands:
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/asm/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ where
}

/// Assemble
pub fn asm(g_args: &GlobalArgs, args: &AsmArgs) -> Result<(), Error> {
pub fn asm_all(g_args: &GlobalArgs, args: &AsmArgs) -> Result<(), Error> {
let proj = common::load_project(g_args.project_file.clone())?;
// Todo: make this a flag?
//common::remove_dir(&args.out_dir)?;
Expand Down
15 changes: 14 additions & 1 deletion src/cmd/asm/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::str::FromStr;

use clap::ArgMatches;

use super::command::AsmArgs;
use super::command::{self, AsmArgs};
use crate::cmd::common::{self, GlobalArgs};
use crate::{Error, ErrorKind};

Expand All @@ -33,3 +33,16 @@ pub fn parse_asm_args(g_args: &GlobalArgs, args: &ArgMatches) -> Result<AsmArgs,
format: AsmFormat::from_str(asm_format)?,
})
}

pub fn execute_asm_command(g_args: &GlobalArgs, args: &ArgMatches) -> Result<(), Error> {
match args.subcommand() {
("all", Some(_a)) => {
let a = arg_parse!(parse_asm_args(g_args, args));
command::asm_all(g_args, &a)
}
_ => {
let msg = format!("Unknown sub command, use 'aloevera asm --help' for details");
return Err(ErrorKind::ArgumentError(msg).into());
}
}
}
5 changes: 2 additions & 3 deletions src/cmd/create/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use crate::Error;
use proj::{AloeVeraProject, Jsonable};
use util::fat;

/// Arguments for the initial create project command
pub struct CreateProjectArgs {
Expand Down Expand Up @@ -46,9 +47,7 @@ pub fn create_sd_image(args: &CreateSDImageArgs) -> Result<(), Error> {
args.output_file
);

/*let proj = AloeVeraProject::new(id);
let json = proj.to_json()?;*/
//crate::cmd::common::output_to_file(&args.output_file, &json.as_bytes())?;
fat::create_fat_image(&args.output_file)?;

Ok(())
}
5 changes: 1 addition & 4 deletions src/cmd/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ use crate::{Error, ErrorKind};

fn parse_and_execute(g_args: &GlobalArgs, args: &ArgMatches) -> Result<(), Error> {
match args.subcommand() {
("asm", Some(args)) => {
let a = arg_parse!(asm::parse::parse_asm_args(g_args, &args,));
asm::command::asm(g_args, &a)
}
("create", Some(args)) => create::parse::execute_create_command(&args),
("asm", Some(args)) => asm::parse::execute_asm_command(g_args, &args),
("palette", Some(args)) => palette::parse::execute_palette_command(g_args, &args),
("sprite", Some(args)) => sprite::parse::execute_sprite_command(g_args, &args),
("bitmap", Some(args)) => bitmap::parse::execute_bitmap_command(g_args, &args),
Expand Down
1 change: 1 addition & 0 deletions util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ walkdir = "2"
zip = { version = "0.5", default-features = false }
parking_lot = {version = "0.6"}
fatfs = "0.3"
flate2 = "1.0"
1 change: 1 addition & 0 deletions util/src/data/contents/CREATED_BY_ALOEVERA
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/yeastplume/aloevera
3 changes: 3 additions & 0 deletions util/src/data/create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
./dir2fat32.sh -f fat32_template.img 32 contents
gzip fat32_template.img
Loading

0 comments on commit d926c91

Please sign in to comment.