/******************************************************************************
*
* Copyright (C) 2007-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: console.h
*
* DESCRIPTION:  This contains console struct and functions used in main
*
* AUTHORS:  bberlin
*
* CHANGE LOG
*
*  VER     DATE     CHANGED BY   DESCRIPTION OF CHANGE
* ------  --------  ----------   ------------------------------------
* 0.5.0   02/06/07  bberlin      Creation, breakout from main
******************************************************************************/
#ifndef console_h
#define console_h

#include "cart.h"
#include "boom6502.h"
#include "antic.h"
#include "gtia.h"
#include "pokey.h"
#include "pia.h"
#include "sio.h"

typedef enum {
    MACHINE_TYPE_MIN,
    MACHINE_TYPE_5200,
    MACHINE_TYPE_800,
    MACHINE_TYPE_XL,
} e_machine_type;

typedef enum {
    OS_TYPE_MIN,
    OS_TYPE_5200_4PORT,
    OS_TYPE_5200_2PORT,
    OS_TYPE_A,
    OS_TYPE_B,
    OS_TYPE_REV_10,
    OS_TYPE_REV_11,
    OS_TYPE_REV_1,
    OS_TYPE_REV_2,
    OS_TYPE_REV_3,
    OS_TYPE_REV_4,
    OS_TYPE_B_NTSC,
    OS_TYPE_B_PAL,
} e_os_type;

typedef enum {
    BASIC_TYPE_REV_A,
    BASIC_TYPE_REV_B,
    BASIC_TYPE_REV_C,
} e_basic_type;

typedef struct {
    t_cpu *cpu;
    t_antic *antic;
    t_gtia *gtia;
    t_pokey *pokey;
    t_pia *pia;
    t_sio_interface *sio;
    t_cart *cart;
    t_cart *cart_right;
    t_media *main_media;
    unsigned int frame_number;
    e_machine_type machine_type;
    int frames_per_sec;
    unsigned int scanlines;
    int tv_standard;
    int debug_mode;
    int throttle;
    int ram_size;
    int basic_enable;
    int option_key_pressed;
    int start_key_pressed;
} t_atari;

void console_init ( void );
void console_exit ( void );
void console_reset (e_machine_type type, int tv_standard, int ram);
t_atari * console_get_ptr ( void );
int console_open_media ( t_media *p_media, unsigned char *buffer, int sio_slot, 
        int launch );
void console_set_machine_type ( e_machine_type type );
e_machine_type console_get_machine_type ( void );
e_cart_type console_get_main_media_type ( t_atari *console, int *slot );
void console_set_main_media_from_type ( t_atari *console, e_cart_type type, int slot );
void console_set_throttle ( int throttle );
void console_set_debug_mode ( int debug_mode );
const char * console_get_machine_string ( e_machine_type type );
const char * console_get_os_string ( e_os_type type );
const char * console_get_tv_string ( int type );

#endif
