2
* ciacore.h - Template file for MOS6526 (CIA) emulation.
5
* Andr� Fachat <fachat@physik.tu-chemnitz.de>
6
* Ettore Perazzoli <ettore@comm2000.it>
7
* Andreas Boose <boose@rzgw.rz.fh-hannover.de>
9
* This file is part of VICE, the Versatile Commodore Emulator.
10
* See README for copyright notice.
12
* This program is free software; you can redistribute it and/or modify
13
* it under the terms of the GNU General Public License as published by
14
* the Free Software Foundation; either version 2 of the License, or
15
* (at your option) any later version.
17
* This program is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
* GNU General Public License for more details.
22
* You should have received a copy of the GNU General Public License
23
* along with this program; if not, write to the Free Software
24
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
39
#ifdef CIA_SHARED_CODE
40
#define CIA_CONTEXT_PARAM CIACONTEXT *ctxptr,
41
#define CIA_CONTEXT_PARVOID CIACONTEXT *ctxptr
42
#define CIA_CONTEXT_CALL ctxptr,
43
#define CIA_CONTEXT_CALLVOID ctxptr
44
#define CIARPARM1 REGPARM2
45
#define CIARPARM2 REGPARM3
47
#define CIA_CONTEXT_PARAM
48
#define CIA_CONTEXT_PARVOID void
49
#define CIA_CONTEXT_CALL
50
#define CIA_CONTEXT_CALLVOID
51
#define CIARPARM1 REGPARM1
52
#define CIARPARM2 REGPARM2
56
* Prototypes for the used inline functions
59
static inline void do_reset_cia(CIA_CONTEXT_PARVOID);
60
static inline void store_sdr(CIA_CONTEXT_PARAM BYTE byte);
61
static inline void read_ciaicr(CIA_CONTEXT_PARVOID);
62
static inline void store_ciapa(CIA_CONTEXT_PARAM CLOCK rclk, BYTE byte);
63
static inline void store_ciapb(CIA_CONTEXT_PARAM CLOCK rclk, BYTE byte);
64
static inline void pulse_ciapc(CIA_CONTEXT_PARAM CLOCK rclk);
65
static inline void undump_ciapa(CIA_CONTEXT_PARAM CLOCK rclk, BYTE byte);
66
static inline void undump_ciapb(CIA_CONTEXT_PARAM CLOCK rclk, BYTE byte);
67
static inline BYTE read_ciapa(CIA_CONTEXT_PARVOID);
68
static inline BYTE read_ciapb(CIA_CONTEXT_PARVOID);
71
#define STORE_OFFSET 1
74
#define CIAT_STOPPED 0
75
#define CIAT_RUNNING 1
76
#define CIAT_COUNTTA 2
79
* Local variable and prototypes - moved here because they're used by
80
* the inline functions
83
static void int_ciata(CIA_CONTEXT_PARAM CLOCK offset);
84
static void int_ciatb(CIA_CONTEXT_PARAM CLOCK offset);
85
static void int_ciatod(CIA_CONTEXT_PARAM CLOCK offset);
87
#ifndef CIA_SHARED_CODE
89
#define ciaier cia[CIA_ICR]
91
static int ciaint; /* Interrupt Flag register for cia 1 */
92
static CLOCK ciardi; /* real clock = clk-offset */
94
static unsigned int cia_tat; /* timer A toggle bit */
95
static unsigned int cia_tbt; /* timer B toggle bit */
97
static CLOCK cia_todclk; /* when is the next TOD alarm scheduled? */
99
static unsigned int ciasr_bits; /* number of bits still to send */
100
static BYTE cia_shifter; /* actual shifter */
101
static int cia_sdr_valid; /* when set, SDR contains new data to send */
103
static BYTE oldpa; /* the actual output on PA (input = high) */
104
static BYTE oldpb; /* the actual output on PB (input = high) */
106
static BYTE ciatodalarm[4];
107
static BYTE ciatodlatch[4];
108
static char ciatodstopped;
109
static char ciatodlatched;
110
static int ciatodticks = 100000; /* approx. a 1/10 sec. */
112
static log_t cia_log = LOG_ERR;
118
/* local functions */
121
static void check_ciatodalarm(CIA_CONTEXT_PARAM CLOCK rclk);