~ubuntu-branches/ubuntu/hardy/vice/hardy

« back to all changes in this revision

Viewing changes to src/c64/cart/actionreplay3.c

  • Committer: Bazaar Package Importer
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2007-10-07 07:05:46 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20071007070546-81yy0twlka7p2t0e
Tags: 1.22-1
* New upstream version (closes: #428280).
* Correct link to HTML documentation in manpage (closes: #409567).
* Fix most packaging mistakes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * actionreplay3.c - Cartridge handling, Action Replay III cart.
 
3
 *
 
4
 * Written by
 
5
 *  Andreas Boose <viceteam@t-online.de>
 
6
 *
 
7
 * This file is part of VICE, the Versatile Commodore Emulator.
 
8
 * See README for copyright notice.
 
9
 *
 
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.
 
14
 *
 
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.
 
19
 *
 
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
 
23
 *  02111-1307  USA.
 
24
 *
 
25
 */
 
26
 
 
27
#include "vice.h"
 
28
 
 
29
#include <stdio.h>
 
30
#include <string.h>
 
31
 
 
32
#include "actionreplay.h"
 
33
#include "c64cart.h"
 
34
#include "c64cartmem.h"
 
35
#include "c64export.h"
 
36
#include "c64io.h"
 
37
#include "types.h"
 
38
#include "util.h"
 
39
#include "vicii-phi1.h"
 
40
 
 
41
 
 
42
static const c64export_resource_t export_res = {
 
43
    "Action Replay III", 1, 1
 
44
};
 
45
 
 
46
static unsigned int ar_active;
 
47
 
 
48
 
 
49
BYTE REGPARM1 actionreplay3_io1_read(WORD addr)
 
50
{
 
51
    return vicii_read_phi1();
 
52
}
 
53
 
 
54
void REGPARM2 actionreplay3_io1_store(WORD addr, BYTE value)
 
55
{
 
56
    int exrom, bank, conf;
 
57
 
 
58
    /*log_debug("ST %02x",value);*/
 
59
 
 
60
    exrom = (value >> 3) & 1;
 
61
    bank = value & 1;
 
62
    conf = (bank << 3) | ((exrom ^ 1) << 1);
 
63
 
 
64
    if (ar_active) {
 
65
        cartridge_config_changed((BYTE)conf, (BYTE)conf, CMODE_WRITE);
 
66
        if (value & 4)
 
67
            ar_active = 0;
 
68
    }
 
69
 
 
70
}
 
71
 
 
72
BYTE REGPARM1 actionreplay3_io2_read(WORD addr)
 
73
{
 
74
    if (!ar_active)
 
75
        return vicii_read_phi1();
 
76
 
 
77
    io_source = IO_SOURCE_ACTION_REPLAY;
 
78
 
 
79
    switch (roml_bank) {
 
80
      case 0:
 
81
        return roml_banks[addr & 0x1fff];
 
82
      case 1:
 
83
        return roml_banks[(addr & 0x1fff) + 0x2000];
 
84
    }
 
85
 
 
86
    io_source = IO_SOURCE_NONE;
 
87
 
 
88
    return 0;
 
89
}
 
90
 
 
91
void actionreplay3_freeze(void)
 
92
{
 
93
    ar_active = 1;
 
94
    cartridge_config_changed(3, 3, CMODE_READ);
 
95
}
 
96
 
 
97
void actionreplay3_config_init(void)
 
98
{
 
99
    ar_active = 1;
 
100
    cartridge_config_changed(8, 8, CMODE_READ);
 
101
}
 
102
 
 
103
void actionreplay3_reset(void)
 
104
{
 
105
    ar_active = 1;
 
106
}
 
107
 
 
108
void actionreplay3_config_setup(BYTE *rawcart)
 
109
{
 
110
    memcpy(roml_banks, rawcart, 0x4000);
 
111
    memcpy(romh_banks, rawcart, 0x4000);
 
112
 
 
113
    cartridge_config_changed(8, 8, CMODE_READ);
 
114
}
 
115
 
 
116
int actionreplay3_bin_attach(const char *filename, BYTE *rawcart)
 
117
{
 
118
    if (util_file_load(filename, rawcart, 0x4000,
 
119
        UTIL_FILE_LOAD_SKIP_ADDRESS) < 0)
 
120
        return -1;
 
121
 
 
122
    if (c64export_add(&export_res) < 0)
 
123
        return -1;
 
124
 
 
125
    return 0;
 
126
}
 
127
 
 
128
/*
 
129
int actionreplay3_crt_attach(FILE *fd, BYTE *rawcart)
 
130
{
 
131
    BYTE chipheader[0x10];
 
132
    int i;
 
133
 
 
134
    for (i = 0; i <= 3; i++) {
 
135
        if (fread(chipheader, 0x10, 1, fd) < 1)
 
136
            return -1;
 
137
 
 
138
        if (chipheader[0xb] > 3)
 
139
            return -1;
 
140
 
 
141
        if (fread(&rawcart[chipheader[0xb] << 13], 0x2000, 1, fd) < 1)
 
142
            return -1;
 
143
    }
 
144
 
 
145
    if (c64export_add(&export_res) < 0)
 
146
        return -1;
 
147
 
 
148
    return 0;
 
149
}
 
150
*/
 
151
 
 
152
void actionreplay3_detach(void)
 
153
{
 
154
    c64export_remove(&export_res);
 
155
}
 
156