/* -*- C -*- * * cia2.def - Definitions for the second MOS6526 (CIA) chip in the C64 * ($DD00). * * Written by * André Fachat (fachat@physik.tu-chemnitz.de) * Ettore Perazzoli (ettore@comm2000.it) * * This file is part of VICE, the Versatile Commodore Emulator. * See README for copyright notice. * * 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 2 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, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA. * */ /* Header for building cia2.c (CIA #2 emulation in the C64). */ #define mycpu maincpu #define myclk maincpu_clk #define mycia cia2 #define MYCIA CIA2 #define READ_SDR #define STORE_SDR /* #define CIA2_TIMER_DEBUG */ #define cia2_set_int_clk maincpu_set_nmi_clk #define CIA2_INT IK_NMI INCLUDES() { #include "true1541.h" #include "c64mem.h" #include "c64iec.h" #include "c64cia.h" #ifdef HAVE_PRINTER #include "pruser.h" #endif #ifdef HAVE_RS232 #include "rsuser.h" #endif } PRE_CIA_FUNCS() { static iec_info_t *iec_info; } RESET_CIA() { #ifdef HAVE_PRINTER userport_printer_write_strobe(1); userport_printer_write_data(0xff); #endif #ifdef HAVE_RS232 userport_serial_write_ctrl(0xff); #endif iec_info = iec_get_drive_port(); } STORE_CIAPA() { if (cia2[addr] != byte) { BYTE tmp; cia2[addr] = byte; tmp = ~cia2[CIA_PRA] & cia2[CIA_DDRA]; mem_set_vbank(tmp & 3); iec_cpu_write(tmp); #ifdef HAVE_PRINTER userport_printer_write_strobe(tmp & 0x04); #endif } } STORE_CIAPB() { cia2[addr] = byte; byte = cia2[CIA_PRB] | ~cia2[CIA_DDRB]; if (true1541_parallel_cable_enabled) parallel_cable_cpu_write(byte, ((addr == CIA_PRB) ? 1 : 0)); #ifdef HAVE_PRINTER userport_printer_write_data(byte); #endif #ifdef HAVE_RS232 userport_serial_write_ctrl(byte); #endif } READ_CIAPA() { if (!true1541_enabled) return ((cia2[CIA_PRA] | ~cia2[CIA_DDRA]) & 0x3f) | (iec_info->iec_fast_1541 & 0x30) << 2; true1541_cpu_execute(); byte = ((cia2[CIA_PRA] | ~cia2[CIA_DDRA]) & 0x3f) | iec_info->cpu_port; } READ_CIAPB() { #ifdef HAVE_RS232 byte = (true1541_parallel_cable_enabled ? parallel_cable_cpu_read() : (rsuser_enabled ? userport_serial_read_ctrl() : cia2[CIA_PRB] | ~cia2[CIA_DDRB])); #else byte = (true1541_parallel_cable_enabled ? parallel_cable_cpu_read() : cia2[CIA_PRB] | ~cia2[CIA_DDRB]); #endif } READ_CIAICR() { if (true1541_parallel_cable_enabled) true1541_cpu_execute(); } POST_CIA_FUNCS() { #ifdef HAVE_PRINTER void userport_printer_set_busy(int flank) { if(!flank) { cia2_set_flag(); } } #endif }