7 releases

0.2.2 Jul 16, 2024
0.2.1 Jul 16, 2024
0.2.0 Jun 30, 2024
0.1.3 Jun 29, 2024

#602 in Command line utilities

Unlicense

34KB
794 lines

cega

CGA/EGA (the graphics formats from 80s games) parsing with png/gif/etc output and colored terminal preview

github crates.io docs.rs Crates.io License: Unlicense

Warning

This is currently very much in an alpha state: apis and CLI arguments may still change heavily and the apis aren't documented. This file has decent usage examples below.

Roadmap/Upcoming

Priority

  • gif or png output (half the point of the whole library).
  • If I use image::DynamicImage there are additional encoders/decoders that will be free
  • Zooming/scaling (for png and gui output)
  • Additional EGA planar encodings
  • Map viewing (the other half): using the tile/spritesheets as palettes for larger images in psuedo CGA/EGA form (common in 80s games)
  • Outputting to CGA/EGA encodings - useful for making non copyrighted test format files to ship

Everything else

  • Document the code beyond a simple readme
  • Palettes beyond the defaults- cga from the full 16 and ega from the full 256.
  • Breaking the features back out now that I have a better understanding of the modules
  • More tests. Adding as I go, but as I learn rust more and understand the problem space better will make sense to do more
  • Full paletting from RGB(?A alpha support maybe)
  • Better terminal support - rascii for iterm/sixel/etc or ratitui for full tui (helpful for discovering formats) and scrollbars
  • Optimize terminal output (don't repeat active codes)

Great if I get to it, but a bit of a tangent

  • Train a model to recognize format and tiling patterns for smart discovery. I don't know how many test files I can get my hands on but I guess I could generate them

Binary/Terminal Usage

This can be used as a library or executable.

The binary handles arguments (and thus help) via clap 4

Usage: cega [OPTIONS] <IMAGE>

Arguments:
  <IMAGE>  

Options:
  -a, --ascii-mode <ASCII_MODE>      images will horizontally crop to terminal
                                     [possible values: a, c, p, h]
                                     a = plain ascii
                                     c = colored ascii
                                     p = full pixels via ansi bg color
                                     h = horizontal half pixels (UGLY)
  -p, --palette [<PALETTE>]          ega palette can be used for cga, but not the inverse
                                      [possible values: cga0, cga0i, cga1, cga1i, ega]
  -i, --image-parser <IMAGE_PARSER>  [default: cga] [possible values: ega_row_planar, erp, cga]
  -c, --custom-ascii <CUSTOM_ASCII>  4 or 16 chars palette like -a " +%0"
  -w, --width <WIDTH>                [default: 320]
  -m, --max-width <MAX_WIDTH>        used for wrapping rows if retiling with tile_height
  -o, --output-file <OUTPUT_FILE>    format based on extension - see image crate
  -t, --tile-height <TILE_HEIGHT>    
  -s, --sdl                          
  -q, --quiet                        
  -h, --help                         Print help
  -V, --version                      Print version

cega can parse output to png, and other formats.

cega can parse tiled/spritesheet style cga and output "pixels" to the terminal

cega ../../assets/game/CGATILES.BIN -w 16 -r 16 -i cga -t p:

cega ../../assets/game/CGATILES.BIN -w 16 -r 16 -i cga -t p

cega will output some suggestions, like if it's not a CGA fullscreen image, but you don't specify tiling:

cega ../../assets/game/CGATILES.BIN -t a:

cega ../../assets/game/CGATILES.BIN -t a

cega will ouput in different preview formats, such as colored ASCII or a gui window:

cega ../../assets/game/CGATILES.BIN -w 16 -r 16 -i cga -t c -c "1234" -s:

cega ../../assets/game/CGATILES.BIN -w 16 -r 16 -i cga -t c -c 1234 -s

Cargo features and library usage

default = ["terminal", "sdl2", "png"]
terminal = ["clap"]
png = ["image"]

Disabling terminal will skip the binary target Png feature is handled via image so includes that dep

Acknowledgements & References

Dependencies

~18MB
~384K SLoC