Skip to content

Commit

Permalink
fix UI for the 'standard' Plus4 parallel cable
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.code.sf.net/p/vice-emu/code/trunk@45225 379a1393-f5fb-40a0-bcee-ef074d9b53f7
  • Loading branch information
mrdudz committed Jul 13, 2024
1 parent 55cf74f commit 16c053d
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 2 deletions.
10 changes: 10 additions & 0 deletions vice/src/arch/gtk3/widgets/settings_drive.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ static void create_plus4_layout(GtkWidget *left_grid,
int right_row,
int unit)
{
GtkWidget *label;
int index = unit - DRIVE_UNIT_MIN; /* index in widget arrays */

/* Left column widgets */
Expand All @@ -566,6 +567,15 @@ static void create_plus4_layout(GtkWidget *left_grid,


/* Right column widgets (none at the moment) */

/* Parallel cable */
label = create_left_aligned_label("Parallel cable");
drive_parallel[index] = drive_parallel_cable_widget_create(unit);
gtk_widget_set_margin_top(label, 8);
gtk_widget_set_margin_top(drive_parallel[index], 8);
gtk_grid_attach(GTK_GRID(right_grid), label, 0, right_row, 1, 1);
gtk_grid_attach(GTK_GRID(right_grid), drive_parallel[index], 1, right_row, 1, 1);
right_row++;
}

/** \brief Create layout for xpet, xcbm5x0 and xcbm2
Expand Down
1 change: 1 addition & 0 deletions vice/src/drive/iec/plus4exp/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/drive \
-I$(top_srcdir)/src/drive/iec \
-I$(top_srcdir)/src/userport \
-I$(top_srcdir)/src/lib/p64 \
-I$(top_srcdir)/src/core/rtc

Expand Down
38 changes: 36 additions & 2 deletions vice/src/drive/iec/plus4exp/plus4exp-resources.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,21 @@

#include "drive.h"
#include "drivemem.h"
#include "init.h"
#include "lib.h"
#include "plus4exp-resources.h"
#include "resources.h"
#include "uiapi.h"
#include "userport.h"


static void set_drive_ram(unsigned int dnr)
{
diskunit_context_t *unit = diskunit_context[dnr];

if (unit->type != DRIVE_TYPE_1570 && unit->type != DRIVE_TYPE_1571
&& unit->type != DRIVE_TYPE_1571CR) {
if ((unit->type != DRIVE_TYPE_1570) &&
(unit->type != DRIVE_TYPE_1571) &&
(unit->type != DRIVE_TYPE_1571CR)) {
return;
}

Expand All @@ -52,6 +56,7 @@ static void set_drive_ram(unsigned int dnr)
static int set_drive_parallel_cable(int val, void *param)
{
diskunit_context_t *unit = diskunit_context[vice_ptr_to_uint(param)];
int userport_device = -1;

switch (val) {
case DRIVE_PC_NONE:
Expand All @@ -64,6 +69,35 @@ static int set_drive_parallel_cable(int val, void *param)
unit->parallel_cable = val;
set_drive_ram(vice_ptr_to_uint(param));

/* some magic to automatically insert or remove the parallel cable into/from the user port */
resources_get_int("UserportDevice", &userport_device);

if ((val == DRIVE_PC_NONE) && (userport_device == USERPORT_DEVICE_DRIVE_PAR_CABLE)) {
int hasparcable = 0;
int dnr;
/* check if any drive has a parallel cable enabled */
for (dnr = 0; dnr < NUM_DISK_UNITS; dnr++) {
int cable;
resources_get_int_sprintf("Drive%iParallelCable", &cable, dnr + 8);
if (cable != DRIVE_PC_NONE) {
hasparcable = 1;
}
}
/* if no drive uses parallel cable, disable it in the userport settings */
if (hasparcable == 0) {
resources_set_int("UserportDevice", USERPORT_DEVICE_NONE);
}
} else if (val != DRIVE_PC_NONE) {
if (userport_device == USERPORT_DEVICE_NONE) {
resources_set_int("UserportDevice", USERPORT_DEVICE_DRIVE_PAR_CABLE);
} else if (userport_device != USERPORT_DEVICE_DRIVE_PAR_CABLE) {
if (init_main_is_done()) {
ui_message("Warning: the user port is already being used for another device.\n"
"To be able to use the parallel cable, you must also set up the user port accordingly.");
}
}
}

return 0;
}

Expand Down
16 changes: 16 additions & 0 deletions vice/src/plus4/plus4parallel.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@
#include "types.h"
#include "userport.h"

/* Standard drive parallel cable (PLUS4)
PLUS4 | NOTES
---------------
B | P0 <-> Drive VIA1 PA0
K | P1 <-> Drive VIA1 PA1
4 | P2 <-> Drive VIA1 PA2
5 | P3 <-> Drive VIA1 PA3
6 | P4 <-> Drive VIA1 PA4
7 | P5 <-> Drive VIA1 PA5
J | P6 <-> Drive VIA1 PA6
F | P7 <-> Drive VIA1 PA7
Note that this is NOT the "SpeedDOS" cable, the pinout is different!
*/

static uint8_t parallel_cable_cpu_value = 0xff;
static uint8_t parallel_cable_drive_value[NUM_DISK_UNITS] = { 0xff, 0xff, 0xff, 0xff };

Expand Down

0 comments on commit 16c053d

Please sign in to comment.