/******************************************************************************
*
* Copyright (C) 2006-2017  Brian Berlin
* 
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>
*
******************************************************************************
*
* FILENAME: media.h
*
* DESCRIPTION:  This contains function declarations for image handling
*
* AUTHORS:  bberlin
*
* CHANGE LOG
*
*  VER     DATE     CHANGED BY   DESCRIPTION OF CHANGE
* ------  --------  ----------   ------------------------------------
* 0.5.0   02/01/06  bberlin      Creation, break out from config
******************************************************************************/
#ifndef media_if_h
#define media_if_h

#include "../core/console.h"
#include "../core/cart.h"
#include "../core/sio.h"
#include "../core/media.h"
#include "../core/memory.h"

#define MEDIA_SCAN_MEDIA 0x01
#define MEDIA_SCAN_BIOS  0x02
#define MEDIA_SCAN_SUBS  0x04

#define MEDIA_LIST "list"
#define MEDIA_LIST_AVAILABLE "list-available"

typedef struct {
    e_machine_type type;
    char *directory;
    int flags;
    int progress;
    /* Optional phase label shown beside the progress count (e.g. "Downloading",
       "Extracting").  NULL falls back to "Files Scanned".  Points at a string
       literal owned by the producer; no allocation. */
    const char *progress_label;
} t_media_scan;

/*
 * Function Declarations
 */
int media_if_init ( void );
char * media_if_get_profile_from_crc ( unsigned long crc );
char * media_if_get_profile_from_crc_with_machine ( unsigned long crc,
        e_machine_type *origin_machine );
int media_if_create_profile_from_crc ( unsigned long crc, t_media *p_media );
int media_if_delete_crc ( unsigned long crc );
t_media *media_if_get_ptr ( void );
int media_if_get_mapping_from_string ( const char *mapping );
char * media_if_get_string_from_mapping ( int mapping );
int media_if_get_media_type_from_string ( char *media_type );
char * media_if_get_string_from_media_type ( int media_type );
int media_if_clear_filenames ( e_machine_type type );
int media_if_create_from_file ( char *file, t_media *cart );
int media_if_create_cart_from_file ( char *file, t_media *cart );
int media_if_scan_for_bios ( char *directory, int scan_subs );
int media_if_scan_directory ( t_media_scan *scan_params );
int media_if_bios_check ( int reset, unsigned long crc, const char *filename );
int media_if_open_rom ( char *filename, int media_type, int slot, int launch );
int media_if_open_file ( char *filename, unsigned char **buffer );

#endif
