##-----------------------------LICENSE NOTICE------------------------------------
##  This file is part of CPCtelera: An Amstrad CPC Game Engine 
##  Copyright (C) 2018 ronaldo / Fremos / Cheesetea / ByteRealms (@FranGallegoBR)
##
##  This program is free software: you can redistribute it and/or modify
##  it under the terms of the GNU Lesser General Public License as published by
##  the Free Software Foundation, either version 3 of the License, or
##  (at your option) any later version.
##
##  This program is distributed in the hope that it will be useful,
##  but WITHOUT ANY WARRANTY; without even the implied warranty of
##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##  GNU Lesser General Public License for more details.
##
##  You should have received a copy of the GNU Lesser General Public License
##  along with this program.  If not, see <http://www.gnu.org/licenses/>.
##------------------------------------------------------------------------------
############################################################################
##                        CPCTELERA ENGINE                                ##
##                 Automatic compression utilities                        ##
##------------------------------------------------------------------------##
## This file is intended for users to automate the generation of          ##
## compressed files and their inclusion in users' projects.               ##
############################################################################

## COMPRESSION EXAMPLE (Uncomment lines to use)
##

## First 3 calls to ADD2PACK add enemy, hero and background
## graphics (previously converted to binary data) into the 
## compressed group 'mygraphics'. After that, call to PACKZX7B
## compresses all the data and generates an array with the result
## that is placed in src/mygraphics.c & src/mygraphics.h, ready
## to be included and used by other modules.
##
#$(eval $(call ADD2PACK,mygraphics,gfx/enemy.bin))
#$(eval $(call ADD2PACK,mygraphics,gfx/hero.bin))
#$(eval $(call ADD2PACK,mygraphics,gfx/background.bin))
#$(eval $(call PACKZX7B,mygraphics,src/))

# WORLD 1
$(eval $(call ADD2PACK,world1_pack, src/worlds/world1_1.bin))
$(eval $(call ADD2PACK,world1_pack, src/worlds/world1_2.bin))
$(eval $(call ADD2PACK,world1_pack, src/worlds/world1_3.bin))
$(eval $(call ADD2PACK,world1_pack, src/worlds/world1_4.bin))
$(eval $(call ADD2PACK,world1_pack, src/worlds/world1_5.bin))
$(eval $(call ADD2PACK,world1_pack, src/worlds/world1_6.bin))
$(eval $(call ADD2PACK,world1_pack, src/worlds/world1_7.bin))
$(eval $(call ADD2PACK,world1_pack, src/worlds/world1_8.bin))
$(eval $(call ADD2PACK,world1_pack, src/worlds/world1_9.bin))
$(eval $(call ADD2PACK,world1_pack, src/worlds/world1_10.bin))
$(eval $(call PACKZX7B,world1_pack, src/worlds))

# WORLD 2
$(eval $(call ADD2PACK,world2_pack, src/worlds/world2_1.bin))
$(eval $(call ADD2PACK,world2_pack, src/worlds/world2_2.bin))
$(eval $(call ADD2PACK,world2_pack, src/worlds/world2_3.bin))
$(eval $(call ADD2PACK,world2_pack, src/worlds/world2_4.bin))
$(eval $(call ADD2PACK,world2_pack, src/worlds/world2_5.bin))
$(eval $(call ADD2PACK,world2_pack, src/worlds/world2_6.bin))
$(eval $(call ADD2PACK,world2_pack, src/worlds/world2_7.bin))
$(eval $(call ADD2PACK,world2_pack, src/worlds/world2_8.bin))
$(eval $(call ADD2PACK,world2_pack, src/worlds/world2_9.bin))
$(eval $(call ADD2PACK,world2_pack, src/worlds/world2_10.bin))
$(eval $(call PACKZX7B,world2_pack, src/worlds))

# WORLD 3
$(eval $(call ADD2PACK,world3_pack, src/worlds/world3_1.bin))
$(eval $(call ADD2PACK,world3_pack, src/worlds/world3_2.bin))
$(eval $(call ADD2PACK,world3_pack, src/worlds/world3_3.bin))
$(eval $(call ADD2PACK,world3_pack, src/worlds/world3_4.bin))
$(eval $(call ADD2PACK,world3_pack, src/worlds/world3_5.bin))
$(eval $(call ADD2PACK,world3_pack, src/worlds/world3_6.bin))
$(eval $(call ADD2PACK,world3_pack, src/worlds/world3_7.bin))
$(eval $(call ADD2PACK,world3_pack, src/worlds/world3_8.bin))
$(eval $(call ADD2PACK,world3_pack, src/worlds/world3_9.bin))
$(eval $(call ADD2PACK,world3_pack, src/worlds/world3_10.bin))
$(eval $(call PACKZX7B,world3_pack, src/worlds))

