2
* ui_sidcart.cc - SID cart settings
5
* Marcus Sutton <loggedoubt@gmail.com>
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
29
#include <OptionPopUp.h>
30
#include <RadioButton.h>
38
#include "constants.h"
40
#include "resources.h"
43
#include "ui_sidcart.h"
48
static char *samplingmode[] = {
56
static sid_engine_model_t **sid_engine_model_list;
58
static char **sidaddresspair;
59
static char **sidclockpair;
61
class SidCartWindow : public BWindow {
62
BOptionPopUp *engine_model_popup;
63
BSlider *passbandslider;
68
void EnableBoxedControls(BBox *box, int enable);
69
void EnableReSidControls(int engine);
70
void EnableControls();
74
virtual void MessageReceived(BMessage *msg);
77
static SidCartWindow *sidcartwindow = NULL;
79
void SidCartWindow::EnableBoxedControls(BBox *box, int enable)
83
children = box->CountChildren();
84
for (i = 0; i < children; i++) {
85
((BControl *)box->ChildAt(i))->SetEnabled(enable);
90
void SidCartWindow::EnableReSidControls(int engine)
94
enable = ((BControl *)FindView("SidCart"))->Value();
95
EnableBoxedControls(residbox, enable && ((engine == SID_ENGINE_RESID) || (engine == SID_ENGINE_RESID_FP)));
98
void SidCartWindow::EnableControls()
102
enable = ((BControl *)FindView("SidCart"))->Value();
103
engine_model_popup->SetEnabled(enable);
104
((BControl *)FindView("SidFilters"))->SetEnabled(enable);
105
EnableBoxedControls(addressbox, enable);
106
EnableBoxedControls(clockbox, enable);
107
if (machine_class == VICE_MACHINE_PLUS4) {
108
((BControl *)FindView("DIGIBLASTER"))->SetEnabled(enable);
111
resources_get_int("SidEngine", &engine);
112
EnableReSidControls(engine);
115
SidCartWindow::SidCartWindow()
116
: BWindow(BRect(250, 50, 500, 340), "SID cartridge settings", B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_RESIZABLE)
121
BRadioButton *radiobutton;
123
int engine, res_val, i;
126
background = new BView(r, NULL, B_FOLLOW_NONE, B_WILL_DRAW);
127
background->SetViewColor(220, 220, 220, 0);
128
AddChild(background);
130
/* SID cart emulation */
131
resources_get_int("SidCart", &res_val);
132
checkbox = new BCheckBox(BRect(10, 10, 240, 25), "SidCart", "Enable SID cartridge", new BMessage(MESSAGE_SIDCART_ENABLE));
133
checkbox->SetValue(res_val);
134
background->AddChild(checkbox);
137
sid_engine_model_list = sid_get_engine_model_list();
138
resources_get_int("SidModel", &i);
139
resources_get_int("SidEngine", &engine);
140
res_val = engine << 8;
142
engine_model_popup = new BOptionPopUp(BRect(10, 35, 240, 59), "SID Engine/Model", "SID Engine/Model", new BMessage(MESSAGE_SIDCART_MODEL));
143
for (i = 0; sid_engine_model_list[i] != NULL; i++) {
144
engine_model_popup->AddOption(sid_engine_model_list[i]->name, sid_engine_model_list[i]->value);
146
engine_model_popup->SelectOptionFor(res_val);
147
background->AddChild(engine_model_popup);
150
resources_get_int("SidFilters", &res_val);
151
checkbox = new BCheckBox(BRect(10, 60, 240, 75), "SidFilters", "SID filters", new BMessage(MESSAGE_SIDCART_FILTERS));
152
checkbox->SetValue(res_val);
153
background->AddChild(checkbox);
156
addressbox = new BBox(BRect(10, 85, 120, 145), "SID address");
157
addressbox->SetViewColor(220, 220, 220, 0);
158
addressbox->SetLabel("SID address");
159
background->AddChild(addressbox);
161
resources_get_int("SidAddress", &res_val);
162
for (i = 0; i < 2; i++) {
163
msg = new BMessage(MESSAGE_SIDCART_ADDRESS);
164
msg->AddInt32("address", i);
165
radiobutton = new BRadioButton(BRect(10, 15 + i * 20, 100, 30 + i * 20), sidaddresspair[i], sidaddresspair[i], msg);
166
radiobutton->SetValue(res_val == i);
167
addressbox->AddChild(radiobutton);
171
clockbox = new BBox(BRect(130, 85, 240, 145), "SID clock");
172
clockbox->SetViewColor(220, 220, 220, 0);
173
clockbox->SetLabel("SID clock");
174
background->AddChild(clockbox);
176
resources_get_int("SidClock", &res_val);
177
for (i = 0; i < 2; i++) {
178
msg = new BMessage(MESSAGE_SIDCART_CLOCK);
179
msg->AddInt32("clock", i);
180
radiobutton = new BRadioButton(BRect(10, 15 + i * 20, 100, 30 + i * 20), sidclockpair[i], sidclockpair[i], msg);
181
radiobutton->SetValue(res_val == i);
182
clockbox->AddChild(radiobutton);
186
if (machine_class == VICE_MACHINE_PLUS4) {
187
resources_get_int("DIGIBLASTER", &res_val);
188
checkbox = new BCheckBox(BRect(10, 155, 240, 170), "DIGIBLASTER", "Enable digiblaster add-on", new BMessage(MESSAGE_SIDCART_DIGIBLASTER));
189
checkbox->SetValue(res_val);
190
background->AddChild(checkbox);
198
r.top = r.bottom - 100;
199
residbox = new BBox(r, "reSID/reSID-fp settings");
200
residbox->SetViewColor(220, 220, 220, 0);
201
residbox->SetLabel("reSID/reSID-fp settings");
202
background->AddChild(residbox);
203
r = residbox->Bounds();
205
/* sampling method */
206
resources_get_int("SidResidSampling", &res_val);
207
for (i = 0; samplingmode[i] != NULL; i++) {
208
msg = new BMessage(MESSAGE_SIDCART_RESIDSAMPLING);
209
msg->AddInt32("mode", i);
210
radiobutton = new BRadioButton(BRect(10, 15 + i * 20, r.Width() / 2 - 10, 30 + i * 20), samplingmode[i], samplingmode[i], msg);
211
radiobutton->SetValue(res_val == i);
212
residbox->AddChild(radiobutton);
215
resources_get_int("SidResidPassband", &res_val);
216
passbandslider = new BSlider(BRect(r.Width() / 2 + 10, 20, r.Width() - 10, 60), "Passband", "Passband", new BMessage(MESSAGE_SIDCART_RESIDPASSBAND), 0, 90, B_TRIANGLE_THUMB);
217
passbandslider->SetValue(res_val);
218
passbandslider->SetHashMarkCount(10);
219
passbandslider->SetHashMarks(B_HASH_MARKS_BOTTOM);
220
passbandslider->SetLimitLabels("0", "90");
221
residbox->AddChild(passbandslider);
228
SidCartWindow::~SidCartWindow()
230
sidcartwindow = NULL;
233
void SidCartWindow::MessageReceived(BMessage *msg)
238
case MESSAGE_SIDCART_ENABLE:
239
resources_toggle("SidCart", (int *)&val);
242
case MESSAGE_SIDCART_MODEL:
243
val = engine_model_popup->Value();
246
sid_set_engine_model(engine, val);
247
EnableReSidControls(engine);
249
case MESSAGE_SIDCART_FILTERS:
250
resources_toggle("SidFilters", (int *)&val);
252
case MESSAGE_SIDCART_ADDRESS:
253
val = msg->FindInt32("address");
254
resources_set_int("SidAddress", (int)val);
256
case MESSAGE_SIDCART_CLOCK:
257
val = msg->FindInt32("clock");
258
resources_set_int("SidClock", (int)val);
260
case MESSAGE_SIDCART_DIGIBLASTER:
261
resources_toggle("DIGIBLASTER", (int *)&val);
263
case MESSAGE_SIDCART_RESIDSAMPLING:
264
val = msg->FindInt32("mode");
265
resources_set_int("SidResidSampling", val);
267
case MESSAGE_SIDCART_RESIDPASSBAND:
268
resources_set_int("SidResidPassband", passbandslider->Value());
271
BWindow::MessageReceived(msg);
275
void ui_sidcart(char **cartaddresspair, char **cartclockpair)
277
thread_id sidcartthread;
280
if (sidcartwindow != NULL) {
284
sidaddresspair = cartaddresspair;
285
sidclockpair = cartclockpair;
287
sidcartwindow = new SidCartWindow;
289
vsync_suspend_speed_eval();
291
/* wait until window closed */
292
sidcartthread = sidcartwindow->Thread();
293
wait_for_thread(sidcartthread, &exit_value);