1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
/*
* plus4pio1.c -- Plus4 PIO1 handling.
*
* Written by
* Andreas Boose <viceteam@t-online.de>
*
* 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.
*
*/
#include "vice.h"
#include "drive.h"
#include "drivetypes.h"
#include "maincpu.h"
#include "plus4parallel.h"
#include "plus4pio1.h"
#include "ted.h"
#include "types.h"
/* FIXME: C16 doesn't have 6529, writes can't mask off the tape_sense line */
/* FIXME: line 2 is used in RS232 IRQ as well at $EA62 in ROM */
static BYTE pio1_data = 0xff;
/* Tape sense line: 1 = some button pressed, 0 = no buttons pressed, or datasette not connected. */
static int tape_sense = 0;
BYTE REGPARM1 pio1_read(WORD addr)
{
BYTE pio1_value;
/* Correct clock */
ted_handle_pending_alarms(0);
if (drive_context[0]->drive->parallel_cable_enabled
|| drive_context[1]->drive->parallel_cable_enabled)
pio1_value = parallel_cable_cpu_read();
else
pio1_value = pio1_data;
if (tape_sense)
pio1_value &= ~4;
return pio1_value;
}
void REGPARM2 pio1_store(WORD addr, BYTE value)
{
BYTE pio1_outline;
/* Correct clock */
ted_handle_pending_alarms(maincpu_rmw_flag + 1);
pio1_data = value;
pio1_outline = value;
if (tape_sense)
pio1_outline &= ~4;
if (drive_context[0]->drive->parallel_cable_enabled
|| drive_context[1]->drive->parallel_cable_enabled)
parallel_cable_cpu_write(pio1_outline);
}
void pio1_set_tape_sense(int sense)
{
BYTE pio1_outline;
tape_sense = sense;
pio1_outline = pio1_data;
if (tape_sense)
pio1_outline &= ~4;
if (drive_context[0]->drive->parallel_cable_enabled
|| drive_context[1]->drive->parallel_cable_enabled)
parallel_cable_cpu_write(pio1_outline);
}
|