# LOBBY
$(eval $(call ADD2PACK,lobby0_pack, src/worlds/lobby0.bin))
$(eval $(call PACKZX7B,lobby0_pack, src/worlds))
$(eval $(call ADD2PACK,lobby1_pack, src/worlds/lobby1.bin))
$(eval $(call PACKZX7B,lobby1_pack, src/worlds))
$(eval $(call ADD2PACK,lobby2_pack, src/worlds/lobby2.bin))
$(eval $(call PACKZX7B,lobby2_pack, src/worlds))
$(eval $(call ADD2PACK,lobby3_pack, src/worlds/lobby3.bin))
$(eval $(call PACKZX7B,lobby3_pack, src/worlds))

# MENU
$(eval $(call ADD2PACK,menu_pack, src/sprites/menu.bin))
$(eval $(call PACKZX7B,menu_pack, src/worlds))
$(eval $(call ADD2PACK,credits1_pack, src/sprites/credits1.bin))
$(eval $(call PACKZX7B,credits1_pack, src/worlds))
$(eval $(call ADD2PACK,credits2_pack, src/sprites/credits2.bin))
$(eval $(call PACKZX7B,credits2_pack, src/worlds))
$(eval $(call ADD2PACK,controls1_pack, src/sprites/controls1.bin))
$(eval $(call PACKZX7B,controls1_pack, src/worlds))
$(eval $(call ADD2PACK,controls2_pack, src/sprites/controls2.bin))
$(eval $(call PACKZX7B,controls2_pack, src/worlds))
$(eval $(call ADD2PACK,completed_l_pack, src/sprites/completed_l.bin))
$(eval $(call PACKZX7B,completed_l_pack, src/worlds))
$(eval $(call ADD2PACK,completed_w_pack, src/sprites/completed_w.bin))
$(eval $(call PACKZX7B,completed_w_pack, src/worlds))
$(eval $(call ADD2PACK,w1_pack, src/sprites/w1.bin))
$(eval $(call PACKZX7B,w1_pack, src/worlds))
$(eval $(call ADD2PACK,w2_pack, src/sprites/w2.bin))
$(eval $(call PACKZX7B,w2_pack, src/worlds))
$(eval $(call ADD2PACK,w3_pack, src/sprites/w3.bin))
$(eval $(call PACKZX7B,w3_pack, src/worlds))
$(eval $(call ADD2PACK,end_pack, src/sprites/end.bin))
$(eval $(call PACKZX7B,end_pack, src/worlds))


############################################################################
##              DETAILED INSTRUCTIONS AND PARAMETERS                      ##
##------------------------------------------------------------------------##
##                                                                        ##
## Macros used for compression are ADD2PACK and PACKZX7B:                 ##
##                                                                        ##
##	ADD2PACK: Adds files to packed (compressed) groups. Each call to this ##
##  		  macro will add a file to a named compressed group.          ##
##  PACKZX7B: Compresses all files in a group into a single binary and    ##
##            generates a C-array and a header to comfortably use it from ##
##            inside your code.                                           ##
##                                                                        ##
##------------------------------------------------------------------------##
##                                                                        ##
##  $(eval $(call ADD2PACK,<packname>,<file>))                            ##
##                                                                        ##
##		Sequentially adds <file> to compressed group <packname>. Each     ##
## call to this macro adds a new <file> after the latest one added.       ##
## packname could be any valid C identifier.                              ##
##                                                                        ##
##  Parameters:                                                           ##
##  (packname): Name of the compressed group where the file will be added ##
##  (file)    : File to be added at the end of the compressed group       ##
##                                                                        ##
##------------------------------------------------------------------------##
##                                                                        ##
##  $(eval $(call PACKZX7B,<packname>,<dest_path>))                       ##
##                                                                        ##
##		Compresses all files in the <packname> group using ZX7B algorithm ##
## and generates 2 files: <packname>.c and <packname>.h that contain a    ##
## C-array with the compressed data and a header file for declarations.   ##
## Generated files are moved to the folder <dest_path>.                   ##
##                                                                        ##
##  Parameters:                                                           ##
##  (packname) : Name of the compressed group to use for packing          ##
##  (dest_path): Destination path for generated output files              ##
##                                                                        ##
############################################################################
##                                                                        ##
## Important:                                                             ##
##  * Do NOT separate macro parameters with spaces, blanks or other chars.##
##    ANY character you put into a macro parameter will be passed to the  ##
##    macro. Therefore ...,src/sprites,... will represent "src/sprites"   ##
##    folder, whereas ...,  src/sprites,... means "  src/sprites" folder. ##
##  * You can omit parameters by leaving them empty.                      ##
##  * Parameters (4) and (5) are optional and generally not required.     ##
############################################################################
