/******************************************************************************
*
* 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: pia.h
*
* DESCRIPTION:  This contains function declarations for Port I/O functions
*
* AUTHORS:  bberlin
*
* CHANGE LOG
*
*  VER     DATE     CHANGED BY   DESCRIPTION OF CHANGE
* ------  --------  ----------   ------------------------------------
* 0.5.0   01/24/07  bberlin      Creation
******************************************************************************/
#ifndef pia_h
#define pia_h

#include "boom6502.h"

/*
 * PIA Registers
 */
#define PORTA   0x00
#define PORTB   0x01
#define PACTL   0x02
#define PBCTL   0x03

typedef struct {
    KBYTE port_control[2];
    KBYTE port_value[2];
    KBYTE input[2];
    KBYTE direction[2];
    int key_pressed[4][4][3];
} t_pia;

void pia_reset ( void );
KBYTE pia_read_register ( KWORD addr );
void pia_write_register ( KWORD addr, KBYTE value );
KBYTE pia_read_register_debug ( KWORD addr );
void pia_write_register_debug ( KWORD addr, KBYTE value );
void pia_recall_port_registers ( KWORD addr, KBYTE value );
void pia_set_input ( int player, int mask, KBYTE value );
void pia_set_keypad_down ( int player, int key, int down );
void pia_set_keypad_column ( int player );

#endif
