This is a python tool that allows users to compress images and display them on an atari 8bit computer
atari.bmp works by generating a Pascal file, compiling it with mp and assembling with mads. There are two compression algorithms available, which i will explain in a later section of this Readme.
for educational purposes we will use this mig29 photo as our image.
python main.py -c rect readme/mig29.jpg
when user does not provide a graphical mode to use, the program will generate all options and prompt the user. You can find all of the generated images in the out/ directory.
here are the generated images
the images will look distorted because atari has non-square pixels
In this case i suppose that gr15 looks the best
choose version > 15
This generates the pascal file, and we can take a look inside.
There are 3 major segments. First, const data:
const
data_65fadaa9_1: array [0..2575] of byte = (<data>);
data_65fadaa9_2: array [0..2999] of byte = (<data>);
data_65fadaa9_0: array [0..859] of byte = (<data>);
the var name structure is data_<random_uuid>_<color>
Second important segment is procedure B
that contains a drawing function, and last we have loops that call this procedure. This is slightly different in the HLine compression mode.
Now, we have to compile this .pas file into an atari executable format like .obx
./Mad-Pascal/bin/mp image.pas -ipath:Mad-Pascal/lib -o:a.a65 -target:a8
this creates a.a65 which we can assemble
./Mad-Assembler/mads a.a65 -x -i:Mad-Pascal/base
I recommend emulating an atari800 xl using this emulator. It's available in APT and AUR, but any other emulator will do.
atari800 -xl -run a.obx
You can also copy this obx file onto a SDRIVE device
- Rectangle matching
- layerizing the image into single-color images
- sorting layers by amount of set pixels
- finding largest possible rectangles on each layer and removing them
- drawing rectangles using individual HLines from mad-pascal's fastgraph library
this compression mode was first using pascal's Bar() procedure, but later i found fastgraph and decided to port the pascal part to it. It achieves suprisingly good drawing speeds with a decent compression ratio
- HLine matching
- layerize and sort as above
- from left to right and layer by layer find horizontal lines with the same color
- denote line breaks (Y increments) using a coordinate = width+1.
- replace multiple empty lines with a (width+2, lines) pair, and remove the redundant width+1 pairs
- pass coordinate pointers to a pascal procedure that also uses HLine
- fpc compiler for tebe6502's tools
- python3
- python3-venv is very recommended, and without it cv2 cnstallation is problematic
Clone this repo with submodule recursion
git clone --recurse-submodules https://github.com/jj15warrior/atari.bmp
cd atari.bmp
Make the build tools
make all
Enable venv and install requirements:
python -m venv .
source bin/activate
pip install -r requirements.txt
note: depending on your shell you will have to use other bin/activate files. For fish it's:
source bin/activate.fish
etc.
python main.py -c <algo> -g <grmode> [file1] [file2] ...
note: multi-file compression is not supported at the moment. You can however hack together two pascal scripts because of uuids used to match data to programs
For help, DM jj15 on discord