2
* actionreplay3.c - Cartridge handling, Action Replay III cart.
5
* Andreas Boose <viceteam@t-online.de>
7
* This file is part of VICE, the Versatile Commodore Emulator.
8
* See README for copyright notice.
10
* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with this program; if not, write to the Free Software
22
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
32
#include "actionreplay.h"
34
#include "c64cartmem.h"
35
#include "c64export.h"
39
#include "vicii-phi1.h"
42
static const c64export_resource_t export_res = {
43
"Action Replay III", 1, 1
46
static unsigned int ar_active;
49
BYTE REGPARM1 actionreplay3_io1_read(WORD addr)
51
return vicii_read_phi1();
54
void REGPARM2 actionreplay3_io1_store(WORD addr, BYTE value)
56
int exrom, bank, conf;
58
/*log_debug("ST %02x",value);*/
60
exrom = (value >> 3) & 1;
62
conf = (bank << 3) | ((exrom ^ 1) << 1);
65
cartridge_config_changed((BYTE)conf, (BYTE)conf, CMODE_WRITE);
72
BYTE REGPARM1 actionreplay3_io2_read(WORD addr)
75
return vicii_read_phi1();
77
io_source = IO_SOURCE_ACTION_REPLAY;
81
return roml_banks[addr & 0x1fff];
83
return roml_banks[(addr & 0x1fff) + 0x2000];
86
io_source = IO_SOURCE_NONE;
91
void actionreplay3_freeze(void)
94
cartridge_config_changed(3, 3, CMODE_READ);
97
void actionreplay3_config_init(void)
100
cartridge_config_changed(8, 8, CMODE_READ);
103
void actionreplay3_reset(void)
108
void actionreplay3_config_setup(BYTE *rawcart)
110
memcpy(roml_banks, rawcart, 0x4000);
111
memcpy(romh_banks, rawcart, 0x4000);
113
cartridge_config_changed(8, 8, CMODE_READ);
116
int actionreplay3_bin_attach(const char *filename, BYTE *rawcart)
118
if (util_file_load(filename, rawcart, 0x4000,
119
UTIL_FILE_LOAD_SKIP_ADDRESS) < 0)
122
if (c64export_add(&export_res) < 0)
129
int actionreplay3_crt_attach(FILE *fd, BYTE *rawcart)
131
BYTE chipheader[0x10];
134
for (i = 0; i <= 3; i++) {
135
if (fread(chipheader, 0x10, 1, fd) < 1)
138
if (chipheader[0xb] > 3)
141
if (fread(&rawcart[chipheader[0xb] << 13], 0x2000, 1, fd) < 1)
145
if (c64export_add(&export_res) < 0)
152
void actionreplay3_detach(void)
154
c64export_remove(&export_res);