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

« back to all changes in this revision

Viewing changes to src/drive/iec/c64exp/c64exp-resources.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
 * c64exp-resources.c
 
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
 
 
31
#include "c64exp-resources.h"
 
32
#include "drive.h"
 
33
#include "drivemem.h"
 
34
#include "lib.h"
 
35
#include "profdos.h"
 
36
#include "resources.h"
 
37
#include "util.h"
 
38
 
 
39
 
 
40
static char *profdos_1571_name = NULL;
 
41
 
 
42
 
 
43
static void set_drive_ram(unsigned int dnr)
 
44
{
 
45
    drive_t *drive = drive_context[dnr]->drive;
 
46
 
 
47
    if (drive->type != DRIVE_TYPE_1570 && drive->type != DRIVE_TYPE_1571
 
48
        && drive->type != DRIVE_TYPE_1571CR)
 
49
        return;
 
50
 
 
51
    drivemem_init(drive_context[dnr], drive->type);
 
52
 
 
53
    return;
 
54
}
 
55
 
 
56
static int set_drive_parallel_cable(int val, void *param)
 
57
{
 
58
    drive_t *drive = drive_context[(unsigned int)param]->drive;
 
59
 
 
60
    if (val != DRIVE_PC_NONE && val != DRIVE_PC_STANDARD
 
61
        && val != DRIVE_PC_DD3)
 
62
        return -1;
 
63
 
 
64
    drive->parallel_cable = val;
 
65
    set_drive_ram((unsigned int)param);
 
66
 
 
67
    return 0;
 
68
}
 
69
 
 
70
static int set_drive_profdos(int val, void *param)
 
71
{
 
72
    drive_t *drive = drive_context[(unsigned int)param]->drive;;
 
73
 
 
74
    drive->profdos = val;
 
75
    set_drive_ram((unsigned int)param);
 
76
 
 
77
    return 0;
 
78
}
 
79
 
 
80
static int set_profdos_1571_name(const char *val, void *param)
 
81
{
 
82
    if (util_string_set(&profdos_1571_name, val))
 
83
        return 0;
 
84
 
 
85
    return profdos_load_1571(profdos_1571_name);
 
86
}
 
87
 
 
88
static resource_int_t res_drive[] = {
 
89
    { NULL, 0, RES_EVENT_SAME, NULL,
 
90
      NULL, set_drive_parallel_cable, NULL },
 
91
    { NULL, 0, RES_EVENT_SAME, NULL,
 
92
      NULL, set_drive_profdos, NULL },
 
93
    { NULL }
 
94
};
 
95
 
 
96
static const resource_string_t resources_string[] =
 
97
{
 
98
    { "DriveProfDOS1571Name", "", RES_EVENT_NO, NULL,
 
99
      &profdos_1571_name, set_profdos_1571_name, NULL },
 
100
    { NULL }
 
101
};
 
102
 
 
103
int c64exp_resources_init(void)
 
104
{
 
105
    unsigned int dnr;
 
106
    drive_t *drive;
 
107
 
 
108
    for (dnr = 0; dnr < DRIVE_NUM; dnr++) {
 
109
        drive = drive_context[dnr]->drive;
 
110
 
 
111
        res_drive[0].name = lib_msprintf("Drive%iParallelCable", dnr + 8);
 
112
        res_drive[0].value_ptr = &(drive->parallel_cable);
 
113
        res_drive[0].param = (void *)dnr;
 
114
        res_drive[1].name = lib_msprintf("Drive%iProfDOS", dnr + 8);
 
115
        res_drive[1].value_ptr = &(drive->profdos);
 
116
        res_drive[1].param = (void *)dnr;
 
117
 
 
118
        if (resources_register_int(res_drive) < 0)
 
119
            return -1;
 
120
 
 
121
        lib_free((char *)(res_drive[0].name));
 
122
        lib_free((char *)(res_drive[1].name));
 
123
    }
 
124
 
 
125
    return resources_register_string(resources_string);
 
126
}
 
127
 
 
128
void c64exp_resources_shutdown(void)
 
129
{
 
130
    lib_free(profdos_1571_name);
 
131
}
 
132