vice-emu-commit Mailing List for VICE (Page 4)
Versatile Commodore Emulator
Brought to you by:
blackystardust,
gpz
You can subscribe to this list here.
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
(38) |
May
(60) |
Jun
(122) |
Jul
(148) |
Aug
(178) |
Sep
(151) |
Oct
(131) |
Nov
(208) |
Dec
(129) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2009 |
Jan
(193) |
Feb
(209) |
Mar
(221) |
Apr
(243) |
May
(165) |
Jun
(168) |
Jul
(198) |
Aug
(161) |
Sep
(103) |
Oct
(98) |
Nov
(168) |
Dec
(99) |
| 2010 |
Jan
(263) |
Feb
(156) |
Mar
(57) |
Apr
(93) |
May
(85) |
Jun
(124) |
Jul
(57) |
Aug
(58) |
Sep
(113) |
Oct
(148) |
Nov
(114) |
Dec
(193) |
| 2011 |
Jan
(200) |
Feb
(207) |
Mar
(91) |
Apr
(91) |
May
(142) |
Jun
(104) |
Jul
(115) |
Aug
(137) |
Sep
(266) |
Oct
(91) |
Nov
(85) |
Dec
(186) |
| 2012 |
Jan
(98) |
Feb
(146) |
Mar
(160) |
Apr
(99) |
May
(59) |
Jun
(257) |
Jul
(84) |
Aug
(103) |
Sep
(169) |
Oct
(206) |
Nov
(90) |
Dec
(296) |
| 2013 |
Jan
(294) |
Feb
(130) |
Mar
(36) |
Apr
(14) |
May
(51) |
Jun
(74) |
Jul
(180) |
Aug
(85) |
Sep
(26) |
Oct
(45) |
Nov
(29) |
Dec
(21) |
| 2014 |
Jan
(56) |
Feb
(40) |
Mar
(57) |
Apr
(30) |
May
(31) |
Jun
(11) |
Jul
(107) |
Aug
(135) |
Sep
(142) |
Oct
(195) |
Nov
(139) |
Dec
(133) |
| 2015 |
Jan
(293) |
Feb
(161) |
Mar
(146) |
Apr
(85) |
May
(139) |
Jun
(51) |
Jul
(21) |
Aug
(24) |
Sep
(29) |
Oct
(136) |
Nov
(212) |
Dec
(118) |
| 2016 |
Jan
(119) |
Feb
(165) |
Mar
(229) |
Apr
(219) |
May
(134) |
Jun
(119) |
Jul
(134) |
Aug
(236) |
Sep
(203) |
Oct
(215) |
Nov
(300) |
Dec
(140) |
| 2017 |
Jan
(188) |
Feb
(20) |
Mar
(147) |
Apr
(198) |
May
(26) |
Jun
(21) |
Jul
(67) |
Aug
(219) |
Sep
(209) |
Oct
(194) |
Nov
(144) |
Dec
(99) |
| 2018 |
Jan
(139) |
Feb
(122) |
Mar
(116) |
Apr
(85) |
May
(232) |
Jun
(181) |
Jul
(190) |
Aug
(105) |
Sep
(92) |
Oct
(178) |
Nov
(105) |
Dec
(86) |
| 2019 |
Jan
(119) |
Feb
(79) |
Mar
(74) |
Apr
(117) |
May
(115) |
Jun
(307) |
Jul
(107) |
Aug
(131) |
Sep
(103) |
Oct
(60) |
Nov
(118) |
Dec
(70) |
| 2020 |
Jan
(114) |
Feb
(103) |
Mar
(77) |
Apr
(121) |
May
(193) |
Jun
(110) |
Jul
(214) |
Aug
(210) |
Sep
(179) |
Oct
(260) |
Nov
(237) |
Dec
(334) |
| 2021 |
Jan
(163) |
Feb
(186) |
Mar
(58) |
Apr
(81) |
May
(108) |
Jun
(175) |
Jul
(154) |
Aug
(180) |
Sep
(217) |
Oct
(204) |
Nov
(232) |
Dec
(190) |
| 2022 |
Jan
(253) |
Feb
(134) |
Mar
(229) |
Apr
(190) |
May
(125) |
Jun
(70) |
Jul
(8) |
Aug
(22) |
Sep
(19) |
Oct
(33) |
Nov
(94) |
Dec
(164) |
| 2023 |
Jan
(158) |
Feb
(366) |
Mar
(272) |
Apr
(109) |
May
(198) |
Jun
(226) |
Jul
(200) |
Aug
(94) |
Sep
(108) |
Oct
(62) |
Nov
(175) |
Dec
(116) |
| 2024 |
Jan
(35) |
Feb
(40) |
Mar
(51) |
Apr
(89) |
May
(24) |
Jun
(26) |
Jul
(53) |
Aug
(71) |
Sep
(23) |
Oct
(11) |
Nov
(22) |
Dec
(58) |
| 2025 |
Jan
(26) |
Feb
(40) |
Mar
(107) |
Apr
(39) |
May
(35) |
Jun
(20) |
Jul
(11) |
Aug
(24) |
Sep
(35) |
Oct
(28) |
Nov
(12) |
Dec
|
|
From: <gp...@us...> - 2025-08-31 13:35:00
|
Revision: 45745
http://sourceforge.net/p/vice-emu/code/45745
Author: gpz
Date: 2025-08-31 13:34:57 +0000 (Sun, 31 Aug 2025)
Log Message:
-----------
Delay some initialization until first actual use. First step towards allocating all printer resources dynamically.
Modified Paths:
--------------
trunk/vice/src/printerdrv/driver-select.c
trunk/vice/src/printerdrv/drv-1520.c
trunk/vice/src/printerdrv/drv-mps803.c
trunk/vice/src/printerdrv/drv-nl10.c
trunk/vice/src/printerdrv/printer.c
Modified: trunk/vice/src/printerdrv/driver-select.c
===================================================================
--- trunk/vice/src/printerdrv/driver-select.c 2025-08-27 09:02:36 UTC (rev 45744)
+++ trunk/vice/src/printerdrv/driver-select.c 2025-08-31 13:34:57 UTC (rev 45745)
@@ -25,8 +25,6 @@
*
*/
-/* #define DEBUG_PRINTER */
-
#include "vice.h"
#include <stdio.h>
@@ -44,6 +42,15 @@
#include "util.h"
+/* #define DEBUG_PRINTER */
+
+#ifdef DEBUG_PRINTER
+#define DBG(x) log_printf x
+#else
+#define DBG(x)
+#endif
+
+
static log_t driver_select_log = LOG_DEFAULT;
/* Currently used printer driver. */
@@ -207,6 +214,8 @@
if (list == NULL) {
return -1;
}
+ DBG(("set_printer_driver name:%s param:%d (list->driver_select.drv_name:%s)",
+ name, prnr, list->driver_select.drv_name));
if ((prnr == PRINTER_IEC_4) || (prnr == PRINTER_IEC_5)) {
if (!driver_select_is_printer(name)) {
@@ -229,12 +238,12 @@
memcpy(&(driver[prnr]), &(list->driver_select), sizeof(driver_select_t));
if(driver[prnr].drv_select) {
#ifdef DEBUG_PRINTER
- log_message(driver_select_log, "driver[%d].drv_select != NULL", prnr);
+ log_message(driver_select_log, "driver[%u].drv_select != NULL (%s)", prnr, name);
#endif
return driver[prnr].drv_select(prnr);
}
#ifdef DEBUG_PRINTER
- log_message(driver_select_log, "driver[%d].drv_select == NULL", prnr);
+ log_message(driver_select_log, "driver[%u].drv_select == NULL (%s)", prnr, name);
#endif
return 0;
}
@@ -350,12 +359,12 @@
{
if(driver[prnr].drv_select) {
#ifdef DEBUG_PRINTER
- log_message(driver_select_log, "driver[%d].drv_select != NULL", prnr);
+ log_message(driver_select_log, "driver[%u].drv_select != NULL", prnr);
#endif
return driver[prnr].drv_select(prnr);
}
#ifdef DEBUG_PRINTER
- log_message(driver_select_log, "driver[%d].drv_select == NULL", prnr);
+ log_message(driver_select_log, "driver[%u].drv_select == NULL", prnr);
#endif
return 0;
}
Modified: trunk/vice/src/printerdrv/drv-1520.c
===================================================================
--- trunk/vice/src/printerdrv/drv-1520.c 2025-08-27 09:02:36 UTC (rev 45744)
+++ trunk/vice/src/printerdrv/drv-1520.c 2025-08-31 13:34:57 UTC (rev 45745)
@@ -45,6 +45,12 @@
/*#define DEBUG1520 1 */
/*#define DEBUG1520_A 1*/
+#ifdef DEBUG1520
+#define DBG(x) log_printf x
+#else
+#define DBG(x)
+#endif
+
/*
* Each line segment is 0,2 mm.
* At 150 DPI that would be 11,8 pixels.
@@ -108,6 +114,8 @@
int rel_origin_x, rel_origin_y; /* steps relative to abs_origin */
int cur_x, cur_y; /* steps relative to abs_origin */
int lowest_y; /* steps relative to start of page */
+
+ int first_open_type; /* if not 0, the driver will initialize itself (for the given type) if needed */
};
typedef struct plot_s plot_t;
@@ -1084,6 +1092,51 @@
/* ------------------------------------------------------------------------- */
/* Interface to the upper layer. */
+static int drv_1520_palette_init(void)
+{
+ static const char *color_names[5] =
+ {
+ "Black", "White", "Blue", "Green", "Red"
+ };
+
+ /* FIXME: rename the palette somehow? */
+ palette = palette_create(5, color_names);
+
+ if (palette == NULL) {
+ return -1;
+ }
+
+ if (palette_load("1520.vpl", "PRINTER", palette) < 0) {
+ log_error(drv1520_log, "Cannot load palette file `%s'.",
+ "1520.vpl");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int drv_1520_first_open(unsigned int prnr)
+{
+#if DEBUG1520
+ log_message(drv1520_log, "drv_1520_first_open: prnr=%u", prnr);
+#endif
+
+ output_parameter_t output_parameter;
+ plot_t *mps = &drv_1520[prnr];
+
+ output_parameter.maxcol = X_PIXELS+1;
+ output_parameter.maxrow = Y_PIXELS+1;
+ output_parameter.dpi_x = (PIXELS_PER_STEP * STEPS_PER_MM * 254) / 10;
+ output_parameter.dpi_y = (PIXELS_PER_STEP * STEPS_PER_MM * 254) / 10;
+ output_parameter.palette = palette;
+
+ drv_1520[prnr].prnr = prnr;
+ power_on_reset(mps);
+
+ drv_1520[prnr].first_open_type = 0;
+
+ return output_select_open(prnr, &output_parameter);
+}
static int drv_1520_open(unsigned int prnr, unsigned int secondary)
{
#if DEBUG1520
@@ -1092,24 +1145,30 @@
/* Is this the first open? */
if (secondary == DRIVER_FIRST_OPEN) {
- output_parameter_t output_parameter;
- plot_t *mps = &drv_1520[prnr];
+ drv_1520[prnr].first_open_type = 1520;
+ return 0;
+ } else if (secondary > 7) {
+ return -1;
+ }
- output_parameter.maxcol = X_PIXELS+1;
- output_parameter.maxrow = Y_PIXELS+1;
- output_parameter.dpi_x = (PIXELS_PER_STEP * STEPS_PER_MM * 254) / 10;
- output_parameter.dpi_y = (PIXELS_PER_STEP * STEPS_PER_MM * 254) / 10;
- output_parameter.palette = palette;
+ return 0;
+}
- drv_1520[prnr].prnr = prnr;
- power_on_reset(mps);
+static int drv_first_open(unsigned int prnr)
+{
+ DBG(("drv_first_open(prnr:%u first_open_type:%d)", prnr, drv_1520[prnr].first_open_type));
- return output_select_open(prnr, &output_parameter);
- } else if (secondary > 7) {
+ if ((palette == NULL) && (drv_1520_palette_init() < 0)) {
return -1;
}
- return 0;
+ switch (drv_1520[prnr].first_open_type) {
+ case 1520:
+ return drv_1520_first_open(prnr);
+ case 0:
+ return 0;
+ }
+ return -1;
}
static void drv_1520_close(unsigned int prnr, unsigned int secondary)
@@ -1117,7 +1176,9 @@
#if DEBUG1520
log_message(drv1520_log, "drv_1520_close: sa=%u prnr=%u", secondary, prnr);
#endif
-
+ if (drv_first_open(prnr) < 0) {
+ return;
+ }
/* Is this the last close? */
if (secondary == DRIVER_LAST_CLOSE) {
plot_t *mps = &drv_1520[prnr];
@@ -1145,7 +1206,9 @@
#if DEBUG1520
log_message(drv1520_log, "drv_1520_putc: sa=%u b='%c' (%u) prnr=%u", secondary, b, b, prnr);
#endif
-
+ if (drv_first_open(prnr) < 0) {
+ return -1;
+ }
switch (secondary) {
case 0:
print_char_text(mps, b);
@@ -1180,6 +1243,9 @@
static int drv_1520_getc(unsigned int prnr, unsigned int secondary, uint8_t *b)
{
+ if (drv_first_open(prnr) < 0) {
+ return -1;
+ }
return output_select_getc(prnr, b);
}
@@ -1188,6 +1254,9 @@
#if DEBUG1520
log_message(drv1520_log, "drv_1520_flush");
#endif
+ if (drv_first_open(prnr) < 0) {
+ return -1;
+ }
return output_select_flush(prnr);
}
@@ -1198,6 +1267,11 @@
#endif
plot_t *mps = &drv_1520[prnr];
+#if 0 /* do not auto-init on formfeed, avoid superflous init at shutdown */
+ if (drv_first_open(prnr) < 0) {
+ return -1;
+ }
+#endif
if (mps->prnr == (int)prnr && mps->sheet != NULL) {
eject(mps);
}
@@ -1240,11 +1314,6 @@
int drv_1520_init(void)
{
- static const char *color_names[5] =
- {
- "Black", "White", "Blue", "Green", "Red"
- };
-
drv1520_log = log_open("plot1520");
#if DEBUG1520
@@ -1251,18 +1320,6 @@
log_message(drv1520_log, "drv_1520_init");
#endif
- palette = palette_create(5, color_names);
-
- if (palette == NULL) {
- return -1;
- }
-
- if (palette_load("1520.vpl", "PRINTER", palette) < 0) {
- log_error(drv1520_log, "Cannot load palette file `%s'.",
- "1520.vpl");
- return -1;
- }
-
return 0;
}
Modified: trunk/vice/src/printerdrv/drv-mps803.c
===================================================================
--- trunk/vice/src/printerdrv/drv-mps803.c 2025-08-27 09:02:36 UTC (rev 45744)
+++ trunk/vice/src/printerdrv/drv-mps803.c 2025-08-31 13:34:57 UTC (rev 45745)
@@ -26,8 +26,6 @@
*
*/
-/* #define DEBUG_MPS803 */
-
#include "vice.h"
#include <stdio.h>
@@ -45,6 +43,8 @@
#include "sysfile.h"
#include "types.h"
+/* #define DEBUG_MPS803 */
+
#ifdef DEBUG_MPS803
#define DBG(x) log_printf x
#else
@@ -248,6 +248,8 @@
uint8_t charset[512 * MAX_BYTES_PER_CHAR]; /* full charset */
uint8_t rom[MAX_ROM_SIZE]; /* full printer rom */
+
+ int first_open_type; /* if not 0, the driver will initialize itself (for the given type) if needed */
};
typedef struct mps_s mps_t;
@@ -271,6 +273,8 @@
#define MPS_BUSINESS 0x80 /* opened with SA = 7 in business mode */
#define MPS_GRAPHICS 0x00 /* opened with SA = 0 in graphics mode */
+static int drv_first_open(unsigned int prnr);
+
/* ------------------------------------------------------------------------- */
/* get one dot to print (for character)
@@ -1004,8 +1008,34 @@
/* ------------------------------------------------------------------------- */
/* Interface to the upper layer. */
+static int mps803_palette_init(void)
+{
+ const char *color_names[2] = {"Black", "White"};
+
+ /* FIXME: rename the palette somehow? */
+ palette = palette_create(2, color_names);
+
+ if (palette == NULL) {
+ return -1;
+ }
+
+ if (palette_load("mps803.vpl", "PRINTER", palette) < 0) {
+ log_error(drv803_log, "Cannot load palette file `%s'.",
+ "mps803.vpl");
+ return -1;
+ }
+
+ return 0;
+}
+
static int drv_common_open(unsigned int prnr, unsigned int secondary)
{
+
+ DBG(("drv_common_open(%u,%u)", prnr, secondary));
+ if (drv_first_open(prnr) < 0) {
+ return -1;
+ }
+
switch (secondary) {
case 0: /* Print data exactly as received (mps801,mps803: Select graphic mode) */
/* set_chargen_mode(&drv_mps803[prnr], secondary, MPS_GRAPHICS); */
@@ -1052,35 +1082,49 @@
return 0;
}
-static int drv_2022_open(unsigned int prnr, unsigned int secondary)
+static int drv_2022_first_open(unsigned int prnr)
{
- if (secondary == DRIVER_FIRST_OPEN) {
- output_parameter_t output_parameter;
+ output_parameter_t output_parameter;
- DBG(("drv_2022_open(prnr:%u, secondary:DRIVER_FIRST_OPEN)", prnr));
- output_parameter.maxcol = 80 * 6;
- output_parameter.maxrow = 66 * 7;
- output_parameter.dpi_x = 72;
- output_parameter.dpi_y = 72;
- output_parameter.palette = palette;
+ DBG(("drv_2022_open(prnr:%u, secondary:DRIVER_FIRST_OPEN)", prnr));
- /* init_charset_2022(&drv_mps803[prnr], C2022_ROM_NAME, C2022_ROM_SIZE); */ /* 7x6 */
- if (sysfile_load(C2022_ROM_NAME, "PRINTER", drv_mps803[prnr].rom, C2022_ROM_SIZE, C2022_ROM_SIZE) < 0) {
- log_error(drv803_log, "Could not load printer ROM '%s'.", C2022_ROM_NAME);
- return -1;
- }
- convert_rom_char_192(&drv_mps803[prnr], 0);
+ /* NOTE: the palette should have been (re)loaded by the function that calls this */
+
+ /* init_charset_2022(&drv_mps803[prnr], C2022_ROM_NAME, C2022_ROM_SIZE); */ /* 7x6 */
+ if (sysfile_load(C2022_ROM_NAME, "PRINTER", drv_mps803[prnr].rom, C2022_ROM_SIZE, C2022_ROM_SIZE) < 0) {
+ log_error(drv803_log, "Could not load printer ROM '%s'.", C2022_ROM_NAME);
+ return -1;
+ }
+
+ drv_mps803[prnr].char_height = 7;
+ drv_mps803[prnr].char_width = 6;
+ drv_mps803[prnr].page_width_dots = 80 * 6;
+ drv_mps803[prnr].page_height_dots = 66 * 7;
+ drv_mps803[prnr].model_sa_features = SA_FEATURE_PROG_CHAR_254;
+ drv_mps803[prnr].model_ctrl_features = CTRL_FEATURE_OLD_ENHANCE | CTRL_FEATURE_CR_WITHOUT_LF;
+ drv_mps803[prnr].lookup_method = 2;
+
+ output_parameter.maxcol = 80 * 6;
+ output_parameter.maxrow = 66 * 7;
+ output_parameter.dpi_x = 72;
+ output_parameter.dpi_y = 72;
+ output_parameter.palette = palette;
+
+ convert_rom_char_192(&drv_mps803[prnr], 0);
#ifdef DEBUG_MPS803
- dump_printer_charset(&drv_mps803[prnr]);
+ dump_printer_charset(&drv_mps803[prnr]);
#endif
- drv_mps803[prnr].char_height = 7;
- drv_mps803[prnr].char_width = 6;
- drv_mps803[prnr].page_width_dots = 80 * 6;
- drv_mps803[prnr].page_height_dots = 66 * 7;
- drv_mps803[prnr].model_sa_features = SA_FEATURE_PROG_CHAR_254;
- drv_mps803[prnr].model_ctrl_features = CTRL_FEATURE_OLD_ENHANCE | CTRL_FEATURE_CR_WITHOUT_LF;
- drv_mps803[prnr].lookup_method = 2;
- return output_select_open(prnr, &output_parameter);
+
+ drv_mps803[prnr].first_open_type = 0;
+
+ return output_select_open(prnr, &output_parameter);
+}
+
+static int drv_2022_open(unsigned int prnr, unsigned int secondary)
+{
+ if (secondary == DRIVER_FIRST_OPEN) {
+ drv_mps803[prnr].first_open_type = 2022;
+ return 0;
}
DBG(("drv_2022_open(prnr:%u, secondary:%u)", prnr, secondary));
return drv_common_open(prnr, secondary);
@@ -1090,39 +1134,53 @@
{
DBG(("drv_2022_select(%u)", prnr));
output_select_close(prnr);
+
return drv_2022_open(prnr, DRIVER_FIRST_OPEN);
}
-static int drv_4023_open(unsigned int prnr, unsigned int secondary)
+static int drv_4023_first_open(unsigned int prnr)
{
- if (secondary == DRIVER_FIRST_OPEN) {
- output_parameter_t output_parameter;
- DBG(("drv_4023_open(prnr:%u, secondary:DRIVER_FIRST_OPEN)", prnr));
+ output_parameter_t output_parameter;
- output_parameter.maxcol = 80 * 8;
- output_parameter.maxrow = 66 * 8;
- output_parameter.dpi_x = 72;
- output_parameter.dpi_y = 72;
- output_parameter.palette = palette;
+ DBG(("drv_4023_open(prnr:%u, secondary:DRIVER_FIRST_OPEN)", prnr));
- /* init_charset_4023(&drv_mps803[prnr], C4023_ROM_NAME, C4023_ROM_SIZE); */ /* 8x8 */
- if (sysfile_load(C4023_ROM_NAME, "PRINTER", drv_mps803[prnr].rom, C4023_ROM_SIZE, C4023_ROM_SIZE) < 0) {
- log_error(drv803_log, "Could not load printer ROM '%s'.", C4023_ROM_NAME);
- return -1;
- }
- convert_rom_char_192(&drv_mps803[prnr], 1024);
+ /* NOTE: the palette should have been (re)loaded by the function that calls this */
+ /* init_charset_4023(&drv_mps803[prnr], C4023_ROM_NAME, C4023_ROM_SIZE); */ /* 8x8 */
+ if (sysfile_load(C4023_ROM_NAME, "PRINTER", drv_mps803[prnr].rom, C4023_ROM_SIZE, C4023_ROM_SIZE) < 0) {
+ log_error(drv803_log, "Could not load printer ROM '%s'.", C4023_ROM_NAME);
+ return -1;
+ }
+
+ drv_mps803[prnr].char_height = 8;
+ drv_mps803[prnr].char_width = 8;
+ drv_mps803[prnr].page_width_dots = 80 * 8;
+ drv_mps803[prnr].page_height_dots = 66 * 8;
+ drv_mps803[prnr].model_sa_features = SA_FEATURE_PROG_CHAR_254;
+ drv_mps803[prnr].model_ctrl_features = CTRL_FEATURE_OLD_ENHANCE | CTRL_FEATURE_CR_WITHOUT_LF;
+ drv_mps803[prnr].lookup_method = 1;
+
+ output_parameter.maxcol = 80 * 8;
+ output_parameter.maxrow = 66 * 8;
+ output_parameter.dpi_x = 72;
+ output_parameter.dpi_y = 72;
+ output_parameter.palette = palette;
+
+ convert_rom_char_192(&drv_mps803[prnr], 1024);
+
#ifdef DEBUG_MPS803
- dump_printer_charset(&drv_mps803[prnr]);
+ dump_printer_charset(&drv_mps803[prnr]);
#endif
- drv_mps803[prnr].char_height = 8;
- drv_mps803[prnr].char_width = 8;
- drv_mps803[prnr].page_width_dots = 80 * 8;
- drv_mps803[prnr].page_height_dots = 66 * 8;
- drv_mps803[prnr].model_sa_features = SA_FEATURE_PROG_CHAR_254;
- drv_mps803[prnr].model_ctrl_features = CTRL_FEATURE_OLD_ENHANCE | CTRL_FEATURE_CR_WITHOUT_LF;
- drv_mps803[prnr].lookup_method = 1;
- return output_select_open(prnr, &output_parameter);
+ drv_mps803[prnr].first_open_type = 0;
+
+ return output_select_open(prnr, &output_parameter);
+}
+
+static int drv_4023_open(unsigned int prnr, unsigned int secondary)
+{
+ if (secondary == DRIVER_FIRST_OPEN) {
+ drv_mps803[prnr].first_open_type = 4023;
+ return 0;
}
DBG(("drv_4023_open(prnr:%u, secondary:%u)", prnr, secondary));
return drv_common_open(prnr, secondary);
@@ -1132,39 +1190,53 @@
{
DBG(("drv_4023_select(%u)", prnr));
output_select_close(prnr);
+
return drv_4023_open(prnr, DRIVER_FIRST_OPEN);
}
-static int drv_8023_open(unsigned int prnr, unsigned int secondary)
+static int drv_8023_first_open(unsigned int prnr)
{
- if (secondary == DRIVER_FIRST_OPEN) {
- output_parameter_t output_parameter;
- DBG(("drv_8023_open(prnr:%u, secondary:DRIVER_FIRST_OPEN)", prnr));
+ output_parameter_t output_parameter;
- output_parameter.maxcol = 136 * 6;
- output_parameter.maxrow = 66 * 7;
- output_parameter.dpi_x = 72;
- output_parameter.dpi_y = 72;
- output_parameter.palette = palette;
+ DBG(("drv_8023_open(prnr:%u, secondary:DRIVER_FIRST_OPEN)", prnr));
- /* init_charset_8023(&drv_mps803[prnr], C8023_ROM_NAME, C8023_ROM_SIZE); */ /* 8x8 */
- if (sysfile_load(C8023_ROM_NAME, "PRINTER", drv_mps803[prnr].rom, C8023_ROM_SIZE, C8023_ROM_SIZE) < 0) {
- log_error(drv803_log, "Could not load printer ROM '%s'.", C8023_ROM_NAME);
- return -1;
- }
- convert_rom_char_192(&drv_mps803[prnr], 0);
+ /* NOTE: the palette should have been (re)loaded by the function that calls this */
+
+ /* init_charset_8023(&drv_mps803[prnr], C8023_ROM_NAME, C8023_ROM_SIZE); */ /* 8x8 */
+ if (sysfile_load(C8023_ROM_NAME, "PRINTER", drv_mps803[prnr].rom, C8023_ROM_SIZE, C8023_ROM_SIZE) < 0) {
+ log_error(drv803_log, "Could not load printer ROM '%s'.", C8023_ROM_NAME);
+ return -1;
+ }
+
+ drv_mps803[prnr].char_height = 7;
+ drv_mps803[prnr].char_width = 6;
+ drv_mps803[prnr].page_width_dots = 136 * 6;
+ drv_mps803[prnr].page_height_dots = 66 * 7;
+ drv_mps803[prnr].model_sa_features = SA_FEATURE_PROG_CHAR_254;
+ drv_mps803[prnr].model_ctrl_features = CTRL_FEATURE_OLD_ENHANCE | CTRL_FEATURE_CR_WITHOUT_LF;
+ drv_mps803[prnr].lookup_method = 1;
+
+ output_parameter.maxcol = 136 * 6;
+ output_parameter.maxrow = 66 * 7;
+ output_parameter.dpi_x = 72;
+ output_parameter.dpi_y = 72;
+ output_parameter.palette = palette;
+
+ convert_rom_char_192(&drv_mps803[prnr], 0);
#ifdef DEBUG_MPS803
- dump_printer_charset(&drv_mps803[prnr]);
+ dump_printer_charset(&drv_mps803[prnr]);
#endif
- drv_mps803[prnr].char_height = 7;
- drv_mps803[prnr].char_width = 6;
- drv_mps803[prnr].page_width_dots = 136 * 6;
- drv_mps803[prnr].page_height_dots = 66 * 7;
- drv_mps803[prnr].model_sa_features = SA_FEATURE_PROG_CHAR_254;
- drv_mps803[prnr].model_ctrl_features = CTRL_FEATURE_OLD_ENHANCE | CTRL_FEATURE_CR_WITHOUT_LF;
- drv_mps803[prnr].lookup_method = 1;
- return output_select_open(prnr, &output_parameter);
+ drv_mps803[prnr].first_open_type = 0;
+
+ return output_select_open(prnr, &output_parameter);
+}
+
+static int drv_8023_open(unsigned int prnr, unsigned int secondary)
+{
+ if (secondary == DRIVER_FIRST_OPEN) {
+ drv_mps803[prnr].first_open_type = 8023;
+ return 0;
}
DBG(("drv_8023_open(prnr:%u, secondary:%u)", prnr, secondary));
return drv_common_open(prnr, secondary);
@@ -1174,40 +1246,53 @@
{
DBG(("drv_8023_select(%u)", prnr));
output_select_close(prnr);
+
return drv_8023_open(prnr, DRIVER_FIRST_OPEN);
}
-static int drv_mps801_open(unsigned int prnr, unsigned int secondary)
+static int drv_mps801_first_open(unsigned int prnr)
{
- if (secondary == DRIVER_FIRST_OPEN) {
- output_parameter_t output_parameter;
- DBG(("drv_mps801_open(prnr:%u, secondary:DRIVER_FIRST_OPEN)", prnr));
+ output_parameter_t output_parameter;
- output_parameter.maxcol = 80 * 6;
- output_parameter.maxrow = 66 * 7;
- output_parameter.dpi_x = 60;
- output_parameter.dpi_y = 72;
- output_parameter.palette = palette;
+ DBG(("drv_mps801_open(prnr:%u, secondary:DRIVER_FIRST_OPEN)", prnr));
- /* init_charset_mps801(&drv_mps803[prnr], MPS801_ROM_NAME, MPS801_ROM_SIZE); */ /* 8x8 */
- if (sysfile_load(MPS801_ROM_NAME, "PRINTER", drv_mps803[prnr].rom, MPS801_ROM_SIZE, MPS801_ROM_SIZE) < 0) {
- log_error(drv803_log, "Could not load printer ROM '%s'.", MPS801_ROM_NAME);
- return -1;
- }
+ /* NOTE: the palette should have been (re)loaded by the function that calls this */
- convert_rom_char_mps801(&drv_mps803[prnr], 0x800);
+ /* init_charset_mps801(&drv_mps803[prnr], MPS801_ROM_NAME, MPS801_ROM_SIZE); */ /* 8x8 */
+ if (sysfile_load(MPS801_ROM_NAME, "PRINTER", drv_mps803[prnr].rom, MPS801_ROM_SIZE, MPS801_ROM_SIZE) < 0) {
+ log_error(drv803_log, "Could not load printer ROM '%s'.", MPS801_ROM_NAME);
+ return -1;
+ }
+
+ drv_mps803[prnr].char_height = 7;
+ drv_mps803[prnr].char_width = 6;
+ drv_mps803[prnr].page_width_dots = 80 * 6;
+ drv_mps803[prnr].page_height_dots = 66 * 7;
+ drv_mps803[prnr].model_sa_features = 0;
+ drv_mps803[prnr].model_ctrl_features = CTRL_FEATURE_NEW_ENHANCE | CTRL_FEATURE_BIT_IMAGE_PRINTING;
+ drv_mps803[prnr].lookup_method = 0;
+
+ output_parameter.maxcol = 80 * 6;
+ output_parameter.maxrow = 66 * 7;
+ output_parameter.dpi_x = 60;
+ output_parameter.dpi_y = 72;
+ output_parameter.palette = palette;
+
+ convert_rom_char_mps801(&drv_mps803[prnr], 0x800);
#ifdef DEBUG_MPS803
- dump_printer_charset(&drv_mps803[prnr]);
+ dump_printer_charset(&drv_mps803[prnr]);
#endif
- drv_mps803[prnr].char_height = 7;
- drv_mps803[prnr].char_width = 6;
- drv_mps803[prnr].page_width_dots = 80 * 6;
- drv_mps803[prnr].page_height_dots = 66 * 7;
- drv_mps803[prnr].model_sa_features = 0;
- drv_mps803[prnr].model_ctrl_features = CTRL_FEATURE_NEW_ENHANCE | CTRL_FEATURE_BIT_IMAGE_PRINTING;
- drv_mps803[prnr].lookup_method = 0;
- return output_select_open(prnr, &output_parameter);
+ drv_mps803[prnr].first_open_type = 0;
+
+ return output_select_open(prnr, &output_parameter);
+}
+
+static int drv_mps801_open(unsigned int prnr, unsigned int secondary)
+{
+ if (secondary == DRIVER_FIRST_OPEN) {
+ drv_mps803[prnr].first_open_type = 801;
+ return 0;
}
DBG(("drv_mps801_open(prnr:%u, secondary:%u)", prnr, secondary));
return drv_common_open(prnr, secondary);
@@ -1217,38 +1302,53 @@
{
DBG(("drv_mps801_select(%u)", prnr));
output_select_close(prnr);
+
return drv_mps801_open(prnr, DRIVER_FIRST_OPEN);
}
-static int drv_mps802_open(unsigned int prnr, unsigned int secondary)
+static int drv_mps802_first_open(unsigned int prnr)
{
- if (secondary == DRIVER_FIRST_OPEN) {
- output_parameter_t output_parameter;
- DBG(("drv_mps802_open(prnr:%u, secondary:DRIVER_FIRST_OPEN)", prnr));
+ output_parameter_t output_parameter;
- output_parameter.maxcol = 80 * 8;
- output_parameter.maxrow = 66 * 8;
- output_parameter.dpi_x = 72;
- output_parameter.dpi_y = 72;
- output_parameter.palette = palette;
+ DBG(("drv_mps802_open(prnr:%u, secondary:DRIVER_FIRST_OPEN)", prnr));
- /* init_charset_mps802(&drv_mps803[prnr], MPS802_ROM_NAME, MPS802_ROM_SIZE); */ /* 8x8 */
- if (sysfile_load(MPS802_ROM_NAME, "PRINTER", drv_mps803[prnr].rom, MPS802_ROM_SIZE, MPS802_ROM_SIZE) < 0) {
- log_error(drv803_log, "Could not load printer ROM '%s'.", MPS802_ROM_NAME);
- return -1;
- }
- convert_rom_char_192(&drv_mps803[prnr], 1024);
+ /* NOTE: the palette should have been (re)loaded by the function that calls this */
+
+ /* init_charset_mps802(&drv_mps803[prnr], MPS802_ROM_NAME, MPS802_ROM_SIZE); */ /* 8x8 */
+ if (sysfile_load(MPS802_ROM_NAME, "PRINTER", drv_mps803[prnr].rom, MPS802_ROM_SIZE, MPS802_ROM_SIZE) < 0) {
+ log_error(drv803_log, "Could not load printer ROM '%s'.", MPS802_ROM_NAME);
+ return -1;
+ }
+
+ drv_mps803[prnr].char_height = 8;
+ drv_mps803[prnr].char_width = 8;
+ drv_mps803[prnr].page_width_dots = 80 * 8;
+ drv_mps803[prnr].page_height_dots = 66 * 8;
+ drv_mps803[prnr].model_sa_features = SA_FEATURE_PROG_CHAR_254;
+ drv_mps803[prnr].model_ctrl_features = CTRL_FEATURE_CR_WITHOUT_LF;
+ drv_mps803[prnr].lookup_method = 1;
+
+ output_parameter.maxcol = 80 * 8;
+ output_parameter.maxrow = 66 * 8;
+ output_parameter.dpi_x = 72;
+ output_parameter.dpi_y = 72;
+ output_parameter.palette = palette;
+
+ convert_rom_char_192(&drv_mps803[prnr], 1024);
#ifdef DEBUG_MPS803
- dump_printer_charset(&drv_mps803[prnr]);
+ dump_printer_charset(&drv_mps803[prnr]);
#endif
- drv_mps803[prnr].char_height = 8;
- drv_mps803[prnr].char_width = 8;
- drv_mps803[prnr].page_width_dots = 80 * 8;
- drv_mps803[prnr].page_height_dots = 66 * 8;
- drv_mps803[prnr].model_sa_features = SA_FEATURE_PROG_CHAR_254;
- drv_mps803[prnr].model_ctrl_features = CTRL_FEATURE_CR_WITHOUT_LF;
- drv_mps803[prnr].lookup_method = 1;
- return output_select_open(prnr, &output_parameter);
+
+ drv_mps803[prnr].first_open_type = 0;
+
+ return output_select_open(prnr, &output_parameter);
+}
+
+static int drv_mps802_open(unsigned int prnr, unsigned int secondary)
+{
+ if (secondary == DRIVER_FIRST_OPEN) {
+ drv_mps803[prnr].first_open_type = 802;
+ return 0;
}
DBG(("drv_mps802_open(prnr:%u, secondary:%u)", prnr, secondary));
return drv_common_open(prnr, secondary);
@@ -1258,41 +1358,55 @@
{
DBG(("drv_mps802_select(%u)", prnr));
output_select_close(prnr);
+
return drv_mps802_open(prnr, DRIVER_FIRST_OPEN);
}
-static int drv_mps803_open(unsigned int prnr, unsigned int secondary)
+static int drv_mps803_first_open(unsigned int prnr)
{
- if (secondary == DRIVER_FIRST_OPEN) {
- output_parameter_t output_parameter;
+ static output_parameter_t output_parameter;
- DBG(("drv_mps803_open(prnr:%u, secondary:DRIVER_FIRST_OPEN)", prnr));
- output_parameter.maxcol = MPS803_PAGE_WIDTH_DOTS;
- output_parameter.maxrow = MPS803_PAGE_HEIGHT_DOTS;
- output_parameter.dpi_x = 60; /* mps803 has different horizontal & vertical dpi - see pg 49 of the manual part H. */
- output_parameter.dpi_y = 72; /* NOTE - mixed dpi might not be liked by some image viewers */
- output_parameter.palette = palette;
+ DBG(("drv_mps803_first_open(prnr:%u)", prnr));
- /* init_charset_mps803(&drv_mps803[prnr], MPS803_ROM_NAME, MPS803_ROM_SIZE); */ /* 7x6 */
- if (sysfile_load(MPS803_ROM_NAME, "PRINTER", drv_mps803[prnr].rom, MPS803_ROM_SIZE, MPS803_ROM_SIZE) < 0) {
- log_error(drv803_log, "Could not load printer charset '%s'.", MPS803_ROM_NAME);
- return -1;
- }
+ /* NOTE: the palette should have been (re)loaded by the function that calls this */
- convert_rom_char_160(&drv_mps803[prnr], 0xc3f);
+ /* init_charset_mps803(&drv_mps803[prnr], MPS803_ROM_NAME, MPS803_ROM_SIZE); */ /* 7x6 */
+ if (sysfile_load(MPS803_ROM_NAME, "PRINTER", drv_mps803[prnr].rom, MPS803_ROM_SIZE, MPS803_ROM_SIZE) < 0) {
+ log_error(drv803_log, "Could not load printer charset '%s'.", MPS803_ROM_NAME);
+ return -1;
+ }
+
+ drv_mps803[prnr].char_height = 7;
+ drv_mps803[prnr].char_width = MPS803_BYTES_PER_CHAR;
+ drv_mps803[prnr].page_width_dots = MPS803_PAGE_WIDTH_DOTS;
+ drv_mps803[prnr].page_height_dots = MPS803_PAGE_HEIGHT_DOTS;
+ drv_mps803[prnr].model_sa_features = 0;
+ drv_mps803[prnr].model_ctrl_features = CTRL_FEATURE_NEW_ENHANCE | CTRL_FEATURE_BIT_IMAGE_PRINTING;
+ drv_mps803[prnr].lookup_method = 0;
+
+ output_parameter.maxcol = MPS803_PAGE_WIDTH_DOTS;
+ output_parameter.maxrow = MPS803_PAGE_HEIGHT_DOTS;
+ output_parameter.dpi_x = 60; /* mps803 has different horizontal & vertical dpi - see pg 49 of the manual part H. */
+ output_parameter.dpi_y = 72; /* NOTE - mixed dpi might not be liked by some image viewers */
+ output_parameter.palette = palette;
+
+ convert_rom_char_160(&drv_mps803[prnr], 0xc3f);
#ifdef DEBUG_MPS803
- dump_printer_charset(&drv_mps803[prnr]);
+ dump_printer_charset(&drv_mps803[prnr]);
#endif
- drv_mps803[prnr].char_height = 7;
- drv_mps803[prnr].char_width = MPS803_BYTES_PER_CHAR;
- drv_mps803[prnr].page_width_dots = MPS803_PAGE_WIDTH_DOTS;
- drv_mps803[prnr].page_height_dots = MPS803_PAGE_HEIGHT_DOTS;
- drv_mps803[prnr].model_sa_features = 0;
- drv_mps803[prnr].model_ctrl_features = CTRL_FEATURE_NEW_ENHANCE | CTRL_FEATURE_BIT_IMAGE_PRINTING;
- drv_mps803[prnr].lookup_method = 0;
- return output_select_open(prnr, &output_parameter);
+
+ drv_mps803[prnr].first_open_type = 0;
+
+ return output_select_open(prnr, &output_parameter);
+}
+
+static int drv_mps803_open(unsigned int prnr, unsigned int secondary)
+{
+ DBG(("drv_mps803_open(prnr:%u, secondary:%u)", prnr, secondary));
+ if (secondary == DRIVER_FIRST_OPEN) {
+ drv_mps803[prnr].first_open_type = 803;
+ return 0;
}
- DBG(("drv_mps803_open(prnr:%u, secondary:%u)", prnr, secondary));
return drv_common_open(prnr, secondary);
}
@@ -1300,14 +1414,47 @@
{
DBG(("drv_mps803_select(%u)", prnr));
output_select_close(prnr);
+
return drv_mps803_open(prnr, DRIVER_FIRST_OPEN);
}
/* ------------------------------------------------------------------------- */
+static int drv_first_open(unsigned int prnr)
+{
+ DBG(("drv_first_open(prnr:%u first_open_type:%d)", prnr, drv_mps803[prnr].first_open_type));
+
+ if ((palette == NULL) && (mps803_palette_init() < 0)) {
+ return -1;
+ }
+
+ switch (drv_mps803[prnr].first_open_type) {
+ case 801:
+ return drv_mps801_first_open(prnr);
+ case 802:
+ return drv_mps802_first_open(prnr);
+ case 803:
+ return drv_mps803_first_open(prnr);
+ case 2022:
+ return drv_2022_first_open(prnr);
+ case 4023:
+ return drv_4023_first_open(prnr);
+ case 8023:
+ return drv_8023_first_open(prnr);
+ case 0:
+ return 0;
+ }
+ return -1;
+}
+
+/* ------------------------------------------------------------------------- */
+
static void drv_mps803_close(unsigned int prnr, unsigned int secondary)
{
DBG(("drv_mps803_close(%u,%u)", prnr, secondary));
+ if (drv_first_open(prnr) < 0) {
+ return;
+ }
output_select_close(prnr);
}
@@ -1319,7 +1466,10 @@
static int drv_mps803_putc(unsigned int prnr, unsigned int secondary, uint8_t b)
{
- /* DBG(("drv_mps803_putc(%u,%u:$%02x)", prnr, secondary, b)); */
+ DBG(("drv_mps803_putc(%u,%u:$%02x)", prnr, secondary, b));
+ if (drv_first_open(prnr) < 0) {
+ return -1;
+ }
mps_engine_putc(&drv_mps803[prnr], prnr, secondary, b);
return 0;
}
@@ -1327,6 +1477,9 @@
static int drv_mps803_getc(unsigned int prnr, unsigned int secondary, uint8_t *b)
{
DBG(("drv_mps803_getc(%u,%u)", prnr, secondary));
+ if (drv_first_open(prnr) < 0) {
+ return -1;
+ }
return output_select_getc(prnr, b);
}
@@ -1333,6 +1486,9 @@
static int drv_mps803_flush(unsigned int prnr, unsigned int secondary)
{
/* DBG(("drv_mps803_flush(%u,%u)", prnr, secondary)); */
+ if (drv_first_open(prnr) < 0) {
+ return -1;
+ }
return output_select_flush(prnr);
}
@@ -1339,6 +1495,11 @@
static int drv_mps803_formfeed(unsigned int prnr)
{
DBG(("drv_mps803_formfeed(%u)", prnr));
+#if 0 /* do not auto-init on formfeed, avoid superflous init at shutdown */
+ if (drv_first_open(prnr) < 0) {
+ return -1;
+ }
+#endif
return output_select_formfeed(prnr);;
}
@@ -1504,23 +1665,8 @@
int drv_mps803_init(void)
{
- const char *color_names[2] = {"Black", "White"};
-
drv803_log = log_open("MPS");
- /* FIXME: rename the palette somehow? */
- palette = palette_create(2, color_names);
-
- if (palette == NULL) {
- return -1;
- }
-
- if (palette_load("mps803.vpl", "PRINTER", palette) < 0) {
- log_error(drv803_log, "Cannot load palette file `%s'.",
- "mps803.vpl");
- return -1;
- }
-
return 0;
}
@@ -1528,4 +1674,5 @@
{
DBG(("drv_mps803_shutdown"));
palette_free(palette);
+ palette = NULL;
}
Modified: trunk/vice/src/printerdrv/drv-nl10.c
===================================================================
--- trunk/vice/src/printerdrv/drv-nl10.c 2025-08-27 09:02:36 UTC (rev 45744)
+++ trunk/vice/src/printerdrv/drv-nl10.c 2025-08-31 13:34:57 UTC (rev 45745)
@@ -106,6 +106,8 @@
int col_nr, line_nr;
int isopen, mode, gfx_mode, gfx_count;
int linespace; /* in 1/216 inch */
+
+ int first_open_type; /* if not 0, the driver will initialize itself (for the given type) if needed */
} nl10_t;
@@ -265,8 +267,12 @@
static void reset_hard(nl10_t *nl10)
{
reset(nl10);
- memset(nl10->char_ram, 0, 12 * 96);
- memset(nl10->char_ram_nlq, 0, 47 * 96);
+ if (nl10->char_ram) {
+ memset(nl10->char_ram, 0, 12 * 96);
+ }
+ if (nl10->char_ram_nlq) {
+ memset(nl10->char_ram_nlq, 0, 47 * 96);
+ }
}
@@ -1928,26 +1934,79 @@
/* ------------------------------------------------------------------------- */
/* Interface to the upper layer. */
-static int drv_nl10_open(unsigned int prnr, unsigned int secondary)
+static int nl10_palette_init(void)
{
- nl10_t *nl10 = &(drv_nl10[prnr]);
+ const char *color_names[2] = {"Black", "White"};
- if (secondary == DRIVER_FIRST_OPEN) {
- DBG(("drv_nl10_open(prnr:%u secondary:DRIVER_FIRST_OPEN) device:%u", prnr, 4 + prnr));
- output_parameter_t output_parameter;
+ /* FIXME: rename the palette somehow? */
+ palette = palette_create(2, color_names);
- output_parameter.maxcol = MAX_COL;
- output_parameter.maxrow = MAX_ROW;
- output_parameter.dpi_x = 300;
- output_parameter.dpi_y = 300;
- output_parameter.palette = palette;
+ if (palette == NULL) {
+ return -1;
+ }
- drv_nl10[prnr].pos_y = 0;
- drv_nl10[prnr].pos_y_pix = 0;
- drv_nl10[prnr].isopen = 1;
+ if (palette_load("nl10.vpl", "PRINTER", palette) < 0) {
+ log_error(drvnl10_log, "Cannot load palette file `%s'.",
+ "nl10.vpl");
+ return -1;
+ }
- return output_select_open(prnr, &output_parameter);
+ return 0;
+}
+
+static int drv_nl10_first_open(unsigned int prnr)
+{
+ int i;
+ DBG(("drv_nl10_first_open(prnr:%u secondary:DRIVER_FIRST_OPEN) device:%u", prnr, 4 + prnr));
+ output_parameter_t output_parameter;
+
+ /* allocate RAM buffers */
+ for (i = 0; i < NUM_OUTPUT_SELECT; i++) {
+ if (drv_nl10[i].char_ram == NULL) {
+ drv_nl10[i].char_ram = lib_malloc(96 * 12);
+ memset(drv_nl10[i].char_ram, 0, 12 * 96);
+ }
+ if (drv_nl10[i].char_ram_nlq == NULL) {
+ drv_nl10[i].char_ram_nlq = lib_malloc(96 * 47);
+ memset(drv_nl10[i].char_ram_nlq, 0, 47 * 96);
+ }
+ reset_hard(&(drv_nl10[i]));
+ drv_nl10[i].isopen = 0;
}
+
+ /* load ROM, init charset */
+ if (drv_nl10_init_charset() < 0) {
+ return -1;
+ }
+
+ /* load palette (if needed) */
+ if ((palette == NULL) && (nl10_palette_init() < 0)) {
+ return -1;
+ }
+
+ output_parameter.maxcol = MAX_COL;
+ output_parameter.maxrow = MAX_ROW;
+ output_parameter.dpi_x = 300;
+ output_parameter.dpi_y = 300;
+ output_parameter.palette = palette;
+
+ drv_nl10[prnr].pos_y = 0;
+ drv_nl10[prnr].pos_y_pix = 0;
+ drv_nl10[prnr].isopen = 1;
+
+ drv_nl10[prnr].first_open_type = 0;
+
+ return output_select_open(prnr, &output_parameter);
+}
+
+static int drv_nl10_open(unsigned int prnr, unsigned int secondary)
+{
+ nl10_t *nl10 = &(drv_nl10[prnr]);
+
+ if (secondary == DRIVER_FIRST_OPEN) {
+ drv_nl10[prnr].first_open_type = 10;
+ return 0;
+ }
DBG(("drv_nl10_open(prnr:%u secondary:%u) device:%u", prnr, secondary, 4 + prnr));
if (secondary == 7) {
@@ -1961,9 +2020,29 @@
return 0;
}
+static int drv_first_open(unsigned int prnr)
+{
+ DBG(("drv_first_open(prnr:%u first_open_type:%d)", prnr, drv_nl10[prnr].first_open_type));
+
+ if ((palette == NULL) && (nl10_palette_init() < 0)) {
+ return -1;
+ }
+
+ switch (drv_nl10[prnr].first_open_type) {
+ case 10:
+ return drv_nl10_first_open(prnr);
+ case 0:
+ return 0;
+ }
+ return -1;
+}
+
static void drv_nl10_close(unsigned int prnr, unsigned int secondary)
{
DBG(("drv_nl10_close(prnr:%u secondary:%u) device:%u", prnr, secondary, 4 + prnr));
+ if (drv_first_open(prnr) < 0) {
+ return;
+ }
/* cannot call output_select_close() here since it would eject the
current page, which is not what "close"ing a channel to a real
printer does */
@@ -1976,6 +2055,9 @@
static int drv_nl10_putc(unsigned int prnr, unsigned int secondary, uint8_t b)
{
+ if (drv_first_open(prnr) < 0) {
+ return 0;
+ }
print_char(&drv_nl10[prnr], prnr, b);
return 0;
}
@@ -1982,6 +2064,9 @@
static int drv_nl10_getc(unsigned int prnr, unsigned int secondary, uint8_t *b)
{
+ if (drv_first_open(prnr) < 0) {
+ return 0;
+ }
return 0x80;
}
@@ -1988,6 +2073,9 @@
static int drv_nl10_flush(unsigned int prnr, unsigned int secondary)
{
DBG(("drv_nl10_flush(prnr:%u secondary:%u) device:%u", prnr, secondary, 4 + prnr));
+ if (drv_first_open(prnr) < 0) {
+ return -1;
+ }
return 0;
}
@@ -1995,6 +2083,11 @@
{
DBG(("drv_nl10_formfeed(prnr:%u) device:%u", prnr, 4 + prnr));
nl10_t *nl10 = &(drv_nl10[prnr]);
+#if 0 /* do not auto-init on formfeed, avoid superflous init at shutdown */
+ if (drv_first_open(prnr) < 0) {
+ return -1;
+ }
+#endif
if (nl10->isopen) {
formfeed(nl10, prnr);
}
@@ -2004,6 +2097,9 @@
static int drv_nl10_select(unsigned int prnr)
{
DBG(("drv_nl10_select(prnr:%u) device:%u", prnr, 4 + prnr));
+ if (drv_first_open(prnr) < 0) {
+ return -1;
+ }
if ((prnr == PRINTER_USERPORT) && (userport_get_device() == USERPORT_DEVICE_PRINTER)) {
return drv_nl10_open(prnr, DRIVER_FIRST_OPEN);
}
@@ -2038,41 +2134,10 @@
int drv_nl10_init(void)
{
- int i;
- static const char *color_names[2] =
- {
- "Black", "White"
- };
-
DBG(("drv_nl10_init"));
drvnl10_log = log_open("NL10");
- for (i = 0; i < NUM_OUTPUT_SELECT; i++) {
- drv_nl10[i].char_ram = lib_malloc(96 * 12);
- drv_nl10[i].char_ram_nlq = lib_malloc(96 * 47);
- reset_hard(&(drv_nl10[i]));
- drv_nl10[i].isopen = 0;
- }
-
- if (drv_nl10_init_charset() < 0) {
- return -1;
- }
-
- palette = palette_create(2, color_names);
-
- if (palette == NULL) {
- return -1;
- }
-
- if (palette_load("nl10.vpl", "PRINTER", palette) < 0) {
- log_error(drvnl10_log, "Cannot load palette file `%s'.",
- "nl10.vpl");
- return -1;
- }
-
- log_message(drvnl10_log, "Printer driver initialized.");
-
return 0;
}
@@ -2079,10 +2144,11 @@
void drv_nl10_shutdown(void)
{
int i;
+ DBG(("drv_nl10_shutdown"));
+
palette_free(palette);
+ palette = NULL;
- DBG(("drv_nl10_shutdown"));
-
for (i = 0; i < NUM_OUTPUT_SELECT; i++) {
if (drv_nl10[i].isopen) {
output_select_close(i);
@@ -2090,6 +2156,8 @@
lib_free(drv_nl10[i].char_ram);
lib_free(drv_nl10[i].char_ram_nlq);
+ drv_nl10[i].char_ram = NULL;
+ drv_nl10[i].char_ram_nlq = NULL;
}
}
@@ -2257,6 +2325,9 @@
/* -------------------------------------------------------------------------- */
+/* loads drv_nl10_rom,
+ * inits drv_nl10_charset_nlq, drv_nl10_charset_nlq_italic
+ */
static int drv_nl10_init_charset(void)
{
char *name = NL10_ROM_NAME;
@@ -2263,7 +2334,7 @@
int i, j;
DBG(("drv_nl10_init_charset"));
-
+ /* NOTE: we could dynamically allocate drv_nl10_charset_nlq and -_italic here */
memset(drv_nl10_charset_nlq, 0, CHARSET_SIZE * 47);
memset(drv_nl10_charset_nlq_italic, 0, CHARSET_SIZE * 47);
Modified: trunk/vice/src/printerdrv/printer.c
===================================================================
--- trunk/vice/src/printerdrv/printer.c 2025-08-27 09:02:36 UTC (rev 45744)
+++ trunk/vice/src/printerdrv/printer.c 2025-08-31 13:34:57 UTC (rev 45745)
@@ -62,8 +62,10 @@
|| drv_raw_init_resources() < 0
|| driver_select_init_resources() < 0
|| machine_printer_resources_init() < 0) {
+ DBG(("printer_resources_init (failed)"));
return -1;
}
+ DBG(("printer_resources_init (OK)"));
return 0;
}
@@ -108,6 +110,7 @@
void printer_init(void)
{
+ DBG(("printer_init"));
output_graphics_init();
drv_ascii_init();
drv_mps803_init();
@@ -116,6 +119,7 @@
drv_raw_init();
driver_select_init();
machine_printer_init();
+ DBG(("printer_init (done)"));
}
void printer_reset(void)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gp...@us...> - 2025-08-27 09:02:39
|
Revision: 45744
http://sourceforge.net/p/vice-emu/code/45744
Author: gpz
Date: 2025-08-27 09:02:36 +0000 (Wed, 27 Aug 2025)
Log Message:
-----------
get rid of static buffers for the drive ROMs, load ROMs on demand directly into the drive rom space instead.
Modified Paths:
--------------
trunk/vice/src/c64/c64drive.c
trunk/vice/src/drive/drive.c
trunk/vice/src/drive/driverom.c
trunk/vice/src/drive/driverom.h
trunk/vice/src/drive/drivetypes.h
trunk/vice/src/drive/iec/iec.c
trunk/vice/src/drive/iec/iecrom.c
trunk/vice/src/drive/iec128dcr/iec128dcrrom.c
trunk/vice/src/drive/ieee/ieee.c
trunk/vice/src/drive/ieee/ieeerom.c
trunk/vice/src/drive/tcbm/tcbm.c
trunk/vice/src/drive/tcbm/tcbmrom.c
Modified: trunk/vice/src/c64/c64drive.c
===================================================================
--- trunk/vice/src/c64/c64drive.c 2025-08-24 15:44:19 UTC (rev 45743)
+++ trunk/vice/src/c64/c64drive.c 2025-08-27 09:02:36 UTC (rev 45744)
@@ -103,6 +103,7 @@
iec_drive_idling_method(dnr);
}
+/* test ROMs for existence, size */
void machine_drive_rom_load(void)
{
iec_drive_rom_load();
@@ -109,6 +110,7 @@
ieee_drive_rom_load();
}
+/* setup (=load) the ROM for a given disk unit */
void machine_drive_rom_setup_image(unsigned int dnr)
{
iec_drive_rom_setup_image(dnr);
@@ -115,6 +117,7 @@
ieee_drive_rom_setup_image(dnr);
}
+/* check if the drive ROM is available for a given drive type, returns -1 on error */
int machine_drive_rom_check_loaded(unsigned int type)
{
if (iec_drive_rom_check_loaded(type) == 0) {
@@ -127,6 +130,7 @@
return -1;
}
+/* perform checksum check on ROM for given disk unit nr */
void machine_drive_rom_do_checksum(unsigned int dnr)
{
iec_drive_rom_do_checksum(dnr);
Modified: trunk/vice/src/drive/drive.c
===================================================================
--- trunk/vice/src/drive/drive.c 2025-08-24 15:44:19 UTC (rev 45743)
+++ trunk/vice/src/drive/drive.c 2025-08-27 09:02:36 UTC (rev 45744)
@@ -195,6 +195,7 @@
}
+ /* NOTE: this will not actually load the images yet, only check of the ROMs exist */
driverom_load_images();
/* Do not error out if _SOME_ images are not found, ie. FD2K/4K, CMDHD */
#if 0
@@ -207,8 +208,7 @@
}
#endif
- log_message(drive_log, "Finished loading ROM images.");
- rom_loaded = 1;
+ rom_loaded = 1; /* mark drive ROMs being tested OK */
for (unit = 0; unit < NUM_DISK_UNITS; unit++) {
diskunit_context_t *diskunit = diskunit_context[unit];
@@ -220,9 +220,12 @@
resources_set_int_sprintf("Drive%uType", DRIVE_TYPE_NONE, unit + 8);
}
+ /* This will trigger loading the ROM if needed */
machine_drive_rom_setup_image(unit);
}
+ log_message(drive_log, "Finished loading ROM images.");
+
for (unit = 0; unit < NUM_DISK_UNITS; unit++) {
diskunit_context_t *diskunit = diskunit_context[unit];
int d;
Modified: trunk/vice/src/drive/driverom.c
===================================================================
--- trunk/vice/src/drive/driverom.c 2025-08-24 15:44:19 UTC (rev 45743)
+++ trunk/vice/src/drive/driverom.c 2025-08-27 09:02:36 UTC (rev 45744)
@@ -44,7 +44,7 @@
#include "snapshot.h"
#ifdef DBGDRIVEROM
-#define DBG(x) printf x
+#define DBG(x) log_printf x
#else
#define DBG(x)
#endif
@@ -73,7 +73,78 @@
/* If nonzero, we are far enough in init that we can load ROMs. */
static int drive_rom_load_ok = 0;
+/* like driverom_load, but doesn't actually load anything, and only tests if the
+ file exists and matches the given size(s) */
+int driverom_test_load(const char *resource_name, unsigned int *loaded,
+ int min, int max, const char *name,
+ unsigned int type, unsigned int *size)
+{
+ const char *rom_name = NULL;
+ int filesize;
+ unsigned int dnr;
+ DBG(("driverom_test_load res:%s loaded:%u min:%d max:%d name:%s type:%u size:%u",
+ resource_name, *loaded, min, max, name, type, size ? *size : 0));
+
+ if (!drive_rom_load_ok) {
+ return 0;
+ }
+
+ resources_get_string(resource_name, &rom_name);
+
+ DBG(("driverom_test_load rom_name: %s", rom_name));
+
+ if (size != NULL) {
+ *size = 0;
+ }
+ if (loaded != NULL) {
+ *loaded = 0;
+ }
+
+ filesize = sysfile_locate(rom_name, "DRIVES", NULL);
+
+ if (filesize < 0) {
+#if 1
+ log_error(driverom_log, "%s ROM image not found. "
+ "Hardware-level %s emulation is not available.", name, name);
+#endif
+ goto exiterror;
+ }
+
+ if ((min < max)) {
+ if ((filesize > max)) {
+#if 1
+ log_error(driverom_log, "%s ROM image too large. "
+ "Hardware-level %s emulation is not available.", name, name);
+#endif
+ goto exiterror;
+ }
+ }
+
+ if (loaded != NULL) {
+ *loaded = 1;
+ }
+ if (size != NULL) {
+ *size = (unsigned int)filesize;
+ }
+ return 0;
+
+exiterror:
+#if 1
+ /* FIXME: this should probably no more happen here */
+ /* disable the drives that used the ROM which could not be loaded */
+ for (dnr = 0; dnr < NUM_DISK_UNITS; dnr++) {
+ diskunit_context_t *unit = diskunit_context[dnr];
+ if (unit->type == type) {
+ unit->type = DRIVE_TYPE_NONE;
+ drive_disable(diskunit_context[dnr]);
+ machine_bus_status_drivetype_set(dnr + 8, 0);
+ }
+ }
+#endif
+ return -1;
+}
+
int driverom_load(const char *resource_name, uint8_t *drive_rom, unsigned
int *loaded, int min, int max, const char *name,
unsigned int type, unsigned int *size)
@@ -82,7 +153,7 @@
int filesize;
unsigned int dnr;
- DBG(("driverom_load res:%s loaded:%u min:%d max:%d name:%s type:%u size:%u\n",
+ DBG(("driverom_load res:%s loaded:%u min:%d max:%d name:%s type:%u size:%u",
resource_name, *loaded, min, max, name, type, size ? *size : 0));
if (!drive_rom_load_ok) {
@@ -91,30 +162,21 @@
resources_get_string(resource_name, &rom_name);
- DBG(("driverom_load rom_name: %s\n", rom_name));
+ DBG(("driverom_load rom_name: %s", rom_name));
+ if (size != NULL) {
+ *size = 0;
+ }
+ if (loaded != NULL) {
+ *loaded = 0;
+ }
+
filesize = sysfile_load(rom_name, "DRIVES", drive_rom, min, max);
if (filesize < 0) {
log_error(driverom_log, "%s ROM image not found. "
"Hardware-level %s emulation is not available.", name, name);
-
- if (size != NULL) {
- *size = 0;
- }
- if (loaded != NULL) {
- *loaded = 0;
- }
- /* disable the drives that used the ROM which could not be loaded */
- for (dnr = 0; dnr < NUM_DISK_UNITS; dnr++) {
- diskunit_context_t *unit = diskunit_context[dnr];
- if (unit->type == type) {
- unit->type = DRIVE_TYPE_NONE;
- drive_disable(diskunit_context[dnr]);
- machine_bus_status_drivetype_set(dnr + 8, 0);
- }
- }
- return -1;
+ goto exiterror;
}
*loaded = 1;
@@ -121,17 +183,20 @@
if (size != NULL) {
*size = (unsigned int)filesize;
}
+
/* Align to the end of available space */
if ((filesize <= min) && (min < max)) {
- DBG(("driverom_load align drive rom\n"));
+ DBG(("driverom_load align drive rom"));
+ /* sysfile_load loaded the block to the top end of the buffer */
memmove(drive_rom, &drive_rom[max - min], min);
}
+ /* reset all drives that use the loaded ROM */
for (dnr = 0; dnr < NUM_DISK_UNITS; dnr++) {
diskunit_context_t *unit = diskunit_context[dnr];
if (unit->type == type) {
- DBG(("driverom_load prepare drive rom and reset\n"));
+ DBG(("driverom_load prepare drive rom and reset"));
machine_drive_rom_setup_image(dnr);
driverom_initialize_traps(diskunit_context[dnr]);
drive_cpu_trigger_reset(dnr);
@@ -138,6 +203,18 @@
}
}
return 0;
+
+exiterror:
+ /* disable the drives that used the ROM which could not be loaded */
+ for (dnr = 0; dnr < NUM_DISK_UNITS; dnr++) {
+ diskunit_context_t *unit = diskunit_context[dnr];
+ if (unit->type == type) {
+ unit->type = DRIVE_TYPE_NONE;
+ drive_disable(diskunit_context[dnr]);
+ machine_bus_status_drivetype_set(dnr + 8, 0);
+ }
+ }
+ return -1;
}
int driverom_load_images(void)
@@ -163,7 +240,7 @@
unit->trap = -1;
unit->trapcont = -1;
- DBG(("driverom_initialize_traps type: %u trap idle: %s\n", unit->type,
+ DBG(("driverom_initialize_traps type: %u trap idle: %s", unit->type,
unit->idling_method == DRIVE_IDLE_TRAP_IDLE ? "enabled" : "disabled"));
if (unit->idling_method != DRIVE_IDLE_TRAP_IDLE) {
Modified: trunk/vice/src/drive/driverom.h
===================================================================
--- trunk/vice/src/drive/driverom.h 2025-08-24 15:44:19 UTC (rev 45743)
+++ trunk/vice/src/drive/driverom.h 2025-08-27 09:02:36 UTC (rev 45744)
@@ -59,6 +59,9 @@
int driverom_load(const char *resource_name, uint8_t *drive_rom, unsigned
int *loaded, int min, int max, const char *name,
unsigned int type, unsigned int *size);
+int driverom_test_load(const char *resource_name, unsigned int *loaded,
+ int min, int max, const char *name,
+ unsigned int type, unsigned int *size);
int driverom_load_images(void);
int driverom_snapshot_write(struct snapshot_s *s, const struct drive_s *drive);
int driverom_snapshot_read(struct snapshot_s *s, struct drive_s *drive);
Modified: trunk/vice/src/drive/drivetypes.h
===================================================================
--- trunk/vice/src/drive/drivetypes.h 2025-08-24 15:44:19 UTC (rev 45743)
+++ trunk/vice/src/drive/drivetypes.h 2025-08-27 09:02:36 UTC (rev 45744)
@@ -236,6 +236,9 @@
/* Current ROM image. */
uint8_t rom[DRIVE_ROM_SIZE];
+ /* What ROM type do we have loaded? */
+ unsigned int rom_type;
+
/* Current trap ROM image. */
uint8_t trap_rom[DRIVE_ROM_SIZE];
int trap, trapcont;
Modified: trunk/vice/src/drive/iec/iec.c
===================================================================
--- trunk/vice/src/drive/iec/iec.c 2025-08-24 15:44:19 UTC (rev 45743)
+++ trunk/vice/src/drive/iec/iec.c 2025-08-27 09:02:36 UTC (rev 45744)
@@ -173,6 +173,7 @@
lib_free(tmp);
}
+/* test all ROMs for existence, size */
void iec_drive_rom_load(void)
{
iecrom_load_1540();
@@ -186,11 +187,13 @@
iecrom_load_CMDHD();
}
+/* setup (=load) the ROM for a given disk unit nr */
void iec_drive_rom_setup_image(unsigned int dnr)
{
iecrom_setup_image(diskunit_context[dnr]);
}
+/* check if the drive ROM is available for a given drive type, returns -1 on error */
int iec_drive_rom_check_loaded(unsigned int type)
{
return iecrom_check_loaded(type);
Modified: trunk/vice/src/drive/iec/iecrom.c
===================================================================
--- trunk/vice/src/drive/iec/iecrom.c 2025-08-24 15:44:19 UTC (rev 45743)
+++ trunk/vice/src/drive/iec/iecrom.c 2025-08-27 09:02:36 UTC (rev 45744)
@@ -37,7 +37,15 @@
#include "resources.h"
#include "sysfile.h"
+/* #define DEBUG_IECROM */
+#ifdef DEBUG_IECROM
+#define DBG(x) log_printf x
+#else
+#define DBG(x)
+#endif
+
+
#define DRIVE_ROM1541_CHECKSUM 1991711
/* NOTE: 1571CR is handled in iec128dcr/iec128dcrrom.c */
@@ -45,19 +53,7 @@
/* Logging goes here. */
static log_t iecrom_log;
-static uint8_t drive_rom1540[DRIVE_ROM1540_SIZE_EXPANDED];
-static uint8_t drive_rom1541[DRIVE_ROM1541_SIZE_EXPANDED];
-static uint8_t drive_rom1541ii[DRIVE_ROM1541II_SIZE_EXPANDED];
-
-static uint8_t drive_rom1570[DRIVE_ROM1570_SIZE];
-static uint8_t drive_rom1571[DRIVE_ROM1571_SIZE];
-static uint8_t drive_rom1581[DRIVE_ROM1581_SIZE];
-
-static uint8_t drive_rom2000[DRIVE_ROM2000_SIZE];
-static uint8_t drive_rom4000[DRIVE_ROM4000_SIZE];
-static uint8_t drive_romCMDHD[DRIVE_ROMCMDHD_SIZE];
-
-/* If nonzero, the ROM image has been loaded. */
+/* If nonzero, the ROM image is available */
static unsigned int rom1540_loaded = 0;
static unsigned int rom1541_loaded = 0;
static unsigned int rom1541ii_loaded = 0;
@@ -68,20 +64,20 @@
static unsigned int rom4000_loaded = 0;
static unsigned int romCMDHD_loaded = 0;
-static unsigned int drive_rom1540_size;
-static unsigned int drive_rom1541_size;
-static unsigned int drive_rom1541ii_size;
+static unsigned int drive_rom1540_size = 0;
+static unsigned int drive_rom1541_size = 0;
+static unsigned int drive_rom1541ii_size = 0;
-
-static int iecrom_do_1541_checksum(void)
+static int iecrom_do_1541_checksum(diskunit_context_t *unit)
{
unsigned int i;
unsigned long s;
+ DBG(("iecrom_do_1541_checksum type: %04x", unit->type));
/* Calculate ROM checksum. */
for (i = DRIVE_ROM1541_SIZE_EXPANDED - drive_rom1541_size, s = 0;
i < DRIVE_ROM1541_SIZE_EXPANDED; i++) {
- s += drive_rom1541[i];
+ s += unit->rom[i];
}
if (s != DRIVE_ROM1541_CHECKSUM) {
@@ -91,9 +87,10 @@
return 0;
}
+/* test ROM for existence, size */
int iecrom_load_1540(void)
{
- return driverom_load("DosName1540", drive_rom1540, &rom1540_loaded,
+ return driverom_test_load("DosName1540", &rom1540_loaded,
DRIVE_ROM1540_SIZE, DRIVE_ROM1540_SIZE_EXPANDED, "1540",
DRIVE_TYPE_1540, &drive_rom1540_size);
}
@@ -100,7 +97,7 @@
int iecrom_load_1541(void)
{
- return driverom_load("DosName1541", drive_rom1541, &rom1541_loaded,
+ return driverom_test_load("DosName1541", &rom1541_loaded,
DRIVE_ROM1541_SIZE, DRIVE_ROM1541_SIZE_EXPANDED, "1541",
DRIVE_TYPE_1541, &drive_rom1541_size);
}
@@ -107,7 +104,7 @@
int iecrom_load_1541ii(void)
{
- return driverom_load("DosName1541ii", drive_rom1541ii,
+ return driverom_test_load("DosName1541ii",
&rom1541ii_loaded, DRIVE_ROM1541II_SIZE,
DRIVE_ROM1541II_SIZE_EXPANDED, "1541-II", DRIVE_TYPE_1541II,
&drive_rom1541ii_size);
@@ -115,106 +112,129 @@
int iecrom_load_1570(void)
{
- return driverom_load("DosName1570", drive_rom1570, &rom1570_loaded,
+ return driverom_test_load("DosName1570", &rom1570_loaded,
DRIVE_ROM1570_SIZE, DRIVE_ROM1570_SIZE, "1570", DRIVE_TYPE_1570, NULL);
}
int iecrom_load_1571(void)
{
- return driverom_load("DosName1571", drive_rom1571, &rom1571_loaded,
+ return driverom_test_load("DosName1571", &rom1571_loaded,
DRIVE_ROM1571_SIZE, DRIVE_ROM1571_SIZE, "1571", DRIVE_TYPE_1571, NULL);
}
int iecrom_load_1581(void)
{
- return driverom_load("DosName1581", drive_rom1581, &rom1581_loaded,
+ return driverom_test_load("DosName1581", &rom1581_loaded,
DRIVE_ROM1581_SIZE, DRIVE_ROM1581_SIZE, "1581", DRIVE_TYPE_1581, NULL);
}
int iecrom_load_2000(void)
{
- return driverom_load("DosName2000", drive_rom2000, &rom2000_loaded,
+ return driverom_test_load("DosName2000", &rom2000_loaded,
DRIVE_ROM2000_SIZE, DRIVE_ROM2000_SIZE, "2000", DRIVE_TYPE_2000, NULL);
}
int iecrom_load_4000(void)
{
- return driverom_load("DosName4000", drive_rom4000, &rom4000_loaded,
+ return driverom_test_load("DosName4000", &rom4000_loaded,
DRIVE_ROM4000_SIZE, DRIVE_ROM4000_SIZE, "4000", DRIVE_TYPE_4000, NULL);
}
int iecrom_load_CMDHD(void)
{
- return driverom_load("DosNameCMDHD", drive_romCMDHD, &romCMDHD_loaded,
+ return driverom_test_load("DosNameCMDHD", &romCMDHD_loaded,
DRIVE_ROMCMDHD_SIZE, DRIVE_ROMCMDHD_SIZE, "CMDHD", DRIVE_TYPE_CMDHD, NULL);
}
+/* setup (=load) the ROM for a given disk unit */
void iecrom_setup_image(diskunit_context_t *unit)
{
+ unsigned int loaded = 0;
+ DBG(("iecrom_setup_image type %04x rom_loaded:%d rom_type: %04x", unit->type, rom_loaded, unit->rom_type));
if (rom_loaded) {
- switch (unit->type) {
- case DRIVE_TYPE_1540:
- if (drive_rom1540_size <= DRIVE_ROM1540_SIZE) {
- memcpy(unit->rom, &drive_rom1540[DRIVE_ROM1540_SIZE],
- DRIVE_ROM1540_SIZE);
- memcpy(&(unit->rom[DRIVE_ROM1540_SIZE]),
- &drive_rom1540[DRIVE_ROM1540_SIZE],
- DRIVE_ROM1540_SIZE);
- } else {
- memcpy(unit->rom, drive_rom1540,
- DRIVE_ROM1540_SIZE_EXPANDED);
- }
- break;
- case DRIVE_TYPE_1541:
- if (drive_rom1541_size <= DRIVE_ROM1541_SIZE) {
- memcpy(unit->rom, &drive_rom1541[DRIVE_ROM1541_SIZE],
- DRIVE_ROM1541_SIZE);
- memcpy(&(unit->rom[DRIVE_ROM1541_SIZE]),
- &drive_rom1541[DRIVE_ROM1541_SIZE],
- DRIVE_ROM1541_SIZE);
- } else {
- memcpy(unit->rom, drive_rom1541,
- DRIVE_ROM1541_SIZE_EXPANDED);
- }
- break;
- case DRIVE_TYPE_1541II:
- if (drive_rom1541ii_size <= DRIVE_ROM1541II_SIZE) {
- memcpy(unit->rom, &drive_rom1541ii[DRIVE_ROM1541II_SIZE],
- DRIVE_ROM1541II_SIZE);
- memcpy(&(unit->rom[DRIVE_ROM1541II_SIZE]),
- &drive_rom1541ii[DRIVE_ROM1541II_SIZE],
- DRIVE_ROM1541II_SIZE);
- } else {
- memcpy(unit->rom, drive_rom1541ii,
- DRIVE_ROM1541II_SIZE_EXPANDED);
- }
- break;
- case DRIVE_TYPE_1570:
- memcpy(unit->rom, drive_rom1570, DRIVE_ROM1570_SIZE);
- break;
- case DRIVE_TYPE_1571:
- memcpy(unit->rom, drive_rom1571, DRIVE_ROM1571_SIZE);
- break;
- case DRIVE_TYPE_1581:
- memcpy(unit->rom, drive_rom1581, DRIVE_ROM1581_SIZE);
- break;
- case DRIVE_TYPE_2000:
- memcpy(unit->rom, drive_rom2000, DRIVE_ROM2000_SIZE);
- break;
- case DRIVE_TYPE_4000:
- memcpy(unit->rom, drive_rom4000, DRIVE_ROM4000_SIZE);
- break;
- case DRIVE_TYPE_CMDHD:
- memcpy(unit->rom, drive_romCMDHD, DRIVE_ROMCMDHD_SIZE);
- break;
- default:
- /* NOP */
- break;
+ if (unit->rom_type != unit->type) {
+ /* set this here to avoid recursion */
+ unit->rom_type = unit->type;
+
+ switch (unit->type) {
+ case DRIVE_TYPE_1540:
+ driverom_load("DosName1540", unit->rom, &loaded,
+ DRIVE_ROM1540_SIZE, DRIVE_ROM1540_SIZE_EXPANDED, "1540",
+ DRIVE_TYPE_1540, &drive_rom1540_size);
+ if (drive_rom1540_size <= DRIVE_ROM1540_SIZE) {
+ /* ROM was loaded to the upper part of the buffer */
+ memcpy(unit->rom, &unit->rom[DRIVE_ROM1540_SIZE],
+ DRIVE_ROM1540_SIZE);
+ }
+ break;
+ case DRIVE_TYPE_1541:
+ driverom_load("DosName1541", unit->rom, &loaded,
+ DRIVE_ROM1541_SIZE, DRIVE_ROM1541_SIZE_EXPANDED, "1541",
+ DRIVE_TYPE_1541, &drive_rom1541_size);
+ if (drive_rom1541_size <= DRIVE_ROM1541_SIZE) {
+ /* ROM was loaded to the upper part of the buffer */
+ memcpy(unit->rom, &unit->rom[DRIVE_ROM1541_SIZE],
+ DRIVE_ROM1541_SIZE);
+ }
+ break;
+ case DRIVE_TYPE_1541II:
+ driverom_load("DosName1541ii", unit->rom, &loaded,
+ DRIVE_ROM1541II_SIZE, DRIVE_ROM1541II_SIZE_EXPANDED, "1541-II",
+ DRIVE_TYPE_1541II, &drive_rom1541ii_size);
+ if (drive_rom1541ii_size <= DRIVE_ROM1541II_SIZE) {
+ /* ROM was loaded to the upper part of the buffer */
+ memcpy(unit->rom, &unit->rom[DRIVE_ROM1541II_SIZE],
+ DRIVE_ROM1541II_SIZE);
+ }
+ break;
+
+ case DRIVE_TYPE_1570:
+ driverom_load("DosName1570", unit->rom, &loaded,
+ DRIVE_ROM1570_SIZE, DRIVE_ROM1570_SIZE, "1570",
+ DRIVE_TYPE_1570, NULL);
+ break;
+ case DRIVE_TYPE_1571:
+ driverom_load("DosName1571", unit->rom, &loaded,
+ DRIVE_ROM1571_SIZE, DRIVE_ROM1571_SIZE, "1571",
+ DRIVE_TYPE_1571, NULL);
+ break;
+ case DRIVE_TYPE_1581:
+ driverom_load("DosName1581", unit->rom, &loaded,
+ DRIVE_ROM1581_SIZE, DRIVE_ROM1581_SIZE, "1581",
+ DRIVE_TYPE_1581, NULL);
+ break;
+ case DRIVE_TYPE_2000:
+ driverom_load("DosName2000", unit->rom, &loaded,
+ DRIVE_ROM2000_SIZE, DRIVE_ROM2000_SIZE, "2000",
+ DRIVE_TYPE_2000, NULL);
+ break;
+ case DRIVE_TYPE_4000:
+ driverom_load("DosName4000", unit->rom, &loaded,
+ DRIVE_ROM4000_SIZE, DRIVE_ROM4000_SIZE, "4000",
+ DRIVE_TYPE_4000, NULL);
+ break;
+ case DRIVE_TYPE_CMDHD:
+ driverom_load("DosNameCMDHD", unit->rom, &loaded,
+ DRIVE_ROMCMDHD_SIZE, DRIVE_ROMCMDHD_SIZE, "CMDHD",
+ DRIVE_TYPE_CMDHD, NULL);
+ break;
+
+ default:
+ /* NOP */
+ break;
+ }
+
+ /* if loading failed, set rom type to 0 */
+ if (!loaded) {
+ unit->rom_type = 0;
+ }
}
+
}
}
+/* check if the drive ROM is available for a given drive type, returns -1 on error */
int iecrom_check_loaded(unsigned int type)
{
switch (type) {
@@ -279,10 +299,12 @@
return 0;
}
+/* perform checksum check on ROM for given disk unit nr */
void iecrom_do_checksum(diskunit_context_t *unit)
{
+ DBG(("iecrom_do_checksum type: %04x", unit->type));
if (unit->type == DRIVE_TYPE_1541) {
- iecrom_do_1541_checksum();
+ iecrom_do_1541_checksum(unit);
}
}
Modified: trunk/vice/src/drive/iec128dcr/iec128dcrrom.c
===================================================================
--- trunk/vice/src/drive/iec128dcr/iec128dcrrom.c 2025-08-24 15:44:19 UTC (rev 45743)
+++ trunk/vice/src/drive/iec128dcr/iec128dcrrom.c 2025-08-27 09:02:36 UTC (rev 45744)
@@ -41,30 +41,48 @@
/* Logging goes here. */
static log_t iec128dcrrom_log;
-static uint8_t drive_rom1571cr[DRIVE_ROM1571CR_SIZE];
-
-/* If nonzero, the ROM image has been loaded. */
+/* If nonzero, the ROM image is available */
static unsigned int rom1571cr_loaded = 0;
+/* test ROM for existence, size */
int iec128dcrrom_load_1571cr(void)
{
- return driverom_load("DosName1571cr", drive_rom1571cr, &rom1571cr_loaded,
+ return driverom_test_load("DosName1571cr", &rom1571cr_loaded,
DRIVE_ROM1571CR_SIZE, DRIVE_ROM1571CR_SIZE, "1571CR",
DRIVE_TYPE_1571CR, NULL);
}
+/* setup (=load) the ROM for a given disk unit */
void iec128dcrrom_setup_image(diskunit_context_t *unit)
{
+ unsigned int loaded = 0;
if (rom_loaded) {
- switch (unit->type) {
- case DRIVE_TYPE_1571CR:
- memcpy(unit->rom, drive_rom1571cr, DRIVE_ROM1571CR_SIZE);
- break;
+
+ if (unit->rom_type != unit->type) {
+ /* set this here to avoid recursion */
+ unit->rom_type = unit->type;
+
+ switch (unit->type) {
+ case DRIVE_TYPE_1571CR:
+ driverom_load("DosName1571cr", unit->rom, &loaded,
+ DRIVE_ROM1571CR_SIZE, DRIVE_ROM1571CR_SIZE, "1571CR",
+ DRIVE_TYPE_1571CR, NULL);
+ break;
+ default:
+ /* NOP */
+ break;
+ }
+
+ /* if loading failed, set rom type to 0 */
+ if (!loaded) {
+ unit->rom_type = 0;
+ }
}
}
}
+/* check if the drive ROM is available for a given drive type, returns -1 on error */
int iec128dcrrom_check_loaded(unsigned int type)
{
switch (type) {
Modified: trunk/vice/src/drive/ieee/ieee.c
===================================================================
--- trunk/vice/src/drive/ieee/ieee.c 2025-08-24 15:44:19 UTC (rev 45743)
+++ trunk/vice/src/drive/ieee/ieee.c 2025-08-27 09:02:36 UTC (rev 45744)
@@ -110,6 +110,7 @@
riot2_setup_context(drv);
}
+/* test all ROMs for existence, size */
void ieee_drive_rom_load(void)
{
ieeerom_load_2031();
@@ -120,16 +121,19 @@
ieeerom_load_9000();
}
+/* setup (=load) the ROM for a given disk unit nr */
void ieee_drive_rom_setup_image(unsigned int dnr)
{
ieeerom_setup_image(diskunit_context[dnr]);
}
+/* check if the drive ROM is available for a given drive type, returns -1 on error */
int ieee_drive_rom_check_loaded(unsigned int type)
{
return ieeerom_check_loaded(type);
}
+/* perform checksum check on ROM for given disk unit nr */
void ieee_drive_rom_do_checksum(unsigned int dnr)
{
}
Modified: trunk/vice/src/drive/ieee/ieeerom.c
===================================================================
--- trunk/vice/src/drive/ieee/ieeerom.c 2025-08-24 15:44:19 UTC (rev 45743)
+++ trunk/vice/src/drive/ieee/ieeerom.c 2025-08-27 09:02:36 UTC (rev 45744)
@@ -41,14 +41,7 @@
/* Logging goes here. */
static log_t ieeerom_log;
-static uint8_t drive_rom2031[DRIVE_ROM2031_SIZE];
-static uint8_t drive_rom1001[DRIVE_ROM1001_SIZE];
-static uint8_t drive_rom2040[DRIVE_ROM2040_SIZE];
-static uint8_t drive_rom3040[DRIVE_ROM3040_SIZE];
-static uint8_t drive_rom4040[DRIVE_ROM4040_SIZE];
-static uint8_t drive_rom9000[DRIVE_ROM9000_SIZE];
-
-/* If nonzero, the ROM image has been loaded. */
+/* If nonzero, the ROM image is available */
static unsigned int rom2031_loaded = 0;
static unsigned int rom2040_loaded = 0;
static unsigned int rom3040_loaded = 0;
@@ -57,9 +50,10 @@
static unsigned int rom9000_loaded = 0;
+/* test ROM for existence, size */
int ieeerom_load_2031(void)
{
- return driverom_load("DosName2031", drive_rom2031, &rom2031_loaded,
+ return driverom_test_load("DosName2031", &rom2031_loaded,
DRIVE_ROM2031_SIZE, DRIVE_ROM2031_SIZE, "2031",
DRIVE_TYPE_2031, NULL);
}
@@ -66,7 +60,7 @@
int ieeerom_load_2040(void)
{
- return driverom_load("DosName2040", drive_rom2040, &rom2040_loaded,
+ return driverom_test_load("DosName2040", &rom2040_loaded,
DRIVE_ROM2040_SIZE, DRIVE_ROM2040_SIZE, "2040",
DRIVE_TYPE_2040, NULL);
}
@@ -73,7 +67,7 @@
int ieeerom_load_3040(void)
{
- return driverom_load("DosName3040", drive_rom3040, &rom3040_loaded,
+ return driverom_test_load("DosName3040", &rom3040_loaded,
DRIVE_ROM3040_SIZE, DRIVE_ROM3040_SIZE, "3040",
DRIVE_TYPE_3040, NULL);
}
@@ -80,7 +74,7 @@
int ieeerom_load_4040(void)
{
- return driverom_load("DosName4040", drive_rom4040, &rom4040_loaded,
+ return driverom_test_load("DosName4040", &rom4040_loaded,
DRIVE_ROM4040_SIZE, DRIVE_ROM4040_SIZE, "4040",
DRIVE_TYPE_4040, NULL);
}
@@ -87,7 +81,7 @@
int ieeerom_load_1001(void)
{
- return driverom_load("DosName1001", drive_rom1001, &rom1001_loaded,
+ return driverom_test_load("DosName1001", &rom1001_loaded,
DRIVE_ROM1001_SIZE, DRIVE_ROM1001_SIZE, "1001/8050/8250",
DRIVE_TYPE_1001, NULL);
}
@@ -94,45 +88,82 @@
int ieeerom_load_9000(void)
{
- return driverom_load("DosName9000", drive_rom9000, &rom9000_loaded,
+ return driverom_test_load("DosName9000", &rom9000_loaded,
DRIVE_ROM9000_SIZE, DRIVE_ROM9000_SIZE, "D9090/9060",
DRIVE_TYPE_9000, NULL);
}
+/* setup (=load) the ROM for a given disk unit */
void ieeerom_setup_image(diskunit_context_t *unit)
{
+ unsigned int loaded = 0;
if (rom_loaded) {
- switch (unit->type) {
- case DRIVE_TYPE_2031:
- memcpy(&(unit->rom[0x4000]), drive_rom2031,
- DRIVE_ROM2031_SIZE);
- break;
- case DRIVE_TYPE_2040:
- memcpy(&(unit->rom[DRIVE_ROM_SIZE - DRIVE_ROM2040_SIZE]),
- drive_rom2040, DRIVE_ROM2040_SIZE);
- break;
- case DRIVE_TYPE_3040:
- memcpy(&(unit->rom[DRIVE_ROM_SIZE - DRIVE_ROM3040_SIZE]),
- drive_rom3040, DRIVE_ROM3040_SIZE);
- break;
- case DRIVE_TYPE_4040:
- memcpy(&(unit->rom[DRIVE_ROM_SIZE - DRIVE_ROM4040_SIZE]),
- drive_rom4040, DRIVE_ROM4040_SIZE);
- break;
- case DRIVE_TYPE_1001:
- case DRIVE_TYPE_8050:
- case DRIVE_TYPE_8250:
- memcpy(&(unit->rom[0x4000]), drive_rom1001,
- DRIVE_ROM1001_SIZE);
- break;
- case DRIVE_TYPE_9000:
- memcpy(&(unit->rom[0x4000]), drive_rom9000,
- DRIVE_ROM9000_SIZE);
- break;
+ if (unit->rom_type != unit->type) {
+ /* set this here to avoid recursion */
+ unit->rom_type = unit->type;
+
+ switch (unit->type) {
+ case DRIVE_TYPE_2031:
+ driverom_load("DosName2031", unit->rom, &rom2031_loaded,
+ DRIVE_ROM2031_SIZE, DRIVE_ROM2031_SIZE, "2031",
+ DRIVE_TYPE_2031, NULL);
+ /* ROM was loaded to the lower part of the buffer */
+ memcpy(&(unit->rom[0x4000]), unit->rom,
+ DRIVE_ROM2031_SIZE);
+ break;
+ case DRIVE_TYPE_2040:
+ driverom_load("DosName2040", unit->rom, &rom2040_loaded,
+ DRIVE_ROM2040_SIZE, DRIVE_ROM2040_SIZE, "2040",
+ DRIVE_TYPE_2040, NULL);
+ /* ROM was loaded to the lower part of the buffer */
+ memcpy(&(unit->rom[DRIVE_ROM_SIZE - DRIVE_ROM2040_SIZE]),
+ unit->rom, DRIVE_ROM2040_SIZE);
+ break;
+ case DRIVE_TYPE_3040:
+ driverom_load("DosName3040", unit->rom, &rom3040_loaded,
+ DRIVE_ROM3040_SIZE, DRIVE_ROM3040_SIZE, "3040",
+ DRIVE_TYPE_3040, NULL);
+ /* ROM was loaded to the lower part of the buffer */
+ memcpy(&(unit->rom[DRIVE_ROM_SIZE - DRIVE_ROM3040_SIZE]),
+ unit->rom, DRIVE_ROM3040_SIZE);
+ break;
+ case DRIVE_TYPE_4040:
+ driverom_load("DosName4040", unit->rom, &rom4040_loaded,
+ DRIVE_ROM4040_SIZE, DRIVE_ROM4040_SIZE, "4040",
+ DRIVE_TYPE_4040, NULL);
+ /* ROM was loaded to the lower part of the buffer */
+ memcpy(&(unit->rom[DRIVE_ROM_SIZE - DRIVE_ROM4040_SIZE]),
+ unit->rom, DRIVE_ROM4040_SIZE);
+ break;
+ case DRIVE_TYPE_1001:
+ case DRIVE_TYPE_8050:
+ case DRIVE_TYPE_8250:
+ driverom_load("DosName1001", unit->rom, &rom1001_loaded,
+ DRIVE_ROM1001_SIZE, DRIVE_ROM1001_SIZE, "1001/8050/8250",
+ DRIVE_TYPE_1001, NULL);
+ /* ROM was loaded to the lower part of the buffer */
+ memcpy(&(unit->rom[0x4000]), unit->rom,
+ DRIVE_ROM1001_SIZE);
+ break;
+ case DRIVE_TYPE_9000:
+ driverom_load("DosName9000", unit->rom, &rom9000_loaded,
+ DRIVE_ROM9000_SIZE, DRIVE_ROM9000_SIZE, "D9090/9060",
+ DRIVE_TYPE_9000, NULL);
+ /* ROM was loaded to the lower part of the buffer */
+ memcpy(&(unit->rom[0x4000]), unit->rom,
+ DRIVE_ROM9000_SIZE);
+ break;
+ }
+
+ /* if loading failed, set rom type to 0 */
+ if (!loaded) {
+ unit->rom_type = 0;
+ }
}
}
}
+/* check if the drive ROM is available for a given drive type, returns -1 on error */
int ieeerom_check_loaded(unsigned int type)
{
switch (type) {
Modified: trunk/vice/src/drive/tcbm/tcbm.c
===================================================================
--- trunk/vice/src/drive/tcbm/tcbm.c 2025-08-24 15:44:19 UTC (rev 45743)
+++ trunk/vice/src/drive/tcbm/tcbm.c 2025-08-27 09:02:36 UTC (rev 45744)
@@ -82,16 +82,19 @@
tpid_setup_context(drv);
}
+/* test all ROMs for existence, size */
void tcbm_drive_rom_load(void)
{
tcbmrom_load_1551();
}
+/* setup (=load) the ROM for a given disk unit nr */
void tcbm_drive_rom_setup_image(unsigned int dnr)
{
tcbmrom_setup_image(diskunit_context[dnr]);
}
+/* check if the drive ROM is available for a given drive type, returns -1 on error */
int tcbm_drive_rom_check_loaded(unsigned int type)
{
return tcbmrom_check_loaded(type);
Modified: trunk/vice/src/drive/tcbm/tcbmrom.c
===================================================================
--- trunk/vice/src/drive/tcbm/tcbmrom.c 2025-08-24 15:44:19 UTC (rev 45743)
+++ trunk/vice/src/drive/tcbm/tcbmrom.c 2025-08-27 09:02:36 UTC (rev 45744)
@@ -41,31 +41,44 @@
/* Logging goes here. */
static log_t tcbmrom_log;
-static uint8_t drive_rom1551[DRIVE_ROM1551_SIZE];
-
-/* If nonzero, the ROM image has been loaded. */
+/* If nonzero, the ROM image is available */
static unsigned int rom1551_loaded = 0;
-
+/* test ROM for existence, size */
int tcbmrom_load_1551(void)
{
- return driverom_load("DosName1551", drive_rom1551, &rom1551_loaded,
+ return driverom_test_load("DosName1551", &rom1551_loaded,
DRIVE_ROM1551_SIZE, DRIVE_ROM1551_SIZE, "1551",
DRIVE_TYPE_1551, NULL);
}
+/* setup (=load) the ROM for a given disk unit */
void tcbmrom_setup_image(diskunit_context_t *unit)
{
+ unsigned int loaded = 0;
if (rom_loaded) {
- switch (unit->type) {
- case DRIVE_TYPE_1551:
- memcpy(&(unit->rom[0x4000]), drive_rom1551,
- DRIVE_ROM1551_SIZE);
- break;
+ if (unit->rom_type != unit->type) {
+ /* set this here to avoid recursion */
+ unit->rom_type = unit->type;
+
+ switch (unit->type) {
+ case DRIVE_TYPE_1551:
+ driverom_load("DosName1551", unit->rom, &loaded,
+ DRIVE_ROM1551_SIZE, DRIVE_ROM1551_SIZE, "1551",
+ DRIVE_TYPE_1551, NULL);
+ /* ROM was loaded to the lower part of the buffer */
+ memcpy(&(unit->rom[DRIVE_ROM1551_SIZE]), unit->rom, DRIVE_ROM1551_SIZE);
+ break;
+ }
+ /* if loading failed, set rom type to 0 */
+ if (!loaded) {
+ unit->rom_type = 0;
+ }
}
}
}
+/* check if the drive ROM is available for a given drive type, returns -1 on error */
int tcbmrom_check_loaded(unsigned int type)
{
switch (type) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gp...@us...> - 2025-08-24 15:44:20
|
Revision: 45743
http://sourceforge.net/p/vice-emu/code/45743
Author: gpz
Date: 2025-08-24 15:44:19 +0000 (Sun, 24 Aug 2025)
Log Message:
-----------
when setting dqbb size, only (re)enable cartridge when it was actually enabled
Modified Paths:
--------------
trunk/vice/src/c64/cart/dqbb.c
Modified: trunk/vice/src/c64/cart/dqbb.c
===================================================================
--- trunk/vice/src/c64/cart/dqbb.c 2025-08-24 13:40:55 UTC (rev 45742)
+++ trunk/vice/src/c64/cart/dqbb.c 2025-08-24 15:44:19 UTC (rev 45743)
@@ -380,10 +380,13 @@
(val == 64) ||
(val == 128) ||
(val == 256)) {
+ int was_enabled = dqbb_enabled;
dqbb_deactivate();
dqbb_size = val;
dqbb_bank_mask = (val == 0) ? 0 : (val / 16) - 1;
- dqbb_activate();
+ if (was_enabled) {
+ dqbb_activate();
+ }
DBG(("set_dqbb_size size: %d mask: 0x%02x", dqbb_size, (unsigned int)dqbb_bank_mask));
} else {
return -1;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gp...@us...> - 2025-08-24 13:40:57
|
Revision: 45742
http://sourceforge.net/p/vice-emu/code/45742
Author: gpz
Date: 2025-08-24 13:40:55 +0000 (Sun, 24 Aug 2025)
Log Message:
-----------
add tcbm test, related to #2160
Modified Paths:
--------------
testprogs/testbench/plus4-testlist.in
testprogs/testbench/xplus4-testlist.txt
Added Paths:
-----------
testprogs/Plus4/tcbm/
testprogs/Plus4/tcbm/Makefile
testprogs/Plus4/tcbm/test.asm
testprogs/Plus4/tcbm/test.prg
Added: testprogs/Plus4/tcbm/Makefile
===================================================================
--- testprogs/Plus4/tcbm/Makefile (rev 0)
+++ testprogs/Plus4/tcbm/Makefile 2025-08-24 13:40:55 UTC (rev 45742)
@@ -0,0 +1,8 @@
+
+all: test.prg
+
+test.prg: test.asm
+ acme -f cbm -o test.prg test.asm
+
+clean:
+ $(RM) test.prg
Added: testprogs/Plus4/tcbm/test.asm
===================================================================
--- testprogs/Plus4/tcbm/test.asm (rev 0)
+++ testprogs/Plus4/tcbm/test.asm 2025-08-24 13:40:55 UTC (rev 45742)
@@ -0,0 +1,60 @@
+
+; related to https://sourceforge.net/p/vice-emu/bugs/2160/
+
+BORDERCOLOR = $ff19
+SCREENCOLOR = $ff15
+DEBUGREG = $fdcf ; http://plus4world.powweb.com/forum.php?postid=31417#31429
+
+TIA_DRIVE9 = $fec0
+TIA_DRIVE8 = $fee0
+
+ * = $1001
+
+ !byte $0C, $10, $E4, $07, $9E, $20, $34, $31, $31, $32, $00 ; 10 SYS 4112
+ !byte $00, $00
+
+ *= $1010
+
+ SEI
+ LDA #$FC
+ STA $FEF4 ; DDRB
+ LDA #$FC
+ STA $FEF1 ; PB
+ AND #$FC
+ CMP #$FC
+ BNE failure
+ LDA #$00
+ STA $FEF4 ; DDRB
+ LDA $FEF1 ; PB
+ AND #$FC
+ BNE failure
+ LDA #$3F
+ STA $FEF5 ; DDRC
+ LDA #$3F
+ STA $FEF2 ; PC
+ LDA $FEF2 ; PC
+ AND #$3F
+ CMP #$3F
+ BNE failure
+ LDA #$00
+ STA $FEF5 ; DDRC
+ LDA $FEF2 ; PC
+ AND #$3F
+ BNE failure
+
+ ; OK
+ LDA #(3 << 4) | 5 ; green
+ STA BORDERCOLOR
+ lda #$00
+ sta DEBUGREG
+
+ JMP $F445 ; exit to monitor
+
+failure:
+ ; ERROR
+ LDA #(3 << 4) | 2 ; red
+ STA BORDERCOLOR
+ lda #$ff
+ sta DEBUGREG
+
+ JMP $F445 ; exit to monitor
Added: testprogs/Plus4/tcbm/test.prg
===================================================================
(Binary files differ)
Index: testprogs/Plus4/tcbm/test.prg
===================================================================
--- testprogs/Plus4/tcbm/test.prg 2025-08-23 12:37:34 UTC (rev 45741)
+++ testprogs/Plus4/tcbm/test.prg 2025-08-24 13:40:55 UTC (rev 45742)
Property changes on: testprogs/Plus4/tcbm/test.prg
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/x-commodore-exec
\ No newline at end of property
Modified: testprogs/testbench/plus4-testlist.in
===================================================================
--- testprogs/testbench/plus4-testlist.in 2025-08-23 12:37:34 UTC (rev 45741)
+++ testprogs/testbench/plus4-testlist.in 2025-08-24 13:40:55 UTC (rev 45742)
@@ -15,6 +15,7 @@
################################################################################
../Plus4/openio/,outrun.prg,exitcode,10000000
../Plus4/openio/,outrun2.prg,exitcode,10000000
+../Plus4/tcbm/,test.prg,exitcode,10000000
################################################################################
# Joystick/Mouse
################################################################################
Modified: testprogs/testbench/xplus4-testlist.txt
===================================================================
--- testprogs/testbench/xplus4-testlist.txt 2025-08-23 12:37:34 UTC (rev 45741)
+++ testprogs/testbench/xplus4-testlist.txt 2025-08-24 13:40:55 UTC (rev 45742)
@@ -16,6 +16,7 @@
################################################################################
../Plus4/openio/,outrun.prg,exitcode,10000000
../Plus4/openio/,outrun2.prg,exitcode,10000000
+../Plus4/tcbm/,test.prg,exitcode,10000000
################################################################################
# Joystick/Mouse
################################################################################
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gp...@us...> - 2025-08-23 12:37:36
|
Revision: 45741
http://sourceforge.net/p/vice-emu/code/45741
Author: gpz
Date: 2025-08-23 12:37:34 +0000 (Sat, 23 Aug 2025)
Log Message:
-----------
fix DBG macro
Modified Paths:
--------------
trunk/vice/src/arch/shared/console_unix.c
trunk/vice/src/monitor/mon_util.c
trunk/vice/src/monitor/monitor.c
Modified: trunk/vice/src/arch/shared/console_unix.c
===================================================================
--- trunk/vice/src/arch/shared/console_unix.c 2025-08-23 12:21:50 UTC (rev 45740)
+++ trunk/vice/src/arch/shared/console_unix.c 2025-08-23 12:37:34 UTC (rev 45741)
@@ -49,7 +49,7 @@
/*#define DEBUG_CONSOLE*/
#ifdef DEBUG_CONSOLE
-#define DBG(x) log_printf
+#define DBG(x) log_printf x
#else
#define DBG(x)
#endif
Modified: trunk/vice/src/monitor/mon_util.c
===================================================================
--- trunk/vice/src/monitor/mon_util.c 2025-08-23 12:21:50 UTC (rev 45740)
+++ trunk/vice/src/monitor/mon_util.c 2025-08-23 12:37:34 UTC (rev 45741)
@@ -52,7 +52,7 @@
/*#define DEBUG_MONUTIL*/
#ifdef DEBUG_MONUTIL
-#define DBG(x) log_printf
+#define DBG(x) log_printf x
#else
#define DBG(x)
#endif
Modified: trunk/vice/src/monitor/monitor.c
===================================================================
--- trunk/vice/src/monitor/monitor.c 2025-08-23 12:21:50 UTC (rev 45740)
+++ trunk/vice/src/monitor/monitor.c 2025-08-23 12:37:34 UTC (rev 45741)
@@ -96,7 +96,7 @@
/*#define DEBUG_MONITOR*/
#ifdef DEBUG_MONITOR
-#define DBG(x) log_printf
+#define DBG(x) log_printf x
#else
#define DBG(x)
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rh...@us...> - 2025-08-23 12:21:52
|
Revision: 45740
http://sourceforge.net/p/vice-emu/code/45740
Author: rhialto
Date: 2025-08-23 12:21:50 +0000 (Sat, 23 Aug 2025)
Log Message:
-----------
Tabs to spaces...
Modified Paths:
--------------
trunk/vice/src/pet/petmem.c
Modified: trunk/vice/src/pet/petmem.c
===================================================================
--- trunk/vice/src/pet/petmem.c 2025-08-23 12:13:41 UTC (rev 45739)
+++ trunk/vice/src/pet/petmem.c 2025-08-23 12:21:50 UTC (rev 45740)
@@ -641,8 +641,8 @@
spet_ctrlwp = 1;
spet_firq_disabled = 0;
if (spet_flat_mode) {
- spet_flat_mode = 0;
- mem_initialize_memory_6809_banked();
+ spet_flat_mode = 0;
+ mem_initialize_memory_6809_banked();
}
petmem_map_reg = 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rh...@us...> - 2025-08-23 12:13:43
|
Revision: 45739
http://sourceforge.net/p/vice-emu/code/45739
Author: rhialto
Date: 2025-08-23 12:13:41 +0000 (Sat, 23 Aug 2025)
Log Message:
-----------
Small SuperPET banking corrections.
- the SYNC instruction resets the whole banking register to 00
- track the bank number in spet_bank again since this is used for display to the user
Modified Paths:
--------------
trunk/vice/src/pet/petmem.c
Modified: trunk/vice/src/pet/petmem.c
===================================================================
--- trunk/vice/src/pet/petmem.c 2025-08-22 18:03:48 UTC (rev 45738)
+++ trunk/vice/src/pet/petmem.c 2025-08-23 12:13:41 UTC (rev 45739)
@@ -65,6 +65,7 @@
static uint8_t mem_read_patchbuf(uint16_t addr);
static void mem_initialize_memory_6809_flat(void);
+static void mem_initialize_memory_6809_banked(void);
uint8_t petmem_2001_buf_ef[256];
@@ -629,6 +630,7 @@
void set_spet_bank(int banknr)
{
+ spet_bank = banknr;
spet_bank_ptr = &mem_ram[EXT_RAM + (banknr << 12)];
}
@@ -637,8 +639,11 @@
spet_ramen = 1;
set_spet_bank(0);
spet_ctrlwp = 1;
- spet_flat_mode = 0;
spet_firq_disabled = 0;
+ if (spet_flat_mode) {
+ spet_flat_mode = 0;
+ mem_initialize_memory_6809_banked();
+ }
petmem_map_reg = 0;
petmem_ramON = 0;
@@ -697,7 +702,7 @@
spet_firq_disabled = (value & 0x20);
spet_flat_mode = (value & 0x40);
spet_ctrlwp = !(value & 0x80);
- /* printf("spet_bank := %x ", spet_bank);
+ /* printf("spet_bank := %2d ", spet_bank);
printf("spet_flat_mode := %d ", !!spet_flat_mode);
printf("spet_firq_disabled := %d ", !!spet_firq_disabled);
printf("spet_ctrlwp := %d\n", !!spet_ctrlwp); */
@@ -710,14 +715,14 @@
*/
mem_initialize_memory_6809_flat();
/* mon_bank(e_default_space, "extram");
- extern WORD PC;
+ extern uint16_t PC;
printf("next opcode: %04X: banked %02X, flat %02X\n",
PC,
- mem_ram[EXT_RAM + spet_bank_4k + (PC & 0x0FFF)],
+ spet_bank_ptr[PC & 0x0FFF],
mem_ram[EXT_RAM + PC]
); */
}
- /* else if (spet_bank_4k != old_spet_bank_4k) {
+ /* else if (spet_bank != old_spet_bank) {
* maincpu_resync_limits(); notyet: 6809 doesn't use bank_base yet.
* }
*/
@@ -1385,8 +1390,8 @@
if (value & FFF0_SCREEN_PEEK_THROUGH) {
/* screen memory mapped through */
for (; l < 0x90; l++) {
- _mem_read_tab[l] = ram_read;
- _mem_write_tab[l] = ram_store;
+ _mem_read_tab[l] = read_vmem;
+ _mem_write_tab[l] = store_vmem;
_mem_read_base_tab[l] = NULL;
mem_read_limit_tab[l] = 0;
}
@@ -1633,17 +1638,23 @@
}
/*
- * The memory mapping is probably reset even if FIRQ is disabled
- * (see http://mikenaberezny.com/wp-content/uploads/2009/11/superos9-mmu-schematic-r2.jpg )
- * but since a missing FIRQ basically halts the 6809, there is little
- * difference in practice.
+ * Reset the memory mapping to 00 if a FIRQ happens.
+ * See http://mikenaberezny.com/wp-content/uploads/2009/11/superos9-mmu-schematic-r2.jpg
+ * Note that it swaps the meaning of Q5 and Q6.
*/
int superpet_sync(void)
{
+ if (spet_firq_disabled) {
+ log_error(pet_mem_log, "SuperPET: SYNC encountered, but no FIRQ possible!");
+ return 1;
+ }
+ set_spet_bank(0);
+ spet_ctrlwp = 1;
spet_flat_mode = 0;
+ spet_firq_disabled = 0;
mem_initialize_memory_6809_banked();
/* mon_bank(e_default_space, "6809");
- extern WORD PC;
+ extern uint16_t PC;
printf("next opcode: %04X: banked %02X, flat %02X\n",
PC,
mem_ram[EXT_RAM + spet_bank_4k + (PC & 0x0FFF)],
@@ -1650,12 +1661,7 @@
mem_ram[EXT_RAM + PC]
); */
- if (spet_firq_disabled) {
- log_error(pet_mem_log, "SuperPET: SYNC encountered, but no FIRQ possible!");
- return 1;
- } else {
- return 0;
- }
+ return 0;
}
/* This does the plain 8032 configuration, as 8096 stuff only comes up when
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gp...@us...> - 2025-08-22 18:03:49
|
Revision: 45738
http://sourceforge.net/p/vice-emu/code/45738
Author: gpz
Date: 2025-08-22 18:03:48 +0000 (Fri, 22 Aug 2025)
Log Message:
-----------
init vte_console.console_cannot_output with 0 once the window was created, and set mon_console_suspend_on_leaving to 0 when leaving the monitor with 'g'. should fix #2158
Modified Paths:
--------------
trunk/vice/src/arch/gtk3/uimon.c
trunk/vice/src/arch/shared/console_unix.c
trunk/vice/src/monitor/mon_util.c
trunk/vice/src/monitor/monitor.c
Modified: trunk/vice/src/arch/gtk3/uimon.c
===================================================================
--- trunk/vice/src/arch/gtk3/uimon.c 2025-08-18 13:33:45 UTC (rev 45737)
+++ trunk/vice/src/arch/gtk3/uimon.c 2025-08-22 18:03:48 UTC (rev 45738)
@@ -81,6 +81,14 @@
#include "widgethelpers.h"
#include "uidata.h"
+/*#define DEBUG_UIMON*/
+
+#ifdef DEBUG_UIMON
+#define DBG(x) log_printf
+#else
+#define DBG(x)
+#endif
+
static gboolean uimon_window_open_impl(gpointer user_data);
static gboolean uimon_window_resume_impl(gpointer user_data);
@@ -1376,6 +1384,7 @@
NULL);
vte_console.console_can_stay_open = 1;
+ vte_console.console_cannot_output = 0;
uimon_set_font();
} else {
Modified: trunk/vice/src/arch/shared/console_unix.c
===================================================================
--- trunk/vice/src/arch/shared/console_unix.c 2025-08-18 13:33:45 UTC (rev 45737)
+++ trunk/vice/src/arch/shared/console_unix.c 2025-08-22 18:03:48 UTC (rev 45738)
@@ -46,7 +46,14 @@
#include "lib/linenoise-ng/linenoise.h"
+/*#define DEBUG_CONSOLE*/
+#ifdef DEBUG_CONSOLE
+#define DBG(x) log_printf
+#else
+#define DBG(x)
+#endif
+
typedef struct console_private_s {
FILE *input;
FILE *output;
@@ -98,6 +105,9 @@
console->console_can_stay_open = 1;
console->console_cannot_output = 0;
+ DBG(("native_console_open console:%p console_can_stay_open:%d console_cannot_output:%d",
+ console, console->console_can_stay_open, console->console_cannot_output));
+
return console;
exitnull:
Modified: trunk/vice/src/monitor/mon_util.c
===================================================================
--- trunk/vice/src/monitor/mon_util.c 2025-08-18 13:33:45 UTC (rev 45737)
+++ trunk/vice/src/monitor/mon_util.c 2025-08-22 18:03:48 UTC (rev 45738)
@@ -49,10 +49,18 @@
#include "uimon.h"
#include "vsyncapi.h"
+/*#define DEBUG_MONUTIL*/
+
+#ifdef DEBUG_MONUTIL
+#define DBG(x) log_printf
+#else
+#define DBG(x)
+#endif
+
static char *bigbuffer = NULL;
static const unsigned int bigbuffersize = 10000;
static unsigned int bigbufferwrite = 0;
-static unsigned int bigbuffermode = 0; /* 0: ascii, 1: petscii, 2: scrcode */
+static unsigned int bigbuffermode = 0; /* 0: ascii, 1: petscii, 2: scrcode, 3: petscii (uppercase), 4: scrcode (uppercase) */
static FILE *mon_log_file = NULL;
@@ -188,6 +196,9 @@
int rv = 0;
int len;
+ DBG(("console_log:%p console_cannot_output:%d",
+ console_log, console_log ? console_log->console_cannot_output : -1));
+
if (!console_log || console_log->console_cannot_output) {
if (mode != bigbuffermode) {
Modified: trunk/vice/src/monitor/monitor.c
===================================================================
--- trunk/vice/src/monitor/monitor.c 2025-08-18 13:33:45 UTC (rev 45737)
+++ trunk/vice/src/monitor/monitor.c 2025-08-22 18:03:48 UTC (rev 45738)
@@ -93,6 +93,14 @@
#include "video.h"
#include "vsync.h"
+/*#define DEBUG_MONITOR*/
+
+#ifdef DEBUG_MONITOR
+#define DBG(x) log_printf
+#else
+#define DBG(x)
+#endif
+
/*
INITBREAK switched to a break point so that the first instruction doesn't
run when '-initbreak reset' is used.
@@ -161,6 +169,7 @@
* different from what keep_monitor_open does :)
*/
static int mon_console_suspend_on_leaving = 1;
+
/* flag used by the eXit command. it will force the monitor to close regardless
* of keep_monitor_open.
*/
@@ -989,6 +998,7 @@
void mon_go(void)
{
exit_mon = 1;
+ mon_console_suspend_on_leaving = 0;
if (should_pause_on_exit_mon || ui_pause_active()) {
should_pause_on_exit_mon = false;
@@ -3043,7 +3053,8 @@
mon_console_close_on_leaving = 0;
if (console_mode) {
- /* Shitty hack. We should support the console size etc. */
+ /* Shitty hack. We should support the console size etc.
+ NOTE: this is (only) for the case when VICE runs in console mode (-console) */
static console_t console_log_console = { TTY_COLUMNS, TTY_ROWS, 0, 0, NULL };
console_log = &console_log_console;
} else if (monitor_is_remote() || monitor_is_binary()) {
@@ -3058,6 +3069,7 @@
uimon_set_interface(mon_interfaces, NUM_MEMSPACES);
}
}
+ DBG(("monitor_open console_mode:%d console_log:%p", console_mode, console_log));
if (console_log == NULL) {
log_error(LOG_DEFAULT, "monitor_open: could not open monitor console.");
@@ -3235,7 +3247,7 @@
last_cmd = cmd;
}
- uimon_notify_change(); /* @SRT */
+ uimon_notify_change();
return exit_mon;
}
@@ -3283,6 +3295,7 @@
console_log = NULL;
}
+ DBG(("monitor_close console_log:%p", console_log));
vsync_suspend_speed_eval();
}
@@ -3291,6 +3304,8 @@
char prompt[40];
char *p;
+ DBG(("monitor_startup console_log:%p", console_log));
+
if (inside_monitor) {
/*
* Drive cpu interrupt can enter the monitor .. and then the monitor
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gp...@us...> - 2025-08-18 13:33:52
|
Revision: 45737
http://sourceforge.net/p/vice-emu/code/45737
Author: gpz
Date: 2025-08-18 13:33:45 +0000 (Mon, 18 Aug 2025)
Log Message:
-----------
add support for Protovisions 'Megabyter' cartridge
Modified Paths:
--------------
trunk/vice/doc/vice.texi
trunk/vice/src/Makefile.am
trunk/vice/src/arch/gtk3/uisettings.c
trunk/vice/src/arch/gtk3/widgets/Makefile.am
trunk/vice/src/arch/sdl/menu_c64cart.c
trunk/vice/src/c64/cart/Makefile.am
trunk/vice/src/c64/cart/c64cart.c
trunk/vice/src/c64/cart/c64carthooks.c
trunk/vice/src/c64/cart/c64cartmem.c
trunk/vice/src/cartridge.h
trunk/vice/src/core/Makefile.am
trunk/vice/src/tools/cartconv/c64-cartridges.c
trunk/vice/src/tools/cartconv/cartconv.c
Added Paths:
-----------
trunk/vice/src/arch/gtk3/widgets/settings_megabyter.c
trunk/vice/src/arch/gtk3/widgets/settings_megabyter.h
trunk/vice/src/c64/cart/megabyter.c
trunk/vice/src/c64/cart/megabyter.h
trunk/vice/src/core/flash800core.c
trunk/vice/src/flash800.h
Modified: trunk/vice/doc/vice.texi
===================================================================
--- trunk/vice/doc/vice.texi 2025-08-16 10:52:49 UTC (rev 45736)
+++ trunk/vice/doc/vice.texi 2025-08-18 13:33:45 UTC (rev 45737)
@@ -10207,6 +10207,8 @@
84: Profi-DOS
@item
85: Magic Desk 16
+@item
+86: Protovision "Megabyter"
@end itemize
@vindex CartridgeFile
@@ -10463,6 +10465,15 @@
@item MagicVoiceImage
String specifying the filename of the Magic Voice ROM image.
+@vindex MegabyterWriteCRT
+@item MegabyterWriteCRT
+Boolean, if true write back the Megabyter image file automatically, incase the
+contents changed, when detaching or quitting the emulator.
+
+@vindex MegabyterOptimizeCRT
+@item MegabyterOptimizeCRT
+Boolean, if true omit empty (filled with $ff) banks from the .crt image when writing.
+
@vindex MMC64
@item MMC64
Boolean specifying whether the MMC64 should be emulated or not.
@@ -11174,6 +11185,10 @@
@item -cartmach5 <name>
Attach raw 8KiB MACH 5 cartridge image.
+@findex -cartmb
+@item -cartmb <name>
+Attach raw Megabyter cartridge image.
+
@findex -cartmd
@item -cartmd <name>
Attach raw 32/64/128KiB Magic Desk cartridge image.
@@ -11198,6 +11213,18 @@
@item -cartmikro <name>
Attach raw 8KiB Mikro Assembler cartridge image.
+@findex -megabytercrtwrite, +megabytercrtwrite
+@item -megabytercrtwrite
+@itemx +megabytercrtwrite
+Allow/Disallow writing to Megabyter .crt image
+(@code{MegabyterWriteCRT=1}, @code{MegabyterWriteCRT=0}).
+
+@findex -megabytercrtoptimize, +megabytercrtoptimize
+@item -megabytercrtoptimize
+@itemx +megabytercrtoptimize
+Allow/Disallow Megabyter .crt image optimizing (omitting of empty banks) on write
+(@code{MegabyterOptimizeCRT=1}, @code{MegabyterOptimizeCRT=0}).
+
@findex -mmc64, +mmc64
@item -mmc64
@itemx +mmc64
@@ -23825,6 +23852,8 @@
Magic Formel .crt file
@item max
MAX Basic .crt file
+@item mb
+Megabyter .crt file
@item mikro
Mikro Assembler .crt file
@item mmc64
@@ -35006,7 +35035,7 @@
@item EXROM
@tab active (lo) (0)
@item GAME
-@tab active (hi) (0)
+@tab active (lo) (0)
@item Startup mode
@tab 16KiB Game
@item Load address
@@ -35038,7 +35067,39 @@
used by "SNK vs CAPCOM - Stronger Edition"
+
@c @node FIXME
+@subsubsection 86 - Protovision "Megabyter"
+
+@multitable @columnfractions .3 .7
+@item Size
+@tab 1024KiB (128 banks of 8KiB each)
+@item EXROM
+@tab active (lo) (0)
+@item GAME
+@tab inactive (hi) (1)
+@item Startup mode
+@tab 8KiB Game
+@item Load address
+@tab (banks 0-127) - $8000-9FFF
+@end multitable
+
+@example
+ 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F ASCII
+ ----------------------------------------------- ----------------
+000000: 43 36 34 20 43 41 52 54 52 49 44 47 45 20 20 20 C64 CARTRIDGE
+000010: 00 00 00 40 01 00 00 56 00 01 00 00 00 00 00 00 ...@...V........
+000020: 50 54 56 20 4d 65 67 61 62 79 74 65 72 00 00 00 PTV Megabyter...
+000030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+000040: 43 48 49 50 00 00 20 10 00 02 00 00 80 00 20 00 CHIP.. ....... .
+000050: 09 80 00 00 c3 c2 cd 38 30 78 20 d3 82 a9 00 8d .......80x .....
+...
+100820: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
+100830: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
+@end example
+
+
+@c @node FIXME
@subsection C128 Cartridge Specifics
Note: Cartridges that work on both C64 and C128 get "C64 Cartridge" type and get a
Modified: trunk/vice/src/Makefile.am
===================================================================
--- trunk/vice/src/Makefile.am 2025-08-16 10:52:49 UTC (rev 45736)
+++ trunk/vice/src/Makefile.am 2025-08-18 13:33:45 UTC (rev 45737)
@@ -192,6 +192,7 @@
fixpoint.h \
fsdevice.h \
flash040.h \
+ flash800.h \
fliplist.h \
fullscreen.h \
gcr.h \
Modified: trunk/vice/src/arch/gtk3/uisettings.c
===================================================================
--- trunk/vice/src/arch/gtk3/uisettings.c 2025-08-16 10:52:49 UTC (rev 45736)
+++ trunk/vice/src/arch/gtk3/uisettings.c 2025-08-18 13:33:45 UTC (rev 45737)
@@ -115,6 +115,7 @@
#endif
#include "settings_misc.h"
#include "settings_minimon.h"
+#include "settings_megabyter.h"
#include "settings_megacart.h"
#include "settings_mmc64.h"
#include "settings_mmcr.h"
@@ -319,6 +320,9 @@
{ CARTRIDGE_NAME_GMOD3,
"gmod3",
settings_gmod3_widget_create, NULL },
+ { CARTRIDGE_NAME_MEGABYTER,
+ "megabyter",
+ settings_megabyter_widget_create, NULL },
UI_SETTINGS_SEPARATOR,
@@ -458,6 +462,9 @@
{ CARTRIDGE_NAME_GMOD3,
"gmod3",
settings_gmod3_widget_create, NULL },
+ { CARTRIDGE_NAME_MEGABYTER,
+ "megabyter",
+ settings_megabyter_widget_create, NULL },
UI_SETTINGS_SEPARATOR,
@@ -587,6 +594,9 @@
{ CARTRIDGE_NAME_GMOD3,
"gmod3",
settings_gmod3_widget_create, NULL },
+ { CARTRIDGE_NAME_MEGABYTER,
+ "megabyter",
+ settings_megabyter_widget_create, NULL },
UI_SETTINGS_SEPARATOR,
Modified: trunk/vice/src/arch/gtk3/widgets/Makefile.am
===================================================================
--- trunk/vice/src/arch/gtk3/widgets/Makefile.am 2025-08-16 10:52:49 UTC (rev 45736)
+++ trunk/vice/src/arch/gtk3/widgets/Makefile.am 2025-08-18 13:33:45 UTC (rev 45737)
@@ -144,6 +144,7 @@
settings_keyboard.c \
settings_ltkernal.c \
settings_magicvoice.c \
+ settings_megabyter.c \
settings_megacart.c \
settings_midi.c \
settings_misc.c \
@@ -316,6 +317,7 @@
settings_keyboard.h \
settings_ltkernal.h \
settings_magicvoice.h \
+ settings_megabyter.h \
settings_megacart.h \
settings_midi.h \
settings_misc.h \
Added: trunk/vice/src/arch/gtk3/widgets/settings_megabyter.c
===================================================================
--- trunk/vice/src/arch/gtk3/widgets/settings_megabyter.c (rev 0)
+++ trunk/vice/src/arch/gtk3/widgets/settings_megabyter.c 2025-08-18 13:33:45 UTC (rev 45737)
@@ -0,0 +1,88 @@
+/** \file settings_megabyter.c
+ * \brief Settings widget to control Megabyter resources
+ *
+ * \author Bas Wassink <b.w...@zi...>
+ */
+
+/*
+ * $VICERES MegabyterWriteCRT x64 x64sc xscpu64 x128
+ * $VICERES MegabyterOptimizeCRT x64 x64sc xscpu64 x128
+ */
+
+/*
+ * This file is part of VICE, the Versatile Commodore Emulator.
+ * See README for copyright notice.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ *
+ */
+
+#include "vice.h"
+#include <gtk/gtk.h>
+
+#include "cartridge.h"
+#include "vice_gtk3.h"
+
+#include "settings_megabyter.h"
+
+
+/** \brief Create widget for EasyFlash primary image
+ *
+ * \return GtkGrid
+ */
+static GtkWidget *create_primary_image_widget(void)
+{
+ GtkWidget *image;
+
+ image = cart_image_widget_new(CARTRIDGE_MEGABYTER,
+ CARTRIDGE_NAME_MEGABYTER,
+ CART_IMAGE_PRIMARY,
+ "cartridge",
+ NULL,
+ TRUE,
+ TRUE);
+ cart_image_widget_append_check(image,
+ "MegabyterWriteCRT",
+ "Save image when changed");
+ cart_image_widget_append_check(image,
+ "MegabyterOptimizeCRT",
+ "Optimize image when saving");
+ return image;
+}
+
+
+/** \brief Create EasyFlash widget
+ *
+ * \param[in] parent parent widget (unused)
+ *
+ * \return GtkGrid
+ */
+GtkWidget *settings_megabyter_widget_create(GtkWidget *parent)
+{
+ GtkWidget *grid;
+ GtkWidget *primary;
+
+ grid = gtk_grid_new();
+ gtk_grid_set_column_spacing(GTK_GRID(grid), 16);
+ gtk_grid_set_column_homogeneous(GTK_GRID(grid), FALSE);
+ gtk_grid_set_row_spacing(GTK_GRID(grid), 16);
+
+ primary = create_primary_image_widget();
+ gtk_grid_attach(GTK_GRID(grid), primary, 0, 0, 2, 1);
+
+ gtk_widget_show_all(grid);
+ return grid;
+}
Added: trunk/vice/src/arch/gtk3/widgets/settings_megabyter.h
===================================================================
--- trunk/vice/src/arch/gtk3/widgets/settings_megabyter.h (rev 0)
+++ trunk/vice/src/arch/gtk3/widgets/settings_megabyter.h 2025-08-18 13:33:45 UTC (rev 45737)
@@ -0,0 +1,35 @@
+/** \file settings_megabyter.h
+ * \brief Settings widget to control Megabyter resources - header
+ *
+ * \author Bas Wassink <b.w...@zi...>
+ */
+
+/*
+ * This file is part of VICE, the Versatile Commodore Emulator.
+ * See README for copyright notice.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ *
+ */
+
+#ifndef VICE_SETTINGS_MEGABYTER_H
+#define VICE_SETTINGS_MEGABYTER_H
+
+#include <gtk/gtk.h>
+
+GtkWidget *settings_megabyter_widget_create(GtkWidget *parent);
+
+#endif
Modified: trunk/vice/src/arch/sdl/menu_c64cart.c
===================================================================
--- trunk/vice/src/arch/sdl/menu_c64cart.c 2025-08-16 10:52:49 UTC (rev 45736)
+++ trunk/vice/src/arch/sdl/menu_c64cart.c 2025-08-18 13:33:45 UTC (rev 45737)
@@ -170,6 +170,7 @@
{ CARTRIDGE_ISEPIC, "IsepicCartridgeEnabled", "Isepicfilename" },
{ CARTRIDGE_EASYFLASH, NULL, NULL },
{ CARTRIDGE_GEORAM, "GEORAM", "GEORAMfilename" },
+ { CARTRIDGE_MEGABYTER, NULL, NULL, },
{ CARTRIDGE_MMC64, "MMC64", "MMC64BIOSfilename" },
{ CARTRIDGE_MMC_REPLAY, NULL, NULL },
{ CARTRIDGE_GMOD2, NULL, NULL },
@@ -790,6 +791,37 @@
};
+/* Megabyter */
+
+UI_MENU_DEFINE_TOGGLE(MegabyterWriteCRT)
+UI_MENU_DEFINE_TOGGLE(MegabyterOptimizeCRT)
+
+#define MEGABYTER_OFFSET_FLUSH 2
+#define MEGABYTER_OFFSET_SAVE 3
+
+static ui_menu_entry_t megabyter_cart_menu[] = {
+ { .string = "Save image on detach",
+ .type = MENU_ENTRY_RESOURCE_TOGGLE,
+ .callback = toggle_MegabyterWriteCRT_callback
+ },
+ { .string = "Optimize image on write",
+ .type = MENU_ENTRY_RESOURCE_TOGGLE,
+ .callback = toggle_MegabyterOptimizeCRT_callback
+ },
+ { .string = "Save image now", /* 2 */
+ .type = MENU_ENTRY_OTHER,
+ .callback = c64_cart_flush_callback,
+ .data = (ui_callback_data_t)CARTRIDGE_MEGABYTER
+ },
+ { .string = "Save image as", /* 3 */
+ .type = MENU_ENTRY_OTHER,
+ .callback = c64_cart_save_callback,
+ .data = (ui_callback_data_t)CARTRIDGE_MEGABYTER
+ },
+ SDL_MENU_LIST_END
+};
+
+
/* MMC64 */
UI_MENU_DEFINE_RADIO(MMC64ClockPort)
@@ -1696,6 +1728,7 @@
{ isepic_cart_menu, ISEPIC_OFFSET_FLUSH, CARTRIDGE_ISEPIC },
{ easyflash_cart_menu, EASYFLASH_OFFSET_FLUSH, CARTRIDGE_EASYFLASH },
{ georam_menu, GEORAM_OFFSET_FLUSH, CARTRIDGE_GEORAM },
+ { megabyter_cart_menu, MEGABYTER_OFFSET_FLUSH, CARTRIDGE_MEGABYTER },
{ mmc64_cart_menu, MMC64_OFFSET_FLUSH, CARTRIDGE_MMC64 },
{ mmcreplay_cart_menu, MMCR_OFFSET_FLUSH, CARTRIDGE_MMC_REPLAY },
{ retroreplay_cart_menu, RETROREPLAY_OFFSET_FLUSH, CARTRIDGE_RETRO_REPLAY },
@@ -1724,6 +1757,7 @@
{ isepic_cart_menu, ISEPIC_OFFSET_SAVE, CARTRIDGE_ISEPIC },
{ easyflash_cart_menu, EASYFLASH_OFFSET_SAVE, CARTRIDGE_EASYFLASH },
{ georam_menu, GEORAM_OFFSET_SAVE, CARTRIDGE_GEORAM },
+ { megabyter_cart_menu, MEGABYTER_OFFSET_SAVE, CARTRIDGE_MEGABYTER },
{ mmc64_cart_menu, MMC64_OFFSET_SAVE, CARTRIDGE_MMC64 },
{ mmcreplay_cart_menu, MMCR_OFFSET_SAVE, CARTRIDGE_MMC_REPLAY },
{ retroreplay_cart_menu, RETROREPLAY_OFFSET_SAVE, CARTRIDGE_RETRO_REPLAY },
Modified: trunk/vice/src/c64/cart/Makefile.am
===================================================================
--- trunk/vice/src/c64/cart/Makefile.am 2025-08-16 10:52:49 UTC (rev 45736)
+++ trunk/vice/src/c64/cart/Makefile.am 2025-08-18 13:33:45 UTC (rev 45737)
@@ -150,6 +150,8 @@
magicvoice.h \
maxbasic.c \
maxbasic.h \
+ megabyter.c \
+ megabyter.h \
mikroass.c \
mikroass.h \
mmcreplay.c \
Modified: trunk/vice/src/c64/cart/c64cart.c
===================================================================
--- trunk/vice/src/c64/cart/c64cart.c 2025-08-16 10:52:49 UTC (rev 45736)
+++ trunk/vice/src/c64/cart/c64cart.c 2025-08-18 13:33:45 UTC (rev 45737)
@@ -108,6 +108,7 @@
#include "magicformel.h"
#include "magicvoice.h"
#include "maxbasic.h"
+#include "megabyter.h"
#include "mikroass.h"
#include "mmc64.h"
#include "mmcreplay.h"
@@ -294,6 +295,7 @@
{ CARTRIDGE_NAME_MAGIC_FORMEL, CARTRIDGE_MAGIC_FORMEL, CARTRIDGE_GROUP_FREEZER },
{ CARTRIDGE_NAME_MAGIC_VOICE, CARTRIDGE_MAGIC_VOICE, CARTRIDGE_GROUP_UTIL },
{ CARTRIDGE_NAME_MAX_BASIC, CARTRIDGE_MAX_BASIC, CARTRIDGE_GROUP_UTIL },
+ { CARTRIDGE_NAME_MEGABYTER, CARTRIDGE_MEGABYTER, CARTRIDGE_GROUP_GAME },
{ CARTRIDGE_NAME_MIKRO_ASSEMBLER, CARTRIDGE_MIKRO_ASSEMBLER, CARTRIDGE_GROUP_UTIL },
{ CARTRIDGE_NAME_MMC64, CARTRIDGE_MMC64, CARTRIDGE_GROUP_UTIL },
{ CARTRIDGE_NAME_MMC_REPLAY, CARTRIDGE_MMC_REPLAY, CARTRIDGE_GROUP_FREEZER },
@@ -924,6 +926,9 @@
case CARTRIDGE_MAX_BASIC:
rc = maxbasic_crt_attach(fd, rawcart);
break;
+ case CARTRIDGE_MEGABYTER:
+ rc = megabyter_crt_attach(fd, rawcart, filename);
+ break;
case CARTRIDGE_MIKRO_ASSEMBLER:
rc = mikroass_crt_attach(fd, rawcart);
break;
Modified: trunk/vice/src/c64/cart/c64carthooks.c
===================================================================
--- trunk/vice/src/c64/cart/c64carthooks.c 2025-08-16 10:52:49 UTC (rev 45736)
+++ trunk/vice/src/c64/cart/c64carthooks.c 2025-08-18 13:33:45 UTC (rev 45737)
@@ -117,6 +117,7 @@
#include "magicformel.h"
#include "magicvoice.h"
#include "maxbasic.h"
+#include "megabyter.h"
#include "mikroass.h"
#include "mmc64.h"
#include "mmcreplay.h"
@@ -373,6 +374,9 @@
{ "-cartmd16", CALL_FUNCTION, CMDLINE_ATTRIB_NEED_ARGS,
cart_attach_cmdline, (void *)CARTRIDGE_MAGIC_DESK_16, NULL, NULL,
"<Name>", "Attach raw up to 2048KiB Magic Desk 16K cartridge image" },
+ { "-cartmb", CALL_FUNCTION, CMDLINE_ATTRIB_NEED_ARGS,
+ cart_attach_cmdline, (void *)CARTRIDGE_MEGABYTER, NULL, NULL,
+ "<Name>", "Attach raw 1024KiB " CARTRIDGE_NAME_MEGABYTER " cartridge image" },
{ "-cartmf", CALL_FUNCTION, CMDLINE_ATTRIB_NEED_ARGS,
cart_attach_cmdline, (void *)CARTRIDGE_MAGIC_FORMEL, NULL, NULL,
"<Name>", "Attach raw Magic Formel cartridge image" },
@@ -534,6 +538,7 @@
|| ide64_cmdline_options_init() < 0
|| ieeeflash64_cmdline_options_init() < 0
|| ltkernal_cmdline_options_init() < 0
+ || megabyter_cmdline_options_init() < 0
|| mmcreplay_cmdline_options_init() < 0
|| retroreplay_cmdline_options_init() < 0
|| rexramfloppy_cmdline_options_init() < 0
@@ -600,6 +605,7 @@
|| gmod3_resources_init() < 0
|| ide64_resources_init() < 0
|| ltkernal_resources_init() < 0
+ || megabyter_resources_init() < 0
|| mmcreplay_resources_init() < 0
|| retroreplay_resources_init() < 0
|| rexramfloppy_resources_init() < 0
@@ -651,6 +657,7 @@
gmod3_resources_shutdown();
ide64_resources_shutdown();
ltkernal_resources_shutdown();
+ megabyter_resources_shutdown();
mmcreplay_resources_shutdown();
retroreplay_resources_shutdown();
rexramfloppy_resources_shutdown();
@@ -1024,6 +1031,8 @@
return magicformel_bin_attach(filename, rawcart);
case CARTRIDGE_MAX_BASIC:
return maxbasic_bin_attach(filename, rawcart);
+ case CARTRIDGE_MEGABYTER:
+ return megabyter_bin_attach(filename, rawcart);
case CARTRIDGE_MIKRO_ASSEMBLER:
return mikroass_bin_attach(filename, rawcart);
case CARTRIDGE_MMC_REPLAY:
@@ -1294,6 +1303,9 @@
case CARTRIDGE_MAX_BASIC:
maxbasic_config_setup(rawcart);
break;
+ case CARTRIDGE_MEGABYTER:
+ megabyter_config_setup(rawcart);
+ break;
case CARTRIDGE_MIKRO_ASSEMBLER:
mikroass_config_setup(rawcart);
break;
@@ -1909,6 +1921,9 @@
case CARTRIDGE_MAX_BASIC:
maxbasic_detach();
break;
+ case CARTRIDGE_MEGABYTER:
+ megabyter_detach();
+ break;
case CARTRIDGE_MIKRO_ASSEMBLER:
mikroass_detach();
break;
@@ -2220,6 +2235,9 @@
case CARTRIDGE_MAX_BASIC:
maxbasic_config_init();
break;
+ case CARTRIDGE_MEGABYTER:
+ megabyter_config_init();
+ break;
case CARTRIDGE_MIKRO_ASSEMBLER:
mikroass_config_init();
break;
@@ -2922,6 +2940,8 @@
return gmod2_flush_image();
case CARTRIDGE_GMOD3:
return gmod3_flush_image();
+ case CARTRIDGE_MEGABYTER:
+ return megabyter_flush_image();
case CARTRIDGE_MMC_REPLAY:
return mmcreplay_flush_image();
case CARTRIDGE_RETRO_REPLAY:
@@ -3000,6 +3020,8 @@
return gmod2_bin_save(filename);
case CARTRIDGE_GMOD3:
return gmod3_bin_save(filename);
+ case CARTRIDGE_MEGABYTER:
+ return megabyter_bin_save(filename);
case CARTRIDGE_MMC_REPLAY:
return mmcreplay_bin_save(filename);
case CARTRIDGE_RETRO_REPLAY:
@@ -3071,6 +3093,8 @@
return gmod2_crt_save(filename);
case CARTRIDGE_GMOD3:
return gmod3_crt_save(filename);
+ case CARTRIDGE_MEGABYTER:
+ return megabyter_crt_save(filename);
case CARTRIDGE_MMC_REPLAY:
return mmcreplay_crt_save(filename);
case CARTRIDGE_RETRO_REPLAY:
@@ -3221,6 +3245,9 @@
case CARTRIDGE_LT_KERNAL:
ltkernal_mmu_translate(addr, base, start, limit);
return;
+ case CARTRIDGE_MEGABYTER:
+ megabyter_mmu_translate(addr, base, start, limit);
+ return;
case CARTRIDGE_RETRO_REPLAY:
retroreplay_mmu_translate(addr, base, start, limit);
return;
@@ -3638,6 +3665,11 @@
return -1;
}
break;
+ case CARTRIDGE_MEGABYTER:
+ if (megabyter_snapshot_write_module(s) < 0) {
+ return -1;
+ }
+ break;
case CARTRIDGE_MIKRO_ASSEMBLER:
if (mikroass_snapshot_write_module(s) < 0) {
return -1;
@@ -4258,6 +4290,11 @@
goto fail2;
}
break;
+ case CARTRIDGE_MEGABYTER:
+ if (megabyter_snapshot_read_module(s) < 0) {
+ goto fail2;
+ }
+ break;
case CARTRIDGE_MIKRO_ASSEMBLER:
if (mikroass_snapshot_read_module(s) < 0) {
goto fail2;
Modified: trunk/vice/src/c64/cart/c64cartmem.c
===================================================================
--- trunk/vice/src/c64/cart/c64cartmem.c 2025-08-16 10:52:49 UTC (rev 45736)
+++ trunk/vice/src/c64/cart/c64cartmem.c 2025-08-18 13:33:45 UTC (rev 45737)
@@ -98,6 +98,7 @@
#include "magicformel.h"
#include "magicvoice.h"
#include "maxbasic.h"
+#include "megabyter.h"
#include "mikroass.h"
#include "mmc64.h"
#include "mmcreplay.h"
@@ -656,6 +657,8 @@
return ltkernal_roml_read(addr);
case CARTRIDGE_MAX_BASIC:
return maxbasic_roml_read(addr);
+ case CARTRIDGE_MEGABYTER:
+ return megabyter_roml_read(addr);
case CARTRIDGE_MMC_REPLAY:
return mmcreplay_roml_read(addr);
case CARTRIDGE_MULTIMAX:
@@ -830,6 +833,9 @@
case CARTRIDGE_LT_KERNAL:
ltkernal_roml_store(addr, value);
return;
+ case CARTRIDGE_MEGABYTER:
+ megabyter_roml_store(addr, value);
+ return;
case CARTRIDGE_MMC_REPLAY:
mmcreplay_roml_store(addr, value);
return;
Added: trunk/vice/src/c64/cart/megabyter.c
===================================================================
--- trunk/vice/src/c64/cart/megabyter.c (rev 0)
+++ trunk/vice/src/c64/cart/megabyter.c 2025-08-18 13:33:45 UTC (rev 45737)
@@ -0,0 +1,545 @@
+
+/*
+ * megabyter.c - Cartridge handling of the megabyter cart.
+ *
+ * Written by
+ * Chester Kollschen <ma...@ch...>
+ * groepaz <gr...@gm...>
+ *
+ * This file is part of VICE, the Versatile Commodore Emulator.
+ * See README for copyright notice.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ *
+ */
+
+#include "vice.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include "archdep.h"
+#define CARTRIDGE_INCLUDE_SLOTMAIN_API
+#include "c64cartsystem.h"
+#undef CARTRIDGE_INCLUDE_SLOTMAIN_API
+#include "c64mem.h"
+#include "cartio.h"
+#include "cartridge.h"
+#include "cmdline.h"
+#include "crt.h"
+#include "megabyter.h"
+#include "export.h"
+#include "flash800.h"
+#include "lib.h"
+#include "log.h"
+#include "maincpu.h"
+#include "mem.h"
+#include "monitor.h"
+#include "resources.h"
+#include "snapshot.h"
+#include "util.h"
+#include "sysfile.h"
+
+/*
+ Protovision "Megabyter"
+
+ - 1MiB Flash ROM (29F800CB)
+
+ ROM is always banked to ROML, ie $8000
+
+ - two write-only Registers in IO1
+
+ $de00 - selects ROM bank
+ bit 7 unused
+ bit 0-6 bank 0-127
+
+ $de02
+ bit 7 LED status (1: enabled)
+ bit 2-6 unused
+ bit 1 EXROM (0: low, 1: high)
+ bit 0 GAME (0: high, 1: low)
+*/
+
+/* #define DEBUG_MEGABYTER */
+
+#ifdef DEBUG_MEGABYTER
+#define DBG(x) log_printf x
+#else
+#define DBG(x)
+#endif
+
+#define MEGABYTER_BANK_BITS 7
+#define MEGABYTER_NUM_BANKS (1 << (MEGABYTER_BANK_BITS))
+#define MEGABYTER_BANK_MASK ((MEGABYTER_NUM_BANKS) -1)
+#define MEGABYTER_BANK_SIZE 0x2000
+#define MEGABYTER_ROM_SIZE (MEGABYTER_NUM_BANKS * MEGABYTER_BANK_SIZE)
+
+/* the 29F800CB statemachine */
+static flash800_context_t *megabyter_state = NULL;
+
+/* writing back to crt enabled */
+static int megabyter_crt_write;
+
+/* optimizing crt enabled */
+static int megabyter_crt_optimize;
+
+/* backup of the registers */
+static uint8_t megabyter_register_00, megabyter_register_02;
+
+/* decoding table of the modes */
+static const uint8_t megabyter_memconfig[4] = {
+ CMODE_8KGAME, /* exrom=0, game=1 */
+ CMODE_16KGAME, /* exrom=0, game=0 */
+ CMODE_RAM, /* exrom=1, game=1 */
+ CMODE_ULTIMAX /* exrom=1, game=0 */
+};
+
+/* filename when attached */
+static char *megabyter_filename = NULL;
+static int megabyter_filetype = 0;
+
+/* ---------------------------------------------------------------------*/
+static io_source_list_t *megabyter_io1_list_item = NULL;
+
+static void megabyter_io1_store(uint16_t addr, uint8_t value);
+static uint8_t megabyter_io1_peek(uint16_t addr);
+static int megabyter_io1_dump(void);
+
+static io_source_t megabyter_io1_device = {
+ CARTRIDGE_NAME_MEGABYTER, /* name of the device */
+ IO_DETACH_CART, /* use cartridge ID to detach the device when involved in a read-collision */
+ IO_DETACH_NO_RESOURCE, /* does not use a resource for detach */
+ 0xde00, 0xdeff, 0xff, /* range for the device */
+ 0, /* read is never valid, device is write only */
+ megabyter_io1_store, /* store function */
+ NULL, /* NO poke function */
+ NULL, /* NO read function */
+ megabyter_io1_peek, /* peek function */
+ megabyter_io1_dump, /* device state information dump function */
+ CARTRIDGE_MEGABYTER, /* cartridge ID */
+ 0, /* normal priority, device read needs to be checked for collisions */
+ 0, /* insertion order, gets filled in by the registration function */
+ IO_MIRROR_NONE /* NO mirroring */
+};
+
+static const export_resource_t export_res = {
+ CARTRIDGE_NAME_MEGABYTER, 1, 1, &megabyter_io1_device, NULL, CARTRIDGE_MEGABYTER
+};
+
+static void megabyter_io1_store(uint16_t addr, uint8_t value)
+{
+ uint8_t mem_mode;
+
+ /* only A1 is decoded */
+ if (addr & 2) {
+ /* mode register */
+ megabyter_register_02 = value & 0x83; /* we only remember led, mode, exrom, game */
+ mem_mode = megabyter_memconfig[megabyter_register_02 & 0x03];
+ cart_config_changed_slotmain(mem_mode, mem_mode, CMODE_READ);
+ /* TODO: change led */
+ /* (value & 0x80) -> led on if true, led off if false */
+ } else {
+ /* bank register */
+ megabyter_register_00 = (uint8_t)(value & MEGABYTER_BANK_MASK);
+ }
+
+ DBG(("Megabyter: addr:0x%04x, value:%02x (bank:%02x mode:%i LED:%i)",
+ addr | 0xde00u, value, megabyter_register_00,
+ megabyter_memconfig[megabyter_register_02 & 0x03],
+ megabyter_register_02 >> 7));
+
+ cart_romlbank_set_slotmain(megabyter_register_00);
+ cart_port_config_changed_slotmain();
+}
+
+/* ---------------------------------------------------------------------*/
+
+static uint8_t megabyter_io1_peek(uint16_t addr)
+{
+ return (addr & 2) ? megabyter_register_02 : megabyter_register_00;
+}
+
+static int megabyter_io1_dump(void)
+{
+ int config = megabyter_memconfig[megabyter_register_02 & 0x03];
+ mon_out("Mode: %i (%s), LED is %s\n",
+ config, cart_config_string(config),
+ (megabyter_register_02 & 0x80) ? "on" : "off");
+ return 0;
+}
+
+
+/* ---------------------------------------------------------------------*/
+
+static int set_megabyter_crt_write(int val, void *param)
+{
+ megabyter_crt_write = val ? 1 : 0;
+ return 0;
+}
+
+static int set_megabyter_crt_optimize(int val, void *param)
+{
+ megabyter_crt_optimize = val ? 1 : 0;
+ return 0;
+}
+
+static int megabyter_write_chip_if_not_empty(FILE* fd, crt_chip_header_t *chip, uint8_t *data)
+{
+ int i;
+
+ for (i = 0; i < chip->size; i++) {
+ if ((data[i] != 0xff) || (megabyter_crt_optimize == 0)) {
+ if (crt_write_chip(data, chip, fd)) {
+ return -1;
+ }
+ return 0;
+ }
+ }
+ return 0;
+}
+
+/* ---------------------------------------------------------------------*/
+
+static const resource_int_t resources_int[] = {
+ { "MegabyterWriteCRT", 0, RES_EVENT_STRICT, (resource_value_t)0,
+ &megabyter_crt_write, set_megabyter_crt_write, NULL },
+ { "MegabyterOptimizeCRT", 1, RES_EVENT_STRICT, (resource_value_t)1,
+ &megabyter_crt_optimize, set_megabyter_crt_optimize, NULL },
+ RESOURCE_INT_LIST_END
+};
+
+int megabyter_resources_init(void)
+{
+ return resources_register_int(resources_int);
+}
+
+void megabyter_resources_shutdown(void)
+{
+}
+
+/* ---------------------------------------------------------------------*/
+
+static const cmdline_option_t cmdline_options[] =
+{
+ { "-megabytercrtwrite", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
+ NULL, NULL, "MegabyterWriteCRT", (resource_value_t)1,
+ NULL, "Enable writing to " CARTRIDGE_NAME_MEGABYTER " .crt image" },
+ { "+megabytercrtwrite", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
+ NULL, NULL, "MegabyterWriteCRT", (resource_value_t)0,
+ NULL, "Disable writing to " CARTRIDGE_NAME_MEGABYTER " .crt image" },
+ { "-megabytercrtoptimize", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
+ NULL, NULL, "MegabyterOptimizeCRT", (resource_value_t)1,
+ NULL, "Enable " CARTRIDGE_NAME_MEGABYTER " .crt image optimize on write" },
+ { "+megabytercrtoptimize", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
+ NULL, NULL, "MegabyterOptimizeCRT", (resource_value_t)0,
+ NULL, "Disable optimizing " CARTRIDGE_NAME_MEGABYTER " .crt image on write" },
+ CMDLINE_LIST_END
+};
+
+int megabyter_cmdline_options_init(void)
+{
+ return cmdline_register_options(cmdline_options);
+}
+
+/* ---------------------------------------------------------------------*/
+
+uint8_t megabyter_roml_read(uint16_t addr)
+{
+ return flash800core_read(megabyter_state, (megabyter_register_00 * MEGABYTER_BANK_SIZE) + (addr & 0x1fff));
+}
+
+void megabyter_roml_store(uint16_t addr, uint8_t value)
+{
+ flash800core_store(megabyter_state, (megabyter_register_00 * MEGABYTER_BANK_SIZE) + (addr & 0x1fff), value);
+}
+
+void megabyter_mmu_translate(unsigned int addr, uint8_t **base, int *start, int *limit)
+{
+ if (megabyter_state && megabyter_state->flash_data) {
+ switch (addr & 0xe000) {
+ case 0x8000:
+ if (megabyter_state->flash_state == FLASH800_STATE_READ) {
+ *base = megabyter_state->flash_data + (megabyter_register_00 * MEGABYTER_BANK_SIZE) - 0x8000;
+ *start = 0x8000;
+ *limit = 0x9ffd;
+ return;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ *base = NULL;
+ *start = 0;
+ *limit = 0;
+}
+
+/* ---------------------------------------------------------------------*/
+
+void megabyter_config_init(void)
+{
+ megabyter_io1_store((uint16_t)0xde00, 0); /* bank 0 */
+ megabyter_io1_store((uint16_t)0xde02, 0); /* 8k game, LED off */
+}
+
+void megabyter_config_setup(uint8_t *rawcart)
+{
+ int i;
+
+ megabyter_state = lib_malloc(sizeof(flash800_context_t));
+
+ flash800core_init(megabyter_state, maincpu_alarm_context, FLASH800_TYPE_CB, roml_banks);
+
+ for (i = 0; i < MEGABYTER_NUM_BANKS; i++) {
+ memcpy(megabyter_state->flash_data + (i * MEGABYTER_BANK_SIZE),
+ rawcart + (i * MEGABYTER_BANK_SIZE), MEGABYTER_BANK_SIZE);
+ }
+}
+
+/* ---------------------------------------------------------------------*/
+
+static int megabyter_common_attach(const char *filename)
+{
+ if (export_add(&export_res) < 0) {
+ return -1;
+ }
+
+ megabyter_io1_list_item = io_source_register(&megabyter_io1_device);
+ megabyter_filename = lib_strdup(filename);
+
+ return 0;
+}
+
+int megabyter_bin_attach(const char *filename, uint8_t *rawcart)
+{
+ megabyter_filetype = CARTRIDGE_FILETYPE_NONE;
+
+ if (util_file_load(filename, rawcart, MEGABYTER_ROM_SIZE, UTIL_FILE_LOAD_SKIP_ADDRESS) < 0) {
+ return -1;
+ }
+
+ megabyter_filetype = CARTRIDGE_FILETYPE_BIN;
+ return megabyter_common_attach(filename);
+}
+
+int megabyter_crt_attach(FILE *fd, uint8_t *rawcart, const char *filename)
+{
+ crt_chip_header_t chip;
+
+ megabyter_filetype = CARTRIDGE_FILETYPE_NONE;
+ memset(rawcart, 0xff, MEGABYTER_ROM_SIZE); /* empty flash */
+
+ while (1) {
+ if (crt_read_chip_header(&chip, fd)) {
+ break;
+ }
+
+ if (chip.size == MEGABYTER_BANK_SIZE) {
+ if (chip.bank >= MEGABYTER_NUM_BANKS || !(chip.start == 0x8000)) {
+ return -1;
+ }
+ if (crt_read_chip(rawcart, chip.bank << 13, &chip, fd)) {
+ return -1;
+ }
+ } else {
+ return -1;
+ }
+ }
+
+ megabyter_filetype = CARTRIDGE_FILETYPE_CRT;
+ return megabyter_common_attach(filename);
+}
+
+void megabyter_detach(void)
+{
+ if (megabyter_crt_write) {
+ megabyter_flush_image();
+ }
+ flash800core_shutdown(megabyter_state);
+ lib_free(megabyter_state);
+ lib_free(megabyter_filename);
+ megabyter_filename = NULL;
+ io_source_unregister(megabyter_io1_list_item);
+ megabyter_io1_list_item = NULL;
+ export_remove(&export_res);
+}
+
+int megabyter_flush_image(void)
+{
+ if (megabyter_filename != NULL) {
+ if (megabyter_filetype == CARTRIDGE_FILETYPE_BIN) {
+ return megabyter_bin_save(megabyter_filename);
+ } else if (megabyter_filetype == CARTRIDGE_FILETYPE_CRT) {
+ return megabyter_crt_save(megabyter_filename);
+ }
+ return -1;
+ }
+ return -2;
+}
+
+int megabyter_bin_save(const char *filename)
+{
+ FILE *fd;
+ int i;
+ uint8_t *data;
+
+ if (filename == NULL) {
+ return -1;
+ }
+
+ fd = fopen(filename, MODE_WRITE);
+
+ if (fd == NULL) {
+ return -1;
+ }
+
+ data = megabyter_state->flash_data;
+
+ for (i = 0; i < MEGABYTER_NUM_BANKS; i++, data += MEGABYTER_BANK_SIZE) {
+ if (fwrite(data, 1, MEGABYTER_BANK_SIZE, fd) != MEGABYTER_BANK_SIZE) {
+ fclose(fd);
+ return -1;
+ }
+ }
+
+ fclose(fd);
+ return 0;
+}
+
+int megabyter_crt_save(const char *filename)
+{
+ FILE *fd;
+ crt_chip_header_t chip;
+ uint8_t *data;
+ int bank;
+
+ fd = crt_create(filename, CARTRIDGE_MEGABYTER, 1, 0, CARTRIDGE_NAME_MEGABYTER);
+
+ if (fd == NULL) {
+ return -1;
+ }
+
+ chip.type = 2;
+ chip.size = MEGABYTER_BANK_SIZE;
+
+ for (bank = 0; bank < MEGABYTER_NUM_BANKS; bank++) {
+ chip.bank = bank;
+
+ data = megabyter_state->flash_data + (bank * MEGABYTER_BANK_SIZE);
+ chip.start = 0x8000;
+ if (megabyter_write_chip_if_not_empty(fd, &chip, data) != 0) {
+ fclose(fd);
+ return -1;
+ }
+
+ }
+ fclose(fd);
+ return 0;
+}
+
+/* ---------------------------------------------------------------------*/
+
+/* CARTMEGABYTER snapshot module format:
+
+ type | name | description
+ --------------------------------
+ BYTE | register 0 | register 0
+ BYTE | register 2 | register 2
+ ARRAY | ROML | 1048576 BYTES of ROML data
+ */
+
+static char snap_module_name[] = "CARTMEGABYTER";
+static char flash_snap_module_name[] = "FLASH800CB";
+#define SNAP_MAJOR 0
+#define SNAP_MINOR 0
+
+int megabyter_snapshot_write_module(snapshot_t *s)
+{
+ snapshot_module_t *m;
+
+ m = snapshot_module_create(s, snap_module_name, SNAP_MAJOR, SNAP_MINOR);
+
+ if (m == NULL) {
+ return -1;
+ }
+
+ if (0
+ || (SMW_B(m, megabyter_register_00) < 0)
+ || (SMW_B(m, megabyter_register_02) < 0)
+ || (SMW_BA(m, roml_banks, MEGABYTER_ROM_SIZE) < 0)) {
+ snapshot_module_close(m);
+ return -1;
+ }
+
+ snapshot_module_close(m);
+
+ if (0
+ || (flash800core_snapshot_write_module(s, megabyter_state, flash_snap_module_name) < 0)) {
+ return -1;
+ }
+
+ return 0;
+}
+
+int megabyter_snapshot_read_module(snapshot_t *s)
+{
+ uint8_t vmajor, vminor;
+ snapshot_module_t *m;
+
+ m = snapshot_module_open(s, snap_module_name, &vmajor, &vminor);
+ if (m == NULL) {
+ return -1;
+ }
+
+ /* Do not accept versions higher than current */
+ if (vmajor > SNAP_MAJOR || vminor > SNAP_MINOR) {
+ snapshot_set_error(SNAPSHOT_MODULE_HIGHER_VERSION);
+ goto fail;
+ }
+
+ if (0
+ || (SMR_B(m, &megabyter_register_00) < 0)
+ || (SMR_B(m, &megabyter_register_02) < 0)
+ || (SMR_BA(m, roml_banks, MEGABYTER_ROM_SIZE) < 0)) {
+ goto fail;
+ }
+
+ snapshot_module_close(m);
+
+ megabyter_state = lib_malloc(sizeof(flash800_context_t));
+
+ flash800core_init(megabyter_state, maincpu_alarm_context, FLASH800_TYPE_CB, roml_banks);
+
+ if (0
+ || (flash800core_snapshot_read_module(s, megabyter_state, flash_snap_module_name) < 0)) {
+ flash800core_shutdown(megabyter_state);
+ lib_free(megabyter_state);
+ return -1;
+ }
+
+ megabyter_common_attach("dummy");
+
+ /* remove dummy filename, set filetype to none */
+ lib_free(megabyter_filename);
+ megabyter_filename = NULL;
+ megabyter_filetype = 0;
+
+ return 0;
+
+fail:
+ snapshot_module_close(m);
+ return -1;
+}
Added: trunk/vice/src/c64/cart/megabyter.h
===================================================================
--- trunk/vice/src/c64/cart/megabyter.h (rev 0)
+++ trunk/vice/src/c64/cart/megabyter.h 2025-08-18 13:33:45 UTC (rev 45737)
@@ -0,0 +1,55 @@
+/*
+ * megabyter.h - Cartridge handling of the megabyter cart.
+ *
+ * Written by
+ * Chester Kollschen <ma...@ch...>
+ * groepaz <gr...@gm...>
+ *
+ * This file is part of VICE, the Versatile Commodore Emulator.
+ * See README for copyright notice.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ *
+ */
+
+#ifndef VICE_MEGABYTER_H
+#define VICE_MEGABYTER_H
+
+#include "types.h"
+
+extern int megabyter_resources_init(void);
+extern void megabyter_resources_shutdown(void);
+extern int megabyter_cmdline_options_init(void);
+
+extern uint8_t megabyter_roml_read(uint16_t addr);
+extern void megabyter_roml_store(uint16_t addr, uint8_t value);
+extern void megabyter_mmu_translate(unsigned int addr, uint8_t **base, int *start, int *limit);
+
+extern void megabyter_config_init(void);
+extern void megabyter_config_setup(uint8_t *rawcart);
+extern int megabyter_bin_attach(const char *filename, uint8_t *rawcart);
+extern int megabyter_crt_attach(FILE *fd, uint8_t *rawcart, const char *filename);
+extern void megabyter_detach(void);
+extern int megabyter_bin_save(const char *filename);
+extern int megabyter_crt_save(const char *filename);
+extern int megabyter_flush_image(void);
+
+struct snapshot_s;
+
+extern int megabyter_snapshot_write_module(struct snapshot_s *s);
+extern int megabyter_snapshot_read_module(struct snapshot_s *s);
+
+#endif
Modified: trunk/vice/src/cartridge.h
===================================================================
--- trunk/vice/src/cartridge.h 2025-08-16 10:52:49 UTC (rev 45736)
+++ trunk/vice/src/cartridge.h 2025-08-18 13:33:45 UTC (rev 45737)
@@ -274,7 +274,8 @@
#define CARTRIDGE_BMPDATATURBO 83 /* bmpdataturbo.c */
#define CARTRIDGE_PROFIDOS 84 /* profidos.c */
#define CARTRIDGE_MAGIC_DESK_16 85 /* magicdesk16.c */
-#define CARTRIDGE_LAST 85 /* cartconv: last cartridge in list */
+#define CARTRIDGE_MEGABYTER 86 /* megabyter.c */
+#define CARTRIDGE_LAST 86 /* cartconv: last cartridge in list */
/* list of canonical names for the c64 cartridges:
note: often it is hard to determine "the" official name, let alone the way it
@@ -352,6 +353,7 @@
#define CARTRIDGE_NAME_MAGIC_VOICE "Magic Voice" /* all lowercase on cart ? */
#define CARTRIDGE_NAME_MIDI_MAPLIN "Maplin MIDI"
#define CARTRIDGE_NAME_MAX_BASIC "MAX Basic"
+#define CARTRIDGE_NAME_MEGABYTER "PTV Megabyter"
#define CARTRIDGE_NAME_MIKRO_ASSEMBLER "Mikro Assembler"
#define CARTRIDGE_NAME_MMC64 "MMC64" /* see manual */
#define CARTRIDGE_NAME_MMC_REPLAY "MMC Replay" /* see manual */
Modified: trunk/vice/src/core/Makefile.am
===================================================================
--- trunk/vice/src/core/Makefile.am 2025-08-16 10:52:49 UTC (rev 45736)
+++ trunk/vice/src/core/Makefile.am 2025-08-18 13:33:45 UTC (rev 45737)
@@ -23,6 +23,7 @@
cs8900.c \
cs8900.h \
flash040core.c \
+ flash800core.c \
fmopl.c \
fmopl.h \
i8255a.c \
Added: trunk/vice/src/core/flash800core.c
===================================================================
--- trunk/vice/src/core/flash800core.c (rev 0)
+++ trunk/vice/src/core/flash800core.c 2025-08-18 13:33:45 UTC (rev 45737)
@@ -0,0 +1,543 @@
+/*
+ * flash800core.c - (MX)29F800C[TB] Flash emulation (preliminary, incomplete).
+ *
+ * Written by
+ * Hannu Nuotio <han...@tu...>
+ * Extended by
+ * Marko Makela <mar...@ik...>
+ * Extended by
+ * Chester Kollschen <ma...@kn...>
+ *
+ * This file is part of VICE, the Versatile Commodore Emulator.
+ * See README for copyright notice.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
+ *
+ */
+
+#include "vice.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include "alarm.h"
+#include "flash800.h"
+#include "lib.h"
+#include "log.h"
+#include "maincpu.h"
+#include "snapshot.h"
+#include "types.h"
+
+/* -------------------------------------------------------------------------- */
+
+/* #define FLASH_DEBUG_ENABLED */
+
+#ifdef FLASH_DEBUG_ENABLED
+#define FLASH_DEBUG(x) log_printf x
+#else
+#define FLASH_DEBUG(x)
+#endif
+
+struct flash_types_s {
+ uint8_t manufacturer_ID;
+ uint8_t device_ID;
+ uint8_t device_ID_addr;
+ unsigned int size;
+ unsigned int sector_mask;
+ unsigned int sector_size;
+ unsigned int sector_shift;
+ unsigned int magic_1_addr;
+ unsigned int magic_2_addr;
+ unsigned int magic_1_mask;
+ unsigned int magic_2_mask;
+ uint8_t status_toggle_bits;
+ unsigned int erase_sector_timeout_cycles;
+ unsigned int erase_sector_cycles;
+ unsigned int erase_chip_cycles;
+};
+typedef struct flash_types_s flash_types_t;
+
+static const flash_types_t flash_types[FLASH800_TYPE_NUM] = {
+ /* MX29F800CB */
+ { 0xc2, 0x58, 1,
+ 0x100000,
+ 0x0f0000, 0x010000, 16,
+ 0xaaa, 0x555, 0xfff, 0xfff,
+ 0x40,
+ 40, 700000, 8000000}, /* may take up to 15s and 32s */
+};
+
+/* -------------------------------------------------------------------------- */
+
+inline static int flash_magic_1(flash800_context_t *flash800_context, unsigned int addr)
+{
+ return ((addr & flash_types[flash800_context->flash_type].magic_1_mask) == flash_types[flash800_context->flash_type].magic_1_addr);
+}
+
+inline static int flash_magic_2(flash800_context_t *flash800_context, unsigned int addr)
+{
+ return ((addr & flash_types[flash800_context->flash_type].magic_2_mask) == flash_types[flash800_context->flash_type].magic_2_addr);
+}
+
+inline static void flash_clear_erase_mask(flash800_context_t *flash800_context)
+{
+ int i;
+
+ for (i = 0; i < FLASH800_ERASE_MASK_SIZE; ++i) {
+ flash800_context->erase_mask[i] = 0;
+ }
+}
+
+inline static unsigned int flash_sector_to_addr(flash800_context_t *flash800_context, unsigned int sector)
+{
+ unsigned int sector_size = flash_types[flash800_context->flash_type].sector_size;
+
+ return sector * sector_size;
+}
+
+inline static unsigned int flash_addr_to_sector_number(flash800_context_t *flash800_context, unsigned int addr)
+{
+ unsigned int sector_addr = flash_types[flash800_context->flash_type].sector_mask & addr;
+ unsigned int sector_shift = flash_types[flash800_context->flash_type].sector_shift;
+
+ return sector_addr >> sector_shift;
+}
+
+inline static void flash_add_sector_to_erase_mask(flash800_context_t *flash800_context, unsigned int addr)
+{
+ unsigned int sector_num = flash_addr_to_sector_number(flash800_context, addr);
+
+ flash800_context->erase_mask[sector_num >> 3] |= (uint8_t)(1 << (sector_num & 0x7));
+}
+
+inline static void flash_erase_sector(flash800_context_t *flash800_context, unsigned int sector)
+{
+ unsigned int sector_size = flash_types[flash800_context->flash_type].sector_size;
+ unsigned int sector_addr;
+
+ sector_addr = flash_sector_to_addr(flash800_context, sector);
+
+ FLASH_DEBUG(("Erasing 0x%x - 0x%x", sector_addr, sector_addr + sector_size - 1));
+ memset(&(flash800_context->flash_data[sector_addr]), 0xff, sector_size);
+ flash800_context->flash_dirty = 1;
+}
+
+inline static void flash_erase_chip(flash800_context_t *flash800_context)
+{
+ FLASH_DEBUG(("Erasing chip"));
+ memset(flash800_context->flash_data, 0xff, flash_types[flash800_context->flash_type].size);
+ flash800_context->flash_dirty = 1;
+}
+
+inline static int flash_program_byte(flash800_context_t *flash800_context, unsigned int addr, uint8_t byte)
+{
+ uint8_t old_data = flash800_context->flash_data[addr];
+ uint8_t new_data = old_data & byte;
+
+ FLASH_DEBUG(("Programming 0x%05x with 0x%02x (%02x->%02x)", addr, byte, old_data, old_data & byte));
+ flash800_context->program_byte = byte;
+ flash800_context->flash_data[addr] = new_data;
+ flash800_context->flash_dirty = 1;
+
+ return (new_data == byte) ? 1 : 0;
+}
+
+inline static int flash_write_operation_status(flash800_context_t *flash800_context)
+{
+ return ((flash800_context->program_byte ^ 0x80) & 0x80) /* DQ7 = inverse of programmed data */
+ | (((unsigned int)maincpu_clk & 2) << 5) /* DQ6 = toggle bit (2 us) */
+ | (1 << 5) /* DQ5 = timeout */
+ ;
+}
+
+inline static int flash_erase_operation_status(flash800_context_t *flash800_context)
+{
+ int v;
+
+ /* DQ6 = toggle bit */
+ v = flash800_context->program_byte;
+
+ /* toggle the toggle bit(s) */
+ /* FIXME better toggle bit II emulation */
+ flash800_context->program_byte ^= flash_types[flash800_context->flash_type].status_toggle_bits;
+
+ /* DQ3 = sector erase timer */
+ if (flash800_context->flash_state != FLASH800_STATE_SECTOR_ERASE_TIMEOUT) {
+ v |= 0x08;
+ }
+
+ return v;
+}
+
+/* -------------------------------------------------------------------------- */
+
+static void erase_alarm_handler(CLOCK offset, void *data)
+{
+ unsigned int i, j;
+ uint8_t m;
+ flash800_context_t *flash800_context = (flash800_context_t *)data;
+
+ alarm_unset(flash800_context->erase_alarm);
+
+ FLASH_DEBUG(("Erase alarm, state %i", (int)flash800_context->flash_state));
+
+ switch (flash800_context->flash_state) {
+ case FLASH800_STATE_SECTOR_ERASE_TIMEOUT:
+ alarm_set(flash800_context->erase_alarm, maincpu_clk + flash_types[flash800_context->flash_type].erase_sector_cycles);
+ flash800_context->flash_state = FLASH800_STATE_SECTOR_ERASE;
+ break;
+ case FLASH800_STATE_SECTOR_ERASE:
+ for (i = 0; i < (8 * FLASH800_ERASE_MASK_SIZE); ++i) {
+ j = i >> 3;
+ m = (uint8_t)(1 << (i & 0x7));
+ if (flash800_context->erase_mask[j] & m) {
+ flash_erase_sector(flash800_context, i);
+ flash800_context->erase_mask[j] &= (uint8_t) ~m;
+ break;
+ }
+ }
+
+ for (i = 0, m = 0; i < FLASH800_ERASE_MASK_SIZE; ++i) {
+ m |= flash800_context->erase_mask[i];
+ }
+
+ if (m != 0) {
+ alarm_set(flash800_context->erase_alarm, maincpu_clk + flash_types[flash800_context->flash_type].erase_sector_cycles);
+ } else {
+ flash800_context->flash_state = flash800_context->flash_base_state;
+ }
+ break;
+
+ case FLASH800_STATE_CHIP_ERASE:
+ flash_erase_chip(flash800_context);
+ flash800_context->flash_state = flash800_context->flash_base_state;
+ break;
+
+ default:
+ FLASH_DEBUG(("Erase alarm - error, state %i unhandled!", (int)flash800_context->flash_state));
+ break;
+ }
+}
+
+/* -------------------------------------------------------------------------- */
+
+static void flash800core_store_internal(flash800_context_t *flash800_context,
+ unsigned int addr, uint8_t byte)
+{
+#ifdef FLASH_DEBUG_ENABLED
+ flash800_state_t old_state = flash800_context->flash_state;
+ flash800_state_t old_base_state = flash800_context->flash_base_state;
+#endif
+
+ switch (flash800_context->flash_state) {
+ case FLASH800_STATE_READ:
+ if (flash_magic_1(flash800_context, addr) && (byte == 0xaa)) {
+ flash800_context->flash_state = FLASH800_STATE_MAGIC_1;
+ }
+ break;
+
+ case FLASH800_STATE_MAGIC_1:
+ if (flash_magic_2(flash800_context, addr) && (byte == 0x55)) {
+ flash800_context->flash_state = FLASH800_STATE_MAGIC_2;
+ } else {
+ flash800_context->flash_state = flash800_context->flash_base_state;
+ }
+ break;
+
+ case FLASH800_STATE_MAGIC_2:
+ if (flash_magic_1(flash800_context, addr)) {
+ switch (byte) {
+ case 0x90:
+ flash800_context->flash_state = FLASH800_STATE_AUTOSELECT;
+ flash800_context->flash_base_state = FLASH800_STATE_AUTOSELECT;
+ break;
+ case 0xf0:
+ flash800_context->flash_state = FLASH800_STATE_READ;
+ flash800_context->flash_base_state = FLASH800_STATE_READ;
+ break;
+ case 0xa0:
+ flash800_context->flash_state = FLASH800_STATE_BYTE_PROGRAM;
+ break;
+ case 0x80:
+ flash800_context->flash_state = FLASH800_STATE_ERASE_MAGIC_1;
+ break;
+ default:
+ flash800_context->flash_state = flash800_context->flash_base_state;
+ break;
+ }
+ } else {
+ flash800_context->flash_state = flash800_context->flash_base_state;
+ }
+ break;
+
+ case FLASH800_STATE_BYTE_PROGRAM:
+ if (flash_program_byte(flash800_context, addr, byte)) {
+ /* The byte program time is short enough to ignore */
+ flash800_context->flash_state = flash800_context->flash_base_state;
+ } else {
+ flash800_context->flash_state = FLASH800_STATE_BYTE_PROGRAM_ERROR;
+ }
+ break;
+
+ case FLASH800_STATE_ERASE_MAGIC_1:
+ if (flash_magic_1(flash800_context, addr) && (byte == 0xaa)) {
+ flash800_context->flash_state = FLASH800_STATE_ERASE_MAGIC_2;
+ } else {
+ flash800_context->flash_state = flash800_context->flash_base_state;
+ }
+ break;
+
+ case FLASH800_STATE_ERASE_MAGIC_2:
+ if (flash_magic_2(flash800_context, addr) && (byte == 0x55)) {
+ flash800_context->flash_state = FLASH800_STATE_ERASE_SELECT;
+ } else {
+ flash800_context->flash_state = flash800_context->flash_base_state;
+ }
+ break;
+
+ case FLASH800_STATE_ERASE_SELECT:
+ if (flash_magic_1(flash800_context, addr) && (byte == 0x10)) {
+ flash800_context->flash_state = FLASH800_STATE_CHIP_ERASE;
+ flash800_context->program_byte = 0;
+ alarm_set(flash800_context->erase_alarm, maincpu_clk + flash_types[flash800_context->flash_type].erase_chip_cycles);
+ } else if (byte == 0x30) {
+ flash_add_sector_to_erase_mask(flash800_context, addr);
+ flash800_context->program_byte = 0;
+ flash800_context->flash_state = FLASH800_STATE_SECTOR_ERASE_TIMEOUT;
+ alarm_set(flash800_context->erase_alarm, maincpu_clk + flash_types[flash800_context->flash_type].erase_sector_timeout_cycles);
+ } else {
+ flash800_context->flash_state = flash800_context->flash_base_state;
+ }
+ break;
+
+ case FLASH800_STATE_SECTOR_ERASE_TIMEOUT:
+ if (byte == 0x30) {
+ flash_add_sector_to_erase_mask(flash800_context, addr);
+ } else {
+ flash800_context->flash_state = flash800_context->flash_base_state;
+ flash_clear_erase_mask(flash800_context);
+ alarm_unset(flash800_context->erase_alarm);
+ }
+ break;
+
+ case FLASH800_STATE_SECTOR_ERASE:
+ /* TODO not all models support suspending */
+ if (byte == 0xb0) {
+ flash800_context->flash_state = FLASH800_STATE_SECTOR_ERASE_SUSPEND;
+ alarm_unset(flash800_context->erase_alarm);
+ }
+ break;
+
+ case FLASH800_STATE_SECTOR_ERASE_SUSPEND:
+ if (byte == 0x30) {
+ flash800_context->flash_state = FLASH800_STATE_SECTOR_ERASE;
+ alarm_set(flash800_context->erase_alarm, maincpu_clk + flash_types[flash800_context->flash_type].erase_sector_cycles);
+ }
+ break;
+
+ case FLASH800_STATE_BYTE_PROGRAM_ERROR:
+ case FLASH800_STATE_AUTOSELECT:
+ if (flash_magic_1(flash800_context, addr) && (byte == 0xaa)) {
+ flash800_context->flash_state = FLASH800_STATE_MAGIC_1;
+ }
+ if (byte == 0xf0) {
+ flash800_context->flash_state = FLASH800_STATE_READ;
+ flash800_context->flash_base_state = FLASH800_STATE_READ;
+ }
+ break;
+
+ case FLASH800_STATE_CHIP_ERASE:
+ default:
+ break;
+ }
+
+ FLASH_DEBUG(("Write %02x to %05x, state %i->%i (base state %i->%i)", byte, addr, (int)old_state, (int)flash800_context->flash_state, (int)old_base_state, (int)flash800_context->flash_base_state));
+}
+
+/* -------------------------------------------------------------------------- */
+
+void flash800core_store(flash800_context_t *flash800_context, unsigned int addr, uint8_t byte)
+{
+ if (maincpu_rmw_flag) {
+ maincpu_clk--;
+ flash800core_store_internal(flash800_context, addr, flash800_context->last_read);
+ maincpu_clk++;
+ }
+
+ flash800core_store_internal(flash800_context, addr, byte);
+}
+
+uint8_t flash800core_read(flash800_context_t *flash800_context, unsigned int addr)
+{
+ uint8_t value;
+#ifdef FLASH_DEBUG_ENABLED
+ flash800_state_t old_state = flash800_context->flash_state;
+#endif
+
+ switch (flash800_context->flash_state) {
+ case FLASH800_STATE_AUTOSELECT:
+
+ if ((addr & 0xff) == 0) {
+ value = flash_types[flash800_context->flash_type].manufacturer_ID;
+ } else if ((addr & 0xff) == flash_types[flash800_context->flash_type].device_ID_addr) {
+ value = flash_types[flash800_context->flash_type].device_ID;
+ } else if ((addr & 0xff) == 2) {
+ value = 0;
+ } else {
+ value = flash800_context->flash_data[addr];
+ }
+ break;
+
+ case FLASH800_STATE_BYTE_PROGRAM_ERROR:
+ value = flash_write_operation_status(flash800_context);
+ break;
+
+ case FLASH800_STATE_SECTOR_ERASE_SUSPEND:
+ case FLASH800_STATE_CHIP_ERASE:
+ case FLASH800_STATE_SECTOR_ERASE:
+ case FLASH800_STATE_SECTOR_ERASE_TIMEOUT:
+ value = flash_erase_operation_status(flash800_context);
+ break;
+
+ default:
+ /* The state doesn't reset if a read occurs during a command sequence */
+ /* fall through */
+ case FLASH800_STATE_READ:
+ value = flash800_context->flash_data[addr];
+ break;
+ }
+
+#ifdef FLASH_DEBUG_ENABLED
+ if (old_state != FLASH800_STATE_READ) {
+ FLASH_DEBUG(("Read %02x from %05x, state %i->%i", value, addr, (int)old_state, (int)flash800_context->flash_state));
+ }
+#endif
+
+ flash800_context->last_read = value;
+ return value;
+}
+
+uint8_t flash800core_peek(flash800_context_t *flash800_context, unsigned int addr)
+{
+ return flash800_context->flash_data[addr];
+}
+
+void flash800core_reset(flash800_context_t *flash800_cont...
[truncated message content] |
|
From: <gp...@us...> - 2025-08-16 10:52:52
|
Revision: 45736
http://sourceforge.net/p/vice-emu/code/45736
Author: gpz
Date: 2025-08-16 10:52:49 +0000 (Sat, 16 Aug 2025)
Log Message:
-----------
preliminary fix for #2160
Modified Paths:
--------------
trunk/vice/src/plus4/plus4tcbm.c
Modified: trunk/vice/src/plus4/plus4tcbm.c
===================================================================
--- trunk/vice/src/plus4/plus4tcbm.c 2025-08-11 14:08:51 UTC (rev 45735)
+++ trunk/vice/src/plus4/plus4tcbm.c 2025-08-16 10:52:49 UTC (rev 45736)
@@ -87,8 +87,13 @@
log_debug(LOG_DEFAULT, "TCBM PB READ DATA %02x DDR %02x",
tiatcbm[dnr].datab, tiatcbm[dnr].ddrb);
#endif
+
+#if 0 /* FIXME: remove when we can confirm the code below is correct, see #2160 */
return (tiatcbm[dnr].datab | ~tiatcbm[dnr].ddrb)
& (tpid_outputc[dnr] | 0xfc);
+#endif
+ return ((tiatcbm[dnr].datab & tiatcbm[dnr].ddrb) |
+ (tpid_outputc[dnr] & (~tiatcbm[dnr].ddrb & 0x03)));
}
inline static uint8_t datac_read(unsigned int dnr)
@@ -97,9 +102,14 @@
log_debug(LOG_DEFAULT, "TCBM PC READ DATA %02x DDR %02x",
tiatcbm[dnr].datac, tiatcbm[dnr].ddrc);
#endif
+#if 0 /* FIXME: remove when we can confirm the code below is correct, see #2160 */
return (tiatcbm[dnr].datac | ~tiatcbm[dnr].ddrc)
& ((tpid_outputc[dnr] << 4) | 0x7f)
& ((tpid_outputc[dnr] >> 1) | 0xbf);
+#endif
+ return ((tiatcbm[dnr].datac & tiatcbm[dnr].ddrc) |
+ ((tpid_outputc[dnr] << 4) & (~tiatcbm[dnr].ddrc) & 0x80) |
+ ((tpid_outputc[dnr] >> 1) & (~tiatcbm[dnr].ddrc) & 0x40));
}
inline static void store_pa(unsigned int dnr)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gp...@us...> - 2025-08-11 14:08:53
|
Revision: 45735
http://sourceforge.net/p/vice-emu/code/45735
Author: gpz
Date: 2025-08-11 14:08:51 +0000 (Mon, 11 Aug 2025)
Log Message:
-----------
allow uppercase characters with and without shift in swedish symbolic keympas, should fix problem(s) with caps-lock and Z
Modified Paths:
--------------
trunk/vice/data/C128/gtk3_sym_se.vkm
trunk/vice/data/C64/gtk3_sym_se.vkm
trunk/vice/data/C64DTV/gtk3_sym_se.vkm
trunk/vice/data/SCPU64/gtk3_sym_se.vkm
Modified: trunk/vice/data/C128/gtk3_sym_se.vkm
===================================================================
--- trunk/vice/data/C128/gtk3_sym_se.vkm 2025-08-11 13:02:24 UTC (rev 45734)
+++ trunk/vice/data/C128/gtk3_sym_se.vkm 2025-08-11 14:08:51 UTC (rev 45735)
@@ -292,32 +292,32 @@
8 3 3 8
9 4 0 8
-A 1 2 1
-B 3 4 1
-C 2 4 1
-D 2 2 1
-E 1 6 1
-F 2 5 1
-G 3 2 1
-H 3 5 1
-I 4 1 1
-J 4 2 1
-K 4 5 1
-L 5 2 1
-M 4 4 1
-N 4 7 1
-O 4 6 1
-P 5 1 1
-Q 7 6 1
-R 2 1 1
-S 1 5 1
-T 2 6 1
-U 3 6 1
-V 3 7 1
-W 1 1 1
-X 2 7 1
-Y 3 1 1
-Z 1 4 1
+A 1 2 8
+B 3 4 8
+C 2 4 8
+D 2 2 8
+E 1 6 8
+F 2 5 8
+G 3 2 8
+H 3 5 8
+I 4 1 8
+J 4 2 8
+K 4 5 8
+L 5 2 8
+M 4 4 8
+N 4 7 8
+O 4 6 8
+P 5 1 8
+Q 7 6 8
+R 2 1 8
+S 1 5 8
+T 2 6 8
+U 3 6 8
+V 3 7 8
+W 1 1 8
+X 2 7 8
+Y 3 1 8
+Z 1 4 8
a 1 2 8
b 3 4 8
@@ -416,4 +416,4 @@
dead_circumflex 6 6 16 # A_UP
dead_tilde 6 6 1 # shift+A_UP
dead_perispomeni 6 6 1 # shift+A_UP
-dead_diaeresis 7 3 1 # "
\ No newline at end of file
+dead_diaeresis 7 3 1 # "
Modified: trunk/vice/data/C64/gtk3_sym_se.vkm
===================================================================
--- trunk/vice/data/C64/gtk3_sym_se.vkm 2025-08-11 13:02:24 UTC (rev 45734)
+++ trunk/vice/data/C64/gtk3_sym_se.vkm 2025-08-11 14:08:51 UTC (rev 45735)
@@ -237,32 +237,32 @@
8 3 3 0
9 4 0 0
-A 1 2 1
-B 3 4 1
-C 2 4 1
-D 2 2 1
-E 1 6 1
-F 2 5 1
-G 3 2 1
-H 3 5 1
-I 4 1 1
-J 4 2 1
-K 4 5 1
-L 5 2 1
-M 4 4 1
-N 4 7 1
-O 4 6 1
-P 5 1 1
-Q 7 6 1
-R 2 1 1
-S 1 5 1
-T 2 6 1
-U 3 6 1
-V 3 7 1
-W 1 1 1
-X 2 7 1
-Y 3 1 1
-Z 1 4 1
+A 1 2 8
+B 3 4 8
+C 2 4 8
+D 2 2 8
+E 1 6 8
+F 2 5 8
+G 3 2 8
+H 3 5 8
+I 4 1 8
+J 4 2 8
+K 4 5 8
+L 5 2 8
+M 4 4 8
+N 4 7 8
+O 4 6 8
+P 5 1 8
+Q 7 6 8
+R 2 1 8
+S 1 5 8
+T 2 6 8
+U 3 6 8
+V 3 7 8
+W 1 1 8
+X 2 7 8
+Y 3 1 8
+Z 1 4 8
a 1 2 8
b 3 4 8
c 2 4 8
Modified: trunk/vice/data/C64DTV/gtk3_sym_se.vkm
===================================================================
--- trunk/vice/data/C64DTV/gtk3_sym_se.vkm 2025-08-11 13:02:24 UTC (rev 45734)
+++ trunk/vice/data/C64DTV/gtk3_sym_se.vkm 2025-08-11 14:08:51 UTC (rev 45735)
@@ -237,32 +237,32 @@
8 3 3 0
9 4 0 0
-A 1 2 1
-B 3 4 1
-C 2 4 1
-D 2 2 1
-E 1 6 1
-F 2 5 1
-G 3 2 1
-H 3 5 1
-I 4 1 1
-J 4 2 1
-K 4 5 1
-L 5 2 1
-M 4 4 1
-N 4 7 1
-O 4 6 1
-P 5 1 1
-Q 7 6 1
-R 2 1 1
-S 1 5 1
-T 2 6 1
-U 3 6 1
-V 3 7 1
-W 1 1 1
-X 2 7 1
-Y 3 1 1
-Z 1 4 1
+A 1 2 8
+B 3 4 8
+C 2 4 8
+D 2 2 8
+E 1 6 8
+F 2 5 8
+G 3 2 8
+H 3 5 8
+I 4 1 8
+J 4 2 8
+K 4 5 8
+L 5 2 8
+M 4 4 8
+N 4 7 8
+O 4 6 8
+P 5 1 8
+Q 7 6 8
+R 2 1 8
+S 1 5 8
+T 2 6 8
+U 3 6 8
+V 3 7 8
+W 1 1 8
+X 2 7 8
+Y 3 1 8
+Z 1 4 8
a 1 2 8
b 3 4 8
c 2 4 8
Modified: trunk/vice/data/SCPU64/gtk3_sym_se.vkm
===================================================================
--- trunk/vice/data/SCPU64/gtk3_sym_se.vkm 2025-08-11 13:02:24 UTC (rev 45734)
+++ trunk/vice/data/SCPU64/gtk3_sym_se.vkm 2025-08-11 14:08:51 UTC (rev 45735)
@@ -237,32 +237,32 @@
8 3 3 0
9 4 0 0
-A 1 2 1
-B 3 4 1
-C 2 4 1
-D 2 2 1
-E 1 6 1
-F 2 5 1
-G 3 2 1
-H 3 5 1
-I 4 1 1
-J 4 2 1
-K 4 5 1
-L 5 2 1
-M 4 4 1
-N 4 7 1
-O 4 6 1
-P 5 1 1
-Q 7 6 1
-R 2 1 1
-S 1 5 1
-T 2 6 1
-U 3 6 1
-V 3 7 1
-W 1 1 1
-X 2 7 1
-Y 3 1 1
-Z 1 4 1
+A 1 2 8
+B 3 4 8
+C 2 4 8
+D 2 2 8
+E 1 6 8
+F 2 5 8
+G 3 2 8
+H 3 5 8
+I 4 1 8
+J 4 2 8
+K 4 5 8
+L 5 2 8
+M 4 4 8
+N 4 7 8
+O 4 6 8
+P 5 1 8
+Q 7 6 8
+R 2 1 8
+S 1 5 8
+T 2 6 8
+U 3 6 8
+V 3 7 8
+W 1 1 8
+X 2 7 8
+Y 3 1 8
+Z 1 4 8
a 1 2 8
b 3 4 8
c 2 4 8
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gp...@us...> - 2025-08-11 13:02:26
|
Revision: 45734
http://sourceforge.net/p/vice-emu/code/45734
Author: gpz
Date: 2025-08-11 13:02:24 +0000 (Mon, 11 Aug 2025)
Log Message:
-----------
fix for accidently introduced DC offset in 6581 filters, fix by leandro nini
Modified Paths:
--------------
trunk/vice/src/resid/filter8580new.h
Modified: trunk/vice/src/resid/filter8580new.h
===================================================================
--- trunk/vice/src/resid/filter8580new.h 2025-08-09 16:54:29 UTC (rev 45733)
+++ trunk/vice/src/resid/filter8580new.h 2025-08-11 13:02:24 UTC (rev 45734)
@@ -961,7 +961,7 @@
my $sum;
if (@sumFilt) {
$sumV = (@sumVoice) ? " + ".join(" + ", @sumVoice) : "";
- $sum = "(((".join(" + ", @sumFilt).") * mf.filterGain) >> 12)" . $sumV;
+ $sum = "((((".join(" + ", @sumFilt).") * f.filterGain) + dc_offset) >> 12)" . $sumV;
} else {
$sum = join(" + ", @sumVoice) || "0";
}
@@ -974,6 +974,7 @@
// Sum inputs routed into the mixer.
int Vi = 0;
int offset = 0;
+ const int dc_offset = 32767 * ((1 << 12) - f.filterGain);
switch (mix & 0x7f) {
case 0x00:
@@ -1041,451 +1042,451 @@
offset = mixer_offset<4>::value;
break;
case 0x10:
- Vi = (((Vlp) * f.filterGain) >> 12);
+ Vi = ((((Vlp) * f.filterGain) + dc_offset) >> 12);
offset = mixer_offset<1>::value;
break;
case 0x11:
- Vi = (((Vlp) * f.filterGain) >> 12) + v1;
+ Vi = ((((Vlp) * f.filterGain) + dc_offset) >> 12) + v1;
offset = mixer_offset<2>::value;
break;
case 0x12:
- Vi = (((Vlp) * f.filterGain) >> 12) + v2;
+ Vi = ((((Vlp) * f.filterGain) + dc_offset) >> 12) + v2;
offset = mixer_offset<2>::value;
break;
case 0x13:
- Vi = (((Vlp) * f.filterGain) >> 12) + v2 + v1;
+ Vi = ((((Vlp) * f.filterGain) + dc_offset) >> 12) + v2 + v1;
offset = mixer_offset<3>::value;
break;
case 0x14:
- Vi = (((Vlp) * f.filterGain) >> 12) + v3;
+ Vi = ((((Vlp) * f.filterGain) + dc_offset) >> 12) + v3;
offset = mixer_offset<2>::value;
break;
case 0x15:
- Vi = (((Vlp) * f.filterGain) >> 12) + v3 + v1;
+ Vi = ((((Vlp) * f.filterGain) + dc_offset) >> 12) + v3 + v1;
offset = mixer_offset<3>::value;
break;
case 0x16:
- Vi = (((Vlp) * f.filterGain) >> 12) + v3 + v2;
+ Vi = ((((Vlp) * f.filterGain) + dc_offset) >> 12) + v3 + v2;
offset = mixer_offset<3>::value;
break;
case 0x17:
- Vi = (((Vlp) * f.filterGain) >> 12) + v3 + v2 + v1;
+ Vi = ((((Vlp) * f.filterGain) + dc_offset) >> 12) + v3 + v2 + v1;
offset = mixer_offset<4>::value;
break;
case 0x18:
- Vi = (((Vlp) * f.filterGain) >> 12) + ve;
+ Vi = ((((Vlp) * f.filterGain) + dc_offset) >> 12) + ve;
offset = mixer_offset<2>::value;
break;
case 0x19:
- Vi = (((Vlp) * f.filterGain) >> 12) + ve + v1;
+ Vi = ((((Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v1;
offset = mixer_offset<3>::value;
break;
case 0x1a:
- Vi = (((Vlp) * f.filterGain) >> 12) + ve + v2;
+ Vi = ((((Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v2;
offset = mixer_offset<3>::value;
break;
case 0x1b:
- Vi = (((Vlp) * f.filterGain) >> 12) + ve + v2 + v1;
+ Vi = ((((Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v2 + v1;
offset = mixer_offset<4>::value;
break;
case 0x1c:
- Vi = (((Vlp) * f.filterGain) >> 12) + ve + v3;
+ Vi = ((((Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v3;
offset = mixer_offset<3>::value;
break;
case 0x1d:
- Vi = (((Vlp) * f.filterGain) >> 12) + ve + v3 + v1;
+ Vi = ((((Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v3 + v1;
offset = mixer_offset<4>::value;
break;
case 0x1e:
- Vi = (((Vlp) * f.filterGain) >> 12) + ve + v3 + v2;
+ Vi = ((((Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v3 + v2;
offset = mixer_offset<4>::value;
break;
case 0x1f:
- Vi = (((Vlp) * f.filterGain) >> 12) + ve + v3 + v2 + v1;
+ Vi = ((((Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v3 + v2 + v1;
offset = mixer_offset<5>::value;
break;
case 0x20:
- Vi = (((Vbp) * f.filterGain) >> 12);
+ Vi = ((((Vbp) * f.filterGain) + dc_offset) >> 12);
offset = mixer_offset<1>::value;
break;
case 0x21:
- Vi = (((Vbp) * f.filterGain) >> 12) + v1;
+ Vi = ((((Vbp) * f.filterGain) + dc_offset) >> 12) + v1;
offset = mixer_offset<2>::value;
break;
case 0x22:
- Vi = (((Vbp) * f.filterGain) >> 12) + v2;
+ Vi = ((((Vbp) * f.filterGain) + dc_offset) >> 12) + v2;
offset = mixer_offset<2>::value;
break;
case 0x23:
- Vi = (((Vbp) * f.filterGain) >> 12) + v2 + v1;
+ Vi = ((((Vbp) * f.filterGain) + dc_offset) >> 12) + v2 + v1;
offset = mixer_offset<3>::value;
break;
case 0x24:
- Vi = (((Vbp) * f.filterGain) >> 12) + v3;
+ Vi = ((((Vbp) * f.filterGain) + dc_offset) >> 12) + v3;
offset = mixer_offset<2>::value;
break;
case 0x25:
- Vi = (((Vbp) * f.filterGain) >> 12) + v3 + v1;
+ Vi = ((((Vbp) * f.filterGain) + dc_offset) >> 12) + v3 + v1;
offset = mixer_offset<3>::value;
break;
case 0x26:
- Vi = (((Vbp) * f.filterGain) >> 12) + v3 + v2;
+ Vi = ((((Vbp) * f.filterGain) + dc_offset) >> 12) + v3 + v2;
offset = mixer_offset<3>::value;
break;
case 0x27:
- Vi = (((Vbp) * f.filterGain) >> 12) + v3 + v2 + v1;
+ Vi = ((((Vbp) * f.filterGain) + dc_offset) >> 12) + v3 + v2 + v1;
offset = mixer_offset<4>::value;
break;
case 0x28:
- Vi = (((Vbp) * f.filterGain) >> 12) + ve;
+ Vi = ((((Vbp) * f.filterGain) + dc_offset) >> 12) + ve;
offset = mixer_offset<2>::value;
break;
case 0x29:
- Vi = (((Vbp) * f.filterGain) >> 12) + ve + v1;
+ Vi = ((((Vbp) * f.filterGain) + dc_offset) >> 12) + ve + v1;
offset = mixer_offset<3>::value;
break;
case 0x2a:
- Vi = (((Vbp) * f.filterGain) >> 12) + ve + v2;
+ Vi = ((((Vbp) * f.filterGain) + dc_offset) >> 12) + ve + v2;
offset = mixer_offset<3>::value;
break;
case 0x2b:
- Vi = (((Vbp) * f.filterGain) >> 12) + ve + v2 + v1;
+ Vi = ((((Vbp) * f.filterGain) + dc_offset) >> 12) + ve + v2 + v1;
offset = mixer_offset<4>::value;
break;
case 0x2c:
- Vi = (((Vbp) * f.filterGain) >> 12) + ve + v3;
+ Vi = ((((Vbp) * f.filterGain) + dc_offset) >> 12) + ve + v3;
offset = mixer_offset<3>::value;
break;
case 0x2d:
- Vi = (((Vbp) * f.filterGain) >> 12) + ve + v3 + v1;
+ Vi = ((((Vbp) * f.filterGain) + dc_offset) >> 12) + ve + v3 + v1;
offset = mixer_offset<4>::value;
break;
case 0x2e:
- Vi = (((Vbp) * f.filterGain) >> 12) + ve + v3 + v2;
+ Vi = ((((Vbp) * f.filterGain) + dc_offset) >> 12) + ve + v3 + v2;
offset = mixer_offset<4>::value;
break;
case 0x2f:
- Vi = (((Vbp) * f.filterGain) >> 12) + ve + v3 + v2 + v1;
+ Vi = ((((Vbp) * f.filterGain) + dc_offset) >> 12) + ve + v3 + v2 + v1;
offset = mixer_offset<5>::value;
break;
case 0x30:
- Vi = (((Vbp + Vlp) * f.filterGain) >> 12);
+ Vi = ((((Vbp + Vlp) * f.filterGain) + dc_offset) >> 12);
offset = mixer_offset<2>::value;
break;
case 0x31:
- Vi = (((Vbp + Vlp) * f.filterGain) >> 12) + v1;
+ Vi = ((((Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + v1;
offset = mixer_offset<3>::value;
break;
case 0x32:
- Vi = (((Vbp + Vlp) * f.filterGain) >> 12) + v2;
+ Vi = ((((Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + v2;
offset = mixer_offset<3>::value;
break;
case 0x33:
- Vi = (((Vbp + Vlp) * f.filterGain) >> 12) + v2 + v1;
+ Vi = ((((Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + v2 + v1;
offset = mixer_offset<4>::value;
break;
case 0x34:
- Vi = (((Vbp + Vlp) * f.filterGain) >> 12) + v3;
+ Vi = ((((Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + v3;
offset = mixer_offset<3>::value;
break;
case 0x35:
- Vi = (((Vbp + Vlp) * f.filterGain) >> 12) + v3 + v1;
+ Vi = ((((Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + v3 + v1;
offset = mixer_offset<4>::value;
break;
case 0x36:
- Vi = (((Vbp + Vlp) * f.filterGain) >> 12) + v3 + v2;
+ Vi = ((((Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + v3 + v2;
offset = mixer_offset<4>::value;
break;
case 0x37:
- Vi = (((Vbp + Vlp) * f.filterGain) >> 12) + v3 + v2 + v1;
+ Vi = ((((Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + v3 + v2 + v1;
offset = mixer_offset<5>::value;
break;
case 0x38:
- Vi = (((Vbp + Vlp) * f.filterGain) >> 12) + ve;
+ Vi = ((((Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + ve;
offset = mixer_offset<3>::value;
break;
case 0x39:
- Vi = (((Vbp + Vlp) * f.filterGain) >> 12) + ve + v1;
+ Vi = ((((Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v1;
offset = mixer_offset<4>::value;
break;
case 0x3a:
- Vi = (((Vbp + Vlp) * f.filterGain) >> 12) + ve + v2;
+ Vi = ((((Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v2;
offset = mixer_offset<4>::value;
break;
case 0x3b:
- Vi = (((Vbp + Vlp) * f.filterGain) >> 12) + ve + v2 + v1;
+ Vi = ((((Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v2 + v1;
offset = mixer_offset<5>::value;
break;
case 0x3c:
- Vi = (((Vbp + Vlp) * f.filterGain) >> 12) + ve + v3;
+ Vi = ((((Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v3;
offset = mixer_offset<4>::value;
break;
case 0x3d:
- Vi = (((Vbp + Vlp) * f.filterGain) >> 12) + ve + v3 + v1;
+ Vi = ((((Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v3 + v1;
offset = mixer_offset<5>::value;
break;
case 0x3e:
- Vi = (((Vbp + Vlp) * f.filterGain) >> 12) + ve + v3 + v2;
+ Vi = ((((Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v3 + v2;
offset = mixer_offset<5>::value;
break;
case 0x3f:
- Vi = (((Vbp + Vlp) * f.filterGain) >> 12) + ve + v3 + v2 + v1;
+ Vi = ((((Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v3 + v2 + v1;
offset = mixer_offset<6>::value;
break;
case 0x40:
- Vi = (((Vhp) * f.filterGain) >> 12);
+ Vi = ((((Vhp) * f.filterGain) + dc_offset) >> 12);
offset = mixer_offset<1>::value;
break;
case 0x41:
- Vi = (((Vhp) * f.filterGain) >> 12) + v1;
+ Vi = ((((Vhp) * f.filterGain) + dc_offset) >> 12) + v1;
offset = mixer_offset<2>::value;
break;
case 0x42:
- Vi = (((Vhp) * f.filterGain) >> 12) + v2;
+ Vi = ((((Vhp) * f.filterGain) + dc_offset) >> 12) + v2;
offset = mixer_offset<2>::value;
break;
case 0x43:
- Vi = (((Vhp) * f.filterGain) >> 12) + v2 + v1;
+ Vi = ((((Vhp) * f.filterGain) + dc_offset) >> 12) + v2 + v1;
offset = mixer_offset<3>::value;
break;
case 0x44:
- Vi = (((Vhp) * f.filterGain) >> 12) + v3;
+ Vi = ((((Vhp) * f.filterGain) + dc_offset) >> 12) + v3;
offset = mixer_offset<2>::value;
break;
case 0x45:
- Vi = (((Vhp) * f.filterGain) >> 12) + v3 + v1;
+ Vi = ((((Vhp) * f.filterGain) + dc_offset) >> 12) + v3 + v1;
offset = mixer_offset<3>::value;
break;
case 0x46:
- Vi = (((Vhp) * f.filterGain) >> 12) + v3 + v2;
+ Vi = ((((Vhp) * f.filterGain) + dc_offset) >> 12) + v3 + v2;
offset = mixer_offset<3>::value;
break;
case 0x47:
- Vi = (((Vhp) * f.filterGain) >> 12) + v3 + v2 + v1;
+ Vi = ((((Vhp) * f.filterGain) + dc_offset) >> 12) + v3 + v2 + v1;
offset = mixer_offset<4>::value;
break;
case 0x48:
- Vi = (((Vhp) * f.filterGain) >> 12) + ve;
+ Vi = ((((Vhp) * f.filterGain) + dc_offset) >> 12) + ve;
offset = mixer_offset<2>::value;
break;
case 0x49:
- Vi = (((Vhp) * f.filterGain) >> 12) + ve + v1;
+ Vi = ((((Vhp) * f.filterGain) + dc_offset) >> 12) + ve + v1;
offset = mixer_offset<3>::value;
break;
case 0x4a:
- Vi = (((Vhp) * f.filterGain) >> 12) + ve + v2;
+ Vi = ((((Vhp) * f.filterGain) + dc_offset) >> 12) + ve + v2;
offset = mixer_offset<3>::value;
break;
case 0x4b:
- Vi = (((Vhp) * f.filterGain) >> 12) + ve + v2 + v1;
+ Vi = ((((Vhp) * f.filterGain) + dc_offset) >> 12) + ve + v2 + v1;
offset = mixer_offset<4>::value;
break;
case 0x4c:
- Vi = (((Vhp) * f.filterGain) >> 12) + ve + v3;
+ Vi = ((((Vhp) * f.filterGain) + dc_offset) >> 12) + ve + v3;
offset = mixer_offset<3>::value;
break;
case 0x4d:
- Vi = (((Vhp) * f.filterGain) >> 12) + ve + v3 + v1;
+ Vi = ((((Vhp) * f.filterGain) + dc_offset) >> 12) + ve + v3 + v1;
offset = mixer_offset<4>::value;
break;
case 0x4e:
- Vi = (((Vhp) * f.filterGain) >> 12) + ve + v3 + v2;
+ Vi = ((((Vhp) * f.filterGain) + dc_offset) >> 12) + ve + v3 + v2;
offset = mixer_offset<4>::value;
break;
case 0x4f:
- Vi = (((Vhp) * f.filterGain) >> 12) + ve + v3 + v2 + v1;
+ Vi = ((((Vhp) * f.filterGain) + dc_offset) >> 12) + ve + v3 + v2 + v1;
offset = mixer_offset<5>::value;
break;
case 0x50:
- Vi = (((Vhp + Vlp) * f.filterGain) >> 12);
+ Vi = ((((Vhp + Vlp) * f.filterGain) + dc_offset) >> 12);
offset = mixer_offset<2>::value;
break;
case 0x51:
- Vi = (((Vhp + Vlp) * f.filterGain) >> 12) + v1;
+ Vi = ((((Vhp + Vlp) * f.filterGain) + dc_offset) >> 12) + v1;
offset = mixer_offset<3>::value;
break;
case 0x52:
- Vi = (((Vhp + Vlp) * f.filterGain) >> 12) + v2;
+ Vi = ((((Vhp + Vlp) * f.filterGain) + dc_offset) >> 12) + v2;
offset = mixer_offset<3>::value;
break;
case 0x53:
- Vi = (((Vhp + Vlp) * f.filterGain) >> 12) + v2 + v1;
+ Vi = ((((Vhp + Vlp) * f.filterGain) + dc_offset) >> 12) + v2 + v1;
offset = mixer_offset<4>::value;
break;
case 0x54:
- Vi = (((Vhp + Vlp) * f.filterGain) >> 12) + v3;
+ Vi = ((((Vhp + Vlp) * f.filterGain) + dc_offset) >> 12) + v3;
offset = mixer_offset<3>::value;
break;
case 0x55:
- Vi = (((Vhp + Vlp) * f.filterGain) >> 12) + v3 + v1;
+ Vi = ((((Vhp + Vlp) * f.filterGain) + dc_offset) >> 12) + v3 + v1;
offset = mixer_offset<4>::value;
break;
case 0x56:
- Vi = (((Vhp + Vlp) * f.filterGain) >> 12) + v3 + v2;
+ Vi = ((((Vhp + Vlp) * f.filterGain) + dc_offset) >> 12) + v3 + v2;
offset = mixer_offset<4>::value;
break;
case 0x57:
- Vi = (((Vhp + Vlp) * f.filterGain) >> 12) + v3 + v2 + v1;
+ Vi = ((((Vhp + Vlp) * f.filterGain) + dc_offset) >> 12) + v3 + v2 + v1;
offset = mixer_offset<5>::value;
break;
case 0x58:
- Vi = (((Vhp + Vlp) * f.filterGain) >> 12) + ve;
+ Vi = ((((Vhp + Vlp) * f.filterGain) + dc_offset) >> 12) + ve;
offset = mixer_offset<3>::value;
break;
case 0x59:
- Vi = (((Vhp + Vlp) * f.filterGain) >> 12) + ve + v1;
+ Vi = ((((Vhp + Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v1;
offset = mixer_offset<4>::value;
break;
case 0x5a:
- Vi = (((Vhp + Vlp) * f.filterGain) >> 12) + ve + v2;
+ Vi = ((((Vhp + Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v2;
offset = mixer_offset<4>::value;
break;
case 0x5b:
- Vi = (((Vhp + Vlp) * f.filterGain) >> 12) + ve + v2 + v1;
+ Vi = ((((Vhp + Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v2 + v1;
offset = mixer_offset<5>::value;
break;
case 0x5c:
- Vi = (((Vhp + Vlp) * f.filterGain) >> 12) + ve + v3;
+ Vi = ((((Vhp + Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v3;
offset = mixer_offset<4>::value;
break;
case 0x5d:
- Vi = (((Vhp + Vlp) * f.filterGain) >> 12) + ve + v3 + v1;
+ Vi = ((((Vhp + Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v3 + v1;
offset = mixer_offset<5>::value;
break;
case 0x5e:
- Vi = (((Vhp + Vlp) * f.filterGain) >> 12) + ve + v3 + v2;
+ Vi = ((((Vhp + Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v3 + v2;
offset = mixer_offset<5>::value;
break;
case 0x5f:
- Vi = (((Vhp + Vlp) * f.filterGain) >> 12) + ve + v3 + v2 + v1;
+ Vi = ((((Vhp + Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v3 + v2 + v1;
offset = mixer_offset<6>::value;
break;
case 0x60:
- Vi = (((Vhp + Vbp) * f.filterGain) >> 12);
+ Vi = ((((Vhp + Vbp) * f.filterGain) + dc_offset) >> 12);
offset = mixer_offset<2>::value;
break;
case 0x61:
- Vi = (((Vhp + Vbp) * f.filterGain) >> 12) + v1;
+ Vi = ((((Vhp + Vbp) * f.filterGain) + dc_offset) >> 12) + v1;
offset = mixer_offset<3>::value;
break;
case 0x62:
- Vi = (((Vhp + Vbp) * f.filterGain) >> 12) + v2;
+ Vi = ((((Vhp + Vbp) * f.filterGain) + dc_offset) >> 12) + v2;
offset = mixer_offset<3>::value;
break;
case 0x63:
- Vi = (((Vhp + Vbp) * f.filterGain) >> 12) + v2 + v1;
+ Vi = ((((Vhp + Vbp) * f.filterGain) + dc_offset) >> 12) + v2 + v1;
offset = mixer_offset<4>::value;
break;
case 0x64:
- Vi = (((Vhp + Vbp) * f.filterGain) >> 12) + v3;
+ Vi = ((((Vhp + Vbp) * f.filterGain) + dc_offset) >> 12) + v3;
offset = mixer_offset<3>::value;
break;
case 0x65:
- Vi = (((Vhp + Vbp) * f.filterGain) >> 12) + v3 + v1;
+ Vi = ((((Vhp + Vbp) * f.filterGain) + dc_offset) >> 12) + v3 + v1;
offset = mixer_offset<4>::value;
break;
case 0x66:
- Vi = (((Vhp + Vbp) * f.filterGain) >> 12) + v3 + v2;
+ Vi = ((((Vhp + Vbp) * f.filterGain) + dc_offset) >> 12) + v3 + v2;
offset = mixer_offset<4>::value;
break;
case 0x67:
- Vi = (((Vhp + Vbp) * f.filterGain) >> 12) + v3 + v2 + v1;
+ Vi = ((((Vhp + Vbp) * f.filterGain) + dc_offset) >> 12) + v3 + v2 + v1;
offset = mixer_offset<5>::value;
break;
case 0x68:
- Vi = (((Vhp + Vbp) * f.filterGain) >> 12) + ve;
+ Vi = ((((Vhp + Vbp) * f.filterGain) + dc_offset) >> 12) + ve;
offset = mixer_offset<3>::value;
break;
case 0x69:
- Vi = (((Vhp + Vbp) * f.filterGain) >> 12) + ve + v1;
+ Vi = ((((Vhp + Vbp) * f.filterGain) + dc_offset) >> 12) + ve + v1;
offset = mixer_offset<4>::value;
break;
case 0x6a:
- Vi = (((Vhp + Vbp) * f.filterGain) >> 12) + ve + v2;
+ Vi = ((((Vhp + Vbp) * f.filterGain) + dc_offset) >> 12) + ve + v2;
offset = mixer_offset<4>::value;
break;
case 0x6b:
- Vi = (((Vhp + Vbp) * f.filterGain) >> 12) + ve + v2 + v1;
+ Vi = ((((Vhp + Vbp) * f.filterGain) + dc_offset) >> 12) + ve + v2 + v1;
offset = mixer_offset<5>::value;
break;
case 0x6c:
- Vi = (((Vhp + Vbp) * f.filterGain) >> 12) + ve + v3;
+ Vi = ((((Vhp + Vbp) * f.filterGain) + dc_offset) >> 12) + ve + v3;
offset = mixer_offset<4>::value;
break;
case 0x6d:
- Vi = (((Vhp + Vbp) * f.filterGain) >> 12) + ve + v3 + v1;
+ Vi = ((((Vhp + Vbp) * f.filterGain) + dc_offset) >> 12) + ve + v3 + v1;
offset = mixer_offset<5>::value;
break;
case 0x6e:
- Vi = (((Vhp + Vbp) * f.filterGain) >> 12) + ve + v3 + v2;
+ Vi = ((((Vhp + Vbp) * f.filterGain) + dc_offset) >> 12) + ve + v3 + v2;
offset = mixer_offset<5>::value;
break;
case 0x6f:
- Vi = (((Vhp + Vbp) * f.filterGain) >> 12) + ve + v3 + v2 + v1;
+ Vi = ((((Vhp + Vbp) * f.filterGain) + dc_offset) >> 12) + ve + v3 + v2 + v1;
offset = mixer_offset<6>::value;
break;
case 0x70:
- Vi = (((Vhp + Vbp + Vlp) * f.filterGain) >> 12);
+ Vi = ((((Vhp + Vbp + Vlp) * f.filterGain) + dc_offset) >> 12);
offset = mixer_offset<3>::value;
break;
case 0x71:
- Vi = (((Vhp + Vbp + Vlp) * f.filterGain) >> 12) + v1;
+ Vi = ((((Vhp + Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + v1;
offset = mixer_offset<4>::value;
break;
case 0x72:
- Vi = (((Vhp + Vbp + Vlp) * f.filterGain) >> 12) + v2;
+ Vi = ((((Vhp + Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + v2;
offset = mixer_offset<4>::value;
break;
case 0x73:
- Vi = (((Vhp + Vbp + Vlp) * f.filterGain) >> 12) + v2 + v1;
+ Vi = ((((Vhp + Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + v2 + v1;
offset = mixer_offset<5>::value;
break;
case 0x74:
- Vi = (((Vhp + Vbp + Vlp) * f.filterGain) >> 12) + v3;
+ Vi = ((((Vhp + Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + v3;
offset = mixer_offset<4>::value;
break;
case 0x75:
- Vi = (((Vhp + Vbp + Vlp) * f.filterGain) >> 12) + v3 + v1;
+ Vi = ((((Vhp + Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + v3 + v1;
offset = mixer_offset<5>::value;
break;
case 0x76:
- Vi = (((Vhp + Vbp + Vlp) * f.filterGain) >> 12) + v3 + v2;
+ Vi = ((((Vhp + Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + v3 + v2;
offset = mixer_offset<5>::value;
break;
case 0x77:
- Vi = (((Vhp + Vbp + Vlp) * f.filterGain) >> 12) + v3 + v2 + v1;
+ Vi = ((((Vhp + Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + v3 + v2 + v1;
offset = mixer_offset<6>::value;
break;
case 0x78:
- Vi = (((Vhp + Vbp + Vlp) * f.filterGain) >> 12) + ve;
+ Vi = ((((Vhp + Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + ve;
offset = mixer_offset<4>::value;
break;
case 0x79:
- Vi = (((Vhp + Vbp + Vlp) * f.filterGain) >> 12) + ve + v1;
+ Vi = ((((Vhp + Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v1;
offset = mixer_offset<5>::value;
break;
case 0x7a:
- Vi = (((Vhp + Vbp + Vlp) * f.filterGain) >> 12) + ve + v2;
+ Vi = ((((Vhp + Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v2;
offset = mixer_offset<5>::value;
break;
case 0x7b:
- Vi = (((Vhp + Vbp + Vlp) * f.filterGain) >> 12) + ve + v2 + v1;
+ Vi = ((((Vhp + Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v2 + v1;
offset = mixer_offset<6>::value;
break;
case 0x7c:
- Vi = (((Vhp + Vbp + Vlp) * f.filterGain) >> 12) + ve + v3;
+ Vi = ((((Vhp + Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v3;
offset = mixer_offset<5>::value;
break;
case 0x7d:
- Vi = (((Vhp + Vbp + Vlp) * f.filterGain) >> 12) + ve + v3 + v1;
+ Vi = ((((Vhp + Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v3 + v1;
offset = mixer_offset<6>::value;
break;
case 0x7e:
- Vi = (((Vhp + Vbp + Vlp) * f.filterGain) >> 12) + ve + v3 + v2;
+ Vi = ((((Vhp + Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v3 + v2;
offset = mixer_offset<6>::value;
break;
case 0x7f:
- Vi = (((Vhp + Vbp + Vlp) * f.filterGain) >> 12) + ve + v3 + v2 + v1;
+ Vi = ((((Vhp + Vbp + Vlp) * f.filterGain) + dc_offset) >> 12) + ve + v3 + v2 + v1;
offset = mixer_offset<7>::value;
break;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gp...@us...> - 2025-08-09 16:54:30
|
Revision: 45733
http://sourceforge.net/p/vice-emu/code/45733
Author: gpz
Date: 2025-08-09 16:54:29 +0000 (Sat, 09 Aug 2025)
Log Message:
-----------
fix some more FIXMEs, image saving and flushing should work now
Modified Paths:
--------------
trunk/vice/src/vic20/cart/minimon.c
trunk/vice/src/vic20/cart/vic20cart.c
Modified: trunk/vice/src/vic20/cart/minimon.c
===================================================================
--- trunk/vice/src/vic20/cart/minimon.c 2025-08-08 16:05:33 UTC (rev 45732)
+++ trunk/vice/src/vic20/cart/minimon.c 2025-08-09 16:54:29 UTC (rev 45733)
@@ -108,6 +108,9 @@
static int minimon_io23_temp = 0;
+static int set_minimon_enabled(int value, void *param);
+static int minimon_rom_reload(char *filename);
+
/* ------------------------------------------------------------------------- */
static int freeze_triggered = 0; /* if not 0, a "freeze reset" was just triggered */
@@ -179,8 +182,6 @@
/* ------------------------------------------------------------------------- */
-static int minimon_rom_reload(char *filename);
-
/* FIXME: this still needs to be tweaked to match the hardware */
static RAMINITPARAM ramparam = {
.start_value = 255,
@@ -457,11 +458,18 @@
/* set the MinimonFilename resource */
static int set_minimon_image_filename(const char *name, void *param)
{
- DBG(("set_minimon_image_filename '%s'", name));
- if (minimon_image_filename != NULL && name != NULL && strcmp(name, minimon_image_filename) == 0) {
+ int enabled = minimon_enabled;
+
+ DBG(("set_minimon_image_filename '%s' (enabled: %d)", name, enabled));
+
+ /* if filename was already set, but not changed, return */
+ if ((minimon_image_filename != NULL) &&
+ (name != NULL) &&
+ (strcmp(name, minimon_image_filename) == 0)) {
return 0;
}
+ /* if filename is valid, check if a file with that name exists */
if ((name != NULL) && (*name != '\0')) {
if (util_check_filename_access(name) < 0) {
return -1;
@@ -469,17 +477,14 @@
}
DBG(("set_minimon_image_filename"));
- if (minimon_enabled) {
- minimon_flush_image();
- util_string_set(&minimon_image_filename, name);
- } else {
- util_string_set(&minimon_image_filename, name);
- }
- /* FIXME: load new image */
- log_warning(LOG_DEFAULT, "FIXME: load minimon image on resource change");
+ /* if already enabled, flush image and disable */
+ set_minimon_enabled(0, (void*)1);
- return 0;
+ util_string_set(&minimon_image_filename, name);
+
+ /* enable, load new image */
+ return set_minimon_enabled(enabled, (void*)1);
}
/* get the MinimonEnabled resource */
@@ -488,7 +493,6 @@
return minimon_enabled;
}
-
static int minimon_activate(void)
{
minimon_bios_changed = 0;
@@ -500,7 +504,11 @@
{
int ret;
+ DBG(("minimon_deactivate: minimon_bios_changed: %d minimon_bios_write: %d",
+ minimon_bios_changed, minimon_bios_write));
+
if (minimon_bios_changed && minimon_bios_write) {
+ DBG(("minimon_deactivate: flushing image"));
if (minimon_bios_type == CARTRIDGE_FILETYPE_CRT) {
ret = minimon_crt_save(minimon_image_filename);
} else {
@@ -507,6 +515,7 @@
ret = minimon_bin_save(minimon_image_filename);
}
if (ret <= 0) {
+ DBG(("minimon_deactivate: flush failed"));
return 0; /* FIXME */
}
}
@@ -793,7 +802,6 @@
int minimon_bin_save(const char *filename)
{
- /* FIXME */
FILE *fd;
size_t ret;
@@ -818,12 +826,11 @@
return -1;
}
minimon_bios_changed = 0;
- return -1;
+ return 0;
}
int minimon_crt_save(const char *filename)
{
- /* FIXME */
FILE *fd;
crt_chip_header_t chip;
@@ -850,29 +857,25 @@
}
fclose(fd);
- return -1;
+ return 0;
}
int minimon_flush_image(void)
{
- /* FIXME */
- int ret = -1;
-
+ int ret = 0;
+ DBG(("minimon_flush_image minimon_bios_changed:%d minimon_bios_write:%d",
+ minimon_bios_changed, minimon_bios_write));
if (minimon_bios_type == CARTRIDGE_FILETYPE_NONE) {
log_warning(LOG_DEFAULT, "Flush: no minimon image attached");
- return 0;
- }
- if (minimon_bios_changed && minimon_bios_write) {
+ } else if (minimon_bios_changed && minimon_bios_write) {
if (minimon_bios_type == CARTRIDGE_FILETYPE_CRT) {
ret = minimon_crt_save(minimon_image_filename);
} else {
ret = minimon_bin_save(minimon_image_filename);
}
- if (ret <= 0) {
- return 0; /* FIXME */
- }
}
minimon_bios_changed = 0;
+ DBG(("minimon_flush_image ret: %d", ret));
return ret;
}
Modified: trunk/vice/src/vic20/cart/vic20cart.c
===================================================================
--- trunk/vice/src/vic20/cart/vic20cart.c 2025-08-08 16:05:33 UTC (rev 45732)
+++ trunk/vice/src/vic20/cart/vic20cart.c 2025-08-09 16:54:29 UTC (rev 45733)
@@ -1203,12 +1203,16 @@
{
const char *p;
if (!cartridge_type_enabled(crtid)) {
+ DBG(("cartridge_can_flush_image crtid:%d ret: 0", crtid));
return 0;
}
p = cartridge_get_filename_by_crtid(crtid);
if ((p == NULL) || (*p == '\x0')) {
+ DBG(("cartridge_can_flush_image crtid:%d ret: 0", crtid));
return 0;
}
+
+ DBG(("cartridge_can_flush_image crtid:%d ret: 1", crtid));
return 1;
}
@@ -1229,8 +1233,10 @@
int cartridge_can_save_image(int crtid)
{
if (!cartridge_type_enabled(crtid)) {
+ DBG(("cartridge_can_save_image crtid:%d ret: 0", crtid));
return 0;
}
+ DBG(("cartridge_can_save_image crtid:%d ret: 1", crtid));
return 1;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gp...@us...> - 2025-08-08 16:05:36
|
Revision: 45732
http://sourceforge.net/p/vice-emu/code/45732
Author: gpz
Date: 2025-08-08 16:05:33 +0000 (Fri, 08 Aug 2025)
Log Message:
-----------
fix enabling minimon via resource, should fix #2152
Modified Paths:
--------------
trunk/vice/src/vic20/cart/minimon.c
trunk/vice/src/vic20/cart/vic20cart.c
trunk/vice/src/vic20/cart/vic20cartmem.c
Modified: trunk/vice/src/vic20/cart/minimon.c
===================================================================
--- trunk/vice/src/vic20/cart/minimon.c 2025-08-07 22:10:20 UTC (rev 45731)
+++ trunk/vice/src/vic20/cart/minimon.c 2025-08-08 16:05:33 UTC (rev 45732)
@@ -488,47 +488,93 @@
return minimon_enabled;
}
+
+static int minimon_activate(void)
+{
+ minimon_bios_changed = 0;
+ /* minimon_reset(); */
+ return 0;
+}
+
+static int minimon_deactivate(void)
+{
+ int ret;
+
+ if (minimon_bios_changed && minimon_bios_write) {
+ if (minimon_bios_type == CARTRIDGE_FILETYPE_CRT) {
+ ret = minimon_crt_save(minimon_image_filename);
+ } else {
+ ret = minimon_bin_save(minimon_image_filename);
+ }
+ if (ret <= 0) {
+ return 0; /* FIXME */
+ }
+ }
+ return 0;
+}
+
/* setup the MinimonEnabled resource */
static int set_minimon_enabled(int value, void *param)
{
int val = value ? 1 : 0;
- if (minimon_enabled == val) {
- DBG(("set_minimon_enabled: %d to %d (nothing to do)", minimon_enabled, val));
- return 0; /* nothing to do */
- }
-
- DBG(("set_minimon_enabled: %d to %d", minimon_enabled, val));
- if (val) {
-
- /* prepare the RAM/ROM */
- if (minimon_rom) {
- clear_ram();
+ DBG(("Minimon: set_enabled: '%s' %d to %d", minimon_image_filename, minimon_enabled, val));
+ if (!minimon_enabled && val) {
+ /* activate minimon */
+ if (param) {
+ /* if the param is != NULL, then we should load the default image file */
+ DBG(("Minimon: set_enabled(1) '%s'", minimon_image_filename));
if (minimon_image_filename) {
- minimon_rom_reload(minimon_image_filename);
+ if (*minimon_image_filename) {
+ /* try .crt first */
+ if ((cartridge_attach_image(CARTRIDGE_CRT, minimon_image_filename) < 0) &&
+ (cartridge_attach_image(CARTRIDGE_VIC20_MINIMON, minimon_image_filename) < 0)) {
+ DBG(("Minimon: set_enabled(1) did not register"));
+ return -1;
+ }
+ /* minimon_enabled = 1; */ /* cartridge_attach_image will end up calling set_minimon_enabled again */
+ return 0;
+ }
}
+ } else {
+ DBG(("Minimon: set_enabled(0) '%s'", minimon_image_filename));
+ /* cart_power_off(); */
+ /* if the param is == NULL, then we should actually set the resource */
+ if (export_add(&export_res23) < 0) {
+ DBG(("Minimon: set_enabled(0) did not register"));
+ return -1;
+ } else {
+ DBG(("Minimon: set_enabled registered"));
+
+ if (minimon_activate() < 0) {
+ return -1;
+ }
+ minimon_enabled = 1;
+ minimon_io2_list_item = io_source_register(&minimon_io2_device);
+ minimon_io3_list_item = io_source_register(&minimon_io3_device);
+ minimon_reset();
+ minimon_alarm_install();
+ }
}
-
- /* enable cartridge */
- if (export_add(&export_res23) < 0) {
+ } else if (minimon_enabled && !val) {
+ /* remove minimon */
+ if (minimon_deactivate() < 0) {
return -1;
}
- if (minimon_io_enabled) {
- io_register();
- }
- /* FIXME: minimon_reload_file(); */
- minimon_alarm_install();
- } else {
- /* disable cartridge */
- io_unregister();
minimon_alarm_deinstall();
+ /* cart_power_off(); */
export_remove(&export_res23);
+ minimon_enabled = 0;
+ io_source_unregister(minimon_io2_list_item);
+ io_source_unregister(minimon_io3_list_item);
+ minimon_io2_list_item = NULL;
+ minimon_io3_list_item = NULL;
}
- minimon_enabled = val; /* resource */
-
+ DBG(("Minimon: set_enabled done: '%s' %d : %d", minimon_image_filename, val, minimon_enabled));
return 0;
}
+
/* set the resource for the PGM switch */
static int set_minimon_pgm_enabled(int value, void *param)
{
Modified: trunk/vice/src/vic20/cart/vic20cart.c
===================================================================
--- trunk/vice/src/vic20/cart/vic20cart.c 2025-08-07 22:10:20 UTC (rev 45731)
+++ trunk/vice/src/vic20/cart/vic20cart.c 2025-08-08 16:05:33 UTC (rev 45732)
@@ -762,14 +762,10 @@
cart currently is in the "Main Slot" */
oldmain = cart_getid_slotmain();
if (oldmain != CARTRIDGE_NONE) {
- DBG(("CART: detach slot main ID: %d\n", oldmain));
+ DBG(("CART: detach slot main ID: %d", oldmain));
cartridge_detach_image(oldmain);
}
}
- if (oldmain != carttype) {
- DBG(("CART: detach %s ID: %d\n", slotmain ? "slot main" : "other slot", carttype));
- cartridge_detach_image(carttype);
- }
#endif
switch (carttype) {
case CARTRIDGE_VIC20_DETECT:
@@ -914,6 +910,7 @@
void cartridge_detach_image(int type)
{
+ DBG(("CART: cartridge_detach_image vic20cart_type:%d type:%d", vic20cart_type, type));
cartridge_detach(vic20cart_type);
vic20cart_type = CARTRIDGE_NONE;
cartridge_is_from_snapshot = 0;
Modified: trunk/vice/src/vic20/cart/vic20cartmem.c
===================================================================
--- trunk/vice/src/vic20/cart/vic20cartmem.c 2025-08-07 22:10:20 UTC (rev 45731)
+++ trunk/vice/src/vic20/cart/vic20cartmem.c 2025-08-08 16:05:33 UTC (rev 45732)
@@ -387,7 +387,7 @@
{
int res = CART_READ_THROUGH;
uint8_t value;
- DBG(("cartridge_read_blk5 (%d) 0x%04x", mem_cartridge_type, addr));
+ /* DBG(("cartridge_read_blk5 (%d) 0x%04x", mem_cartridge_type, addr)); */
/* "Slot 0" */
@@ -398,7 +398,7 @@
}
/* open bus value, in case no cartridge is attached to pass through */
vic20_cpu_last_data = (addr >> 8);
- printf("cartridge_read_blk5 %02x %04x\n", vic20_cpu_last_data, addr);
+ /* DBG(("cartridge_read_blk5 %02x %04x", vic20_cpu_last_data, addr)); */
}
/* main slot */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gp...@us...> - 2025-08-07 22:10:22
|
Revision: 45731
http://sourceforge.net/p/vice-emu/code/45731
Author: gpz
Date: 2025-08-07 22:10:20 +0000 (Thu, 07 Aug 2025)
Log Message:
-----------
on vic20 the error is significantly worse when display dma is going on. still very much not accurrate emulation, but still better than nothing
Modified Paths:
--------------
trunk/vice/src/vic20/vic-mem.c
Modified: trunk/vice/src/vic20/vic-mem.c
===================================================================
--- trunk/vice/src/vic20/vic-mem.c 2025-08-07 20:11:48 UTC (rev 45730)
+++ trunk/vice/src/vic20/vic-mem.c 2025-08-07 22:10:20 UTC (rev 45731)
@@ -288,13 +288,19 @@
/* Add some randomness to the pot value(s). Note that _with paddles_ the error
gets gradually worse depending on the sampled value (the larger the value,
- the bigger error. This does _not_ happen with the 1351 mouse */
+ the bigger error. This does _not_ happen with the 1351 mouse.
+ Additionally the amount of error appears to depend on display DMA.
+*/
static inline uint8_t makepotval(int value)
{
unsigned int fuzz;
if (get_joyport_pot_type() == JOYPORT_POT_TYPE_ANALOG) {
- fuzz = lib_unsigned_rand(0, (value * 5) / 255);
+ if (vic.area == VIC_AREA_DISPLAY) {
+ fuzz = lib_unsigned_rand(0, 1 + ((value * 25) / 255));
+ } else {
+ fuzz = lib_unsigned_rand(0, 1 + ((value * 5) / 255));
+ }
} else {
fuzz = lib_unsigned_rand(0, 1);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gp...@us...> - 2025-08-07 20:11:50
|
Revision: 45730
http://sourceforge.net/p/vice-emu/code/45730
Author: gpz
Date: 2025-08-07 20:11:48 +0000 (Thu, 07 Aug 2025)
Log Message:
-----------
also produce a prg that disables IRQ, for quick cross checking
Modified Paths:
--------------
testprogs/SID/paddlescope/Makefile
testprogs/SID/paddlescope/plotter.asm
testprogs/SID/paddlescope/plotter.prg
Added Paths:
-----------
testprogs/SID/paddlescope/plotter-sei.prg
Modified: testprogs/SID/paddlescope/Makefile
===================================================================
--- testprogs/SID/paddlescope/Makefile 2025-08-07 20:10:05 UTC (rev 45729)
+++ testprogs/SID/paddlescope/Makefile 2025-08-07 20:11:48 UTC (rev 45730)
@@ -1,8 +1,11 @@
-all: plotter.prg
+all: plotter.prg plotter-sei.prg
plotter.prg: plotter.asm
- acme --cpu 6510 -f cbm -o plotter.prg plotter.asm
+ acme -DIRQ=1 --cpu 6510 -f cbm -o plotter.prg plotter.asm
+plotter-sei.prg: plotter.asm
+ acme -DIRQ=0 --cpu 6510 -f cbm -o plotter-sei.prg plotter.asm
clean:
$(RM) plotter.prg
+ $(RM) plotter-sei.prg
Added: testprogs/SID/paddlescope/plotter-sei.prg
===================================================================
(Binary files differ)
Index: testprogs/SID/paddlescope/plotter-sei.prg
===================================================================
--- testprogs/SID/paddlescope/plotter-sei.prg 2025-08-07 20:10:05 UTC (rev 45729)
+++ testprogs/SID/paddlescope/plotter-sei.prg 2025-08-07 20:11:48 UTC (rev 45730)
Property changes on: testprogs/SID/paddlescope/plotter-sei.prg
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/x-commodore-exec
\ No newline at end of property
Modified: testprogs/SID/paddlescope/plotter.asm
===================================================================
--- testprogs/SID/paddlescope/plotter.asm 2025-08-07 20:10:05 UTC (rev 45729)
+++ testprogs/SID/paddlescope/plotter.asm 2025-08-07 20:11:48 UTC (rev 45730)
@@ -12,6 +12,9 @@
!byte $32,$30,$36,$34
*= $0810
+!if IRQ=0 {
+ sei
+}
lda #0
sta $d020
sta $d021
Modified: testprogs/SID/paddlescope/plotter.prg
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gp...@us...> - 2025-08-07 20:10:08
|
Revision: 45729
http://sourceforge.net/p/vice-emu/code/45729
Author: gpz
Date: 2025-08-07 20:10:05 +0000 (Thu, 07 Aug 2025)
Log Message:
-----------
naive model of how the POT values glitch when reading them in the first (incomplete) sample period after switching the control ports, should fix #2159
Modified Paths:
--------------
trunk/vice/src/joyport/joyport.c
trunk/vice/src/joyport/joyport.h
trunk/vice/src/sid/sid.c
Modified: trunk/vice/src/joyport/joyport.c
===================================================================
--- trunk/vice/src/joyport/joyport.c 2025-08-07 13:23:07 UTC (rev 45728)
+++ trunk/vice/src/joyport/joyport.c 2025-08-07 20:10:05 UTC (rev 45729)
@@ -45,6 +45,7 @@
#include "lightpen.h"
#include "log.h"
#include "machine.h"
+#include "maincpu.h"
#include "mouse_1351.h"
#include "mouse_neos.h"
#include "mouse_paddle.h"
@@ -82,6 +83,7 @@
static int joy_port[JOYPORT_MAX_PORTS];
static joyport_port_props_t port_props[JOYPORT_MAX_PORTS];
static int pot_port_mask = 1;
+static CLOCK pot_port_mask_clk = 0; /* time when the mask changed */
static uint8_t joyport_dig_stored[JOYPORT_MAX_PORTS];
@@ -119,9 +121,17 @@
/* setup which port(s) are selected, ie the upper 2 bits of $dc00 on C64 */
void set_joyport_pot_mask(int mask)
{
+ if (pot_port_mask != mask) {
+ pot_port_mask_clk = maincpu_clk;
+ }
pot_port_mask = mask;
}
+CLOCK get_joyport_pot_mask_clk(void)
+{
+ return pot_port_mask_clk;
+}
+
static int joyport_device_is_single_port(int id)
{
switch (id) {
Modified: trunk/vice/src/joyport/joyport.h
===================================================================
--- trunk/vice/src/joyport/joyport.h 2025-08-07 13:23:07 UTC (rev 45728)
+++ trunk/vice/src/joyport/joyport.h 2025-08-07 20:10:05 UTC (rev 45729)
@@ -340,6 +340,7 @@
uint8_t read_joyport_poty(void);
void set_joyport_pot_mask(int mask);
+CLOCK get_joyport_pot_mask_clk(void); /* get time since last port switch */
#define JOYPORT_POT_TYPE_ANALOG 0 /* regular resistor */
#define JOYPORT_POT_TYPE_DIGITAL 1 /* digital (1351 style) */
Modified: trunk/vice/src/sid/sid.c
===================================================================
--- trunk/vice/src/sid/sid.c 2025-08-07 13:23:07 UTC (rev 45728)
+++ trunk/vice/src/sid/sid.c 2025-08-07 20:10:05 UTC (rev 45729)
@@ -192,6 +192,25 @@
return value;
}
+/* this creates a "glitched" value that might be read in the first incomplete
+ sample period after switching the control port */
+static inline uint8_t makebadpotval(int value, int clkdiff)
+{
+ unsigned int fuzz;
+
+ if (get_joyport_pot_type() == JOYPORT_POT_TYPE_ANALOG) {
+ fuzz = lib_unsigned_rand(0, (clkdiff * 32) / 255);
+ } else {
+ fuzz = lib_unsigned_rand(0, 255);
+ }
+
+ value += fuzz;
+ if (value > 255) {
+ return 255;
+ }
+ return value;
+}
+
static uint8_t sid_read_chip(uint16_t addr, int chipno)
{
int val = -1;
@@ -203,15 +222,26 @@
#ifdef HAVE_MOUSE
if (chipno == 0 && (addr == 0x19 || addr == 0x1a)) {
#if 1
- if ((maincpu_clk ^ pot_cycle) & ~511) {
- pot_cycle = maincpu_clk & ~511; /* simplistic 512 cycle sampling */
+ CLOCK port_changed_clk = get_joyport_pot_mask_clk();
+ CLOCK port_changed_diff_clk = maincpu_clk - port_changed_clk;
+ if (port_changed_diff_clk > 511) {
+ /* produce a regular value */
+ if ((maincpu_clk ^ pot_cycle) & ~511) {
+ pot_cycle = maincpu_clk & ~511; /* simplistic 512 cycle sampling */
- if (_mouse_enabled) {
- mouse_poll();
+ if (_mouse_enabled) {
+ mouse_poll();
+ }
+
+ val_pot_x = makepotval(read_joyport_potx());
+ val_pot_y = makepotval(read_joyport_poty());
}
-
- val_pot_x = makepotval(read_joyport_potx());
- val_pot_y = makepotval(read_joyport_poty());
+ } else {
+ /* produce a "bad" value in case the POT register was read within
+ the first sample period after switching the port */
+ pot_cycle = port_changed_clk & ~511;
+ val_pot_x = makebadpotval(read_joyport_potx(), 512 - (int)port_changed_diff_clk);
+ val_pot_y = makebadpotval(read_joyport_poty(), 512 - (int)port_changed_diff_clk);
}
#endif
val = (addr == 0x19) ? val_pot_x : val_pot_y;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gp...@us...> - 2025-08-07 13:23:08
|
Revision: 45728
http://sourceforge.net/p/vice-emu/code/45728
Author: gpz
Date: 2025-08-07 13:23:07 +0000 (Thu, 07 Aug 2025)
Log Message:
-----------
small optimization
Modified Paths:
--------------
testprogs/SID/paddlescope/plotter.asm
testprogs/SID/paddlescope/plotter.prg
Modified: testprogs/SID/paddlescope/plotter.asm
===================================================================
--- testprogs/SID/paddlescope/plotter.asm 2025-08-06 22:38:25 UTC (rev 45727)
+++ testprogs/SID/paddlescope/plotter.asm 2025-08-07 13:23:07 UTC (rev 45728)
@@ -95,14 +95,6 @@
lda bitmaplo,x
sta lineaddr+0
- clc
- lda lineaddr+0
- adc #<(20*8)
- sta lineaddr2+0
- lda lineaddr+1
- adc #>(20*8)
- sta lineaddr2+1
-
; clear the line
ldx #0
-
@@ -109,13 +101,7 @@
lda #0
lineaddr=*+1
sta bitmap + (0 * 8),x
-lineaddr2=*+1
- sta bitmap + (20 * 8),x
-; txa
-; clc
-; adc #8
-; tax
-; cpx #(20*8)
+
lda add8,x
tax
bne -
@@ -165,7 +151,7 @@
!byte %00000010
!byte %00000001
}
-
+
!align 255,0
bitmaphi:
@@ -182,9 +168,6 @@
!align 255,0
add8:
- !for n, 0, 151 {
+ !for n, 0, 255 {
!byte <(n+8)
}
- !for n, 152, 255 {
- !byte 0
- }
Modified: testprogs/SID/paddlescope/plotter.prg
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gp...@us...> - 2025-08-06 22:38:27
|
Revision: 45727
http://sourceforge.net/p/vice-emu/code/45727
Author: gpz
Date: 2025-08-06 22:38:25 +0000 (Wed, 06 Aug 2025)
Log Message:
-----------
use different jitter depending on whether a 1351-style mouse or regular resistor is connected to POT input. Not really 100% correct, but should work for all practical purposes
Modified Paths:
--------------
trunk/vice/src/joyport/joyport.c
trunk/vice/src/joyport/joyport.h
trunk/vice/src/sid/sid.c
trunk/vice/src/vic20/vic-mem.c
Modified: trunk/vice/src/joyport/joyport.c
===================================================================
--- trunk/vice/src/joyport/joyport.c 2025-08-06 18:13:36 UTC (rev 45726)
+++ trunk/vice/src/joyport/joyport.c 2025-08-06 22:38:25 UTC (rev 45727)
@@ -116,6 +116,7 @@
return retval;
}
+/* setup which port(s) are selected, ie the upper 2 bits of $dc00 on C64 */
void set_joyport_pot_mask(int mask)
{
pot_port_mask = mask;
@@ -312,6 +313,40 @@
}
}
+/* returns JOYPORT_POT_TYPE_DIGITAL if one of the selected POTs is a digital
+ (1351 style) device. we need this to correctly emulate the dither produced
+ when sampling the POTs */
+int get_joyport_pot_type(void)
+{
+ /* first find the pot ports if needed */
+ if (pot_port1 == -1 || pot_port2 == -1) {
+ find_pot_ports();
+ }
+
+ if (pot_port_mask == 1 || pot_port_mask == 3) {
+ if (pot_port1 != -2) {
+ switch (joy_port[pot_port1]) {
+ case JOYPORT_ID_MOUSE_1351:
+ case JOYPORT_ID_MOUSE_SMART:
+ case JOYPORT_ID_MOUSE_MICROMYS:
+ return JOYPORT_POT_TYPE_DIGITAL;
+ }
+ }
+ }
+
+ if (pot_port_mask == 2 || pot_port_mask == 3) {
+ if (pot_port2 != -2) {
+ switch (joy_port[pot_port2]) {
+ case JOYPORT_ID_MOUSE_1351:
+ case JOYPORT_ID_MOUSE_SMART:
+ case JOYPORT_ID_MOUSE_MICROMYS:
+ return JOYPORT_POT_TYPE_DIGITAL;
+ }
+ }
+ }
+ return JOYPORT_POT_TYPE_ANALOG;
+}
+
/* calculate the paddle value that will show in the registers when both
ports are selected at the same time */
static uint8_t calc_parallel_paddle_value(uint8_t t1, uint8_t t2)
Modified: trunk/vice/src/joyport/joyport.h
===================================================================
--- trunk/vice/src/joyport/joyport.h 2025-08-06 18:13:36 UTC (rev 45726)
+++ trunk/vice/src/joyport/joyport.h 2025-08-06 22:38:25 UTC (rev 45727)
@@ -341,6 +341,10 @@
void set_joyport_pot_mask(int mask);
+#define JOYPORT_POT_TYPE_ANALOG 0 /* regular resistor */
+#define JOYPORT_POT_TYPE_DIGITAL 1 /* digital (1351 style) */
+int get_joyport_pot_type(void);
+
void joyport_powerup(void);
int joyport_resources_init(void);
Modified: trunk/vice/src/sid/sid.c
===================================================================
--- trunk/vice/src/sid/sid.c 2025-08-06 18:13:36 UTC (rev 45726)
+++ trunk/vice/src/sid/sid.c 2025-08-06 22:38:25 UTC (rev 45727)
@@ -177,13 +177,14 @@
the bigger error. This does _not_ happen with the 1351 mouse */
static inline uint8_t makepotval(int value)
{
-/* FIXME: we must somehow determine whether this is a 1531 or not, use the
- lesser error for the time being */
-#if 0
- unsigned int fuzz = lib_unsigned_rand(0, (value * 5) / 255);
-#else
- unsigned int fuzz = lib_unsigned_rand(0, 1);
-#endif
+ unsigned int fuzz;
+
+ if (get_joyport_pot_type() == JOYPORT_POT_TYPE_ANALOG) {
+ fuzz = lib_unsigned_rand(0, (value * 5) / 255);
+ } else {
+ fuzz = lib_unsigned_rand(0, 1);
+ }
+
value += fuzz;
if (value > 255) {
return 255;
Modified: trunk/vice/src/vic20/vic-mem.c
===================================================================
--- trunk/vice/src/vic20/vic-mem.c 2025-08-06 18:13:36 UTC (rev 45726)
+++ trunk/vice/src/vic20/vic-mem.c 2025-08-06 22:38:25 UTC (rev 45727)
@@ -291,13 +291,14 @@
the bigger error. This does _not_ happen with the 1351 mouse */
static inline uint8_t makepotval(int value)
{
-/* FIXME: we must somehow determine whether this is a 1531 or not, use the
- lesser error for the time being */
-#if 0
- unsigned int fuzz = lib_unsigned_rand(0, (value * 5) / 255);
-#else
- unsigned int fuzz = lib_unsigned_rand(0, 1);
-#endif
+ unsigned int fuzz;
+
+ if (get_joyport_pot_type() == JOYPORT_POT_TYPE_ANALOG) {
+ fuzz = lib_unsigned_rand(0, (value * 5) / 255);
+ } else {
+ fuzz = lib_unsigned_rand(0, 1);
+ }
+
value += fuzz;
if (value > 255) {
return 255;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gp...@us...> - 2025-08-06 18:13:44
|
Revision: 45726
http://sourceforge.net/p/vice-emu/code/45726
Author: gpz
Date: 2025-08-06 18:13:36 +0000 (Wed, 06 Aug 2025)
Log Message:
-----------
add some jitter to the lsb of the POT values, partial fix for #2159
Modified Paths:
--------------
trunk/vice/src/sid/sid.c
trunk/vice/src/vic20/vic-mem.c
Modified: trunk/vice/src/sid/sid.c
===================================================================
--- trunk/vice/src/sid/sid.c 2025-08-06 18:10:13 UTC (rev 45725)
+++ trunk/vice/src/sid/sid.c 2025-08-06 18:13:36 UTC (rev 45726)
@@ -172,6 +172,25 @@
#endif
/* ------------------------------------------------------------------------- */
+/* Add some randomness to the pot value(s). Note that _with paddles_ the error
+ gets gradually worse depending on the sampled value (the larger the value,
+ the bigger error. This does _not_ happen with the 1351 mouse */
+static inline uint8_t makepotval(int value)
+{
+/* FIXME: we must somehow determine whether this is a 1531 or not, use the
+ lesser error for the time being */
+#if 0
+ unsigned int fuzz = lib_unsigned_rand(0, (value * 5) / 255);
+#else
+ unsigned int fuzz = lib_unsigned_rand(0, 1);
+#endif
+ value += fuzz;
+ if (value > 255) {
+ return 255;
+ }
+ return value;
+}
+
static uint8_t sid_read_chip(uint16_t addr, int chipno)
{
int val = -1;
@@ -190,8 +209,8 @@
mouse_poll();
}
- val_pot_x = read_joyport_potx();
- val_pot_y = read_joyport_poty();
+ val_pot_x = makepotval(read_joyport_potx());
+ val_pot_y = makepotval(read_joyport_poty());
}
#endif
val = (addr == 0x19) ? val_pot_x : val_pot_y;
Modified: trunk/vice/src/vic20/vic-mem.c
===================================================================
--- trunk/vice/src/vic20/vic-mem.c 2025-08-06 18:10:13 UTC (rev 45725)
+++ trunk/vice/src/vic20/vic-mem.c 2025-08-06 18:13:36 UTC (rev 45726)
@@ -33,6 +33,7 @@
#include <string.h>
#include "joyport.h"
+#include "lib.h"
#include "maincpu.h"
#include "raster-changes.h"
#include "types.h"
@@ -285,6 +286,25 @@
return ypos;
}
+/* Add some randomness to the pot value(s). Note that _with paddles_ the error
+ gets gradually worse depending on the sampled value (the larger the value,
+ the bigger error. This does _not_ happen with the 1351 mouse */
+static inline uint8_t makepotval(int value)
+{
+/* FIXME: we must somehow determine whether this is a 1531 or not, use the
+ lesser error for the time being */
+#if 0
+ unsigned int fuzz = lib_unsigned_rand(0, (value * 5) / 255);
+#else
+ unsigned int fuzz = lib_unsigned_rand(0, 1);
+#endif
+ value += fuzz;
+ if (value > 255) {
+ return 255;
+ }
+ return value;
+}
+
uint8_t vic_read(uint16_t addr)
{
addr &= 0xf;
@@ -298,8 +318,8 @@
mouse_poll();
}
- vic.regs[8] = read_joyport_potx();
- vic.regs[9] = read_joyport_poty();
+ vic.regs[8] = makepotval(read_joyport_potx());
+ vic.regs[9] = makepotval(read_joyport_poty());
}
}
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gp...@us...> - 2025-08-06 18:10:14
|
Revision: 45725
http://sourceforge.net/p/vice-emu/code/45725
Author: gpz
Date: 2025-08-06 18:10:13 +0000 (Wed, 06 Aug 2025)
Log Message:
-----------
add test prgram to show pot sample jitter/artefacts, related to bug #2159
Added Paths:
-----------
testprogs/SID/paddlescope/
testprogs/SID/paddlescope/Makefile
testprogs/SID/paddlescope/plotter.asm
testprogs/SID/paddlescope/plotter.prg
testprogs/SID/paddlescope/readme.txt
Added: testprogs/SID/paddlescope/Makefile
===================================================================
--- testprogs/SID/paddlescope/Makefile (rev 0)
+++ testprogs/SID/paddlescope/Makefile 2025-08-06 18:10:13 UTC (rev 45725)
@@ -0,0 +1,8 @@
+
+all: plotter.prg
+
+plotter.prg: plotter.asm
+ acme --cpu 6510 -f cbm -o plotter.prg plotter.asm
+
+clean:
+ $(RM) plotter.prg
Added: testprogs/SID/paddlescope/plotter.asm
===================================================================
--- testprogs/SID/paddlescope/plotter.asm (rev 0)
+++ testprogs/SID/paddlescope/plotter.asm 2025-08-06 18:10:13 UTC (rev 45725)
@@ -0,0 +1,190 @@
+bitmap = $2000
+vram = $0400
+
+xposlo = $fa
+xposhi = $fb
+
+linecount = $02
+
+
+ *= $0801
+ !byte $0c,$08,$0b,$00,$9e
+ !byte $32,$30,$36,$34
+ *= $0810
+
+ lda #0
+ sta $d020
+ sta $d021
+
+ jsr initplot
+
+ jmp doplot
+
+initplot:
+ ldy #13
+--
+ ldx #0
+ lda #$1b
+-
+ lda clearline,x
+clearaddr=*+1
+ sta vram,x
+ lda clearline2,x
+clearaddr2=*+1
+ sta vram+40,x
+ inx
+ cpx #40
+ bne -
+
+ lda clearaddr
+ clc
+ adc #40*2
+ sta clearaddr
+ bcc +
+ inc clearaddr+1
++
+ lda clearaddr2
+ clc
+ adc #40*2
+ sta clearaddr2
+ bcc +
+ inc clearaddr2+1
++
+ dey
+ bne --
+
+ lda #0
+ ldy #$20
+ ldx #0
+-
+bitmaphiaddr=*+2
+ sta bitmap,x
+ inx
+ bne -
+ inc bitmaphiaddr
+ dey
+ bne -
+
+ lda #$3b
+ sta $d011
+ lda #$18
+ sta $d018
+
+ lda #0
+ sta xposlo
+ sta xposhi
+
+ rts
+;-------------------------------------------------------------------------------
+
+
+paddlereg = $d419
+
+doplot:
+
+ ; get line address
+ ldx linecount
+ inx
+ cpx #(25*8)
+ bne +
+ ldx #0
++ stx linecount
+
+ lda bitmaphi,x
+ sta lineaddr+1
+ lda bitmaplo,x
+ sta lineaddr+0
+
+ clc
+ lda lineaddr+0
+ adc #<(20*8)
+ sta lineaddr2+0
+ lda lineaddr+1
+ adc #>(20*8)
+ sta lineaddr2+1
+
+ ; clear the line
+ ldx #0
+-
+ lda #0
+lineaddr=*+1
+ sta bitmap + (0 * 8),x
+lineaddr2=*+1
+ sta bitmap + (20 * 8),x
+; txa
+; clc
+; adc #8
+; tax
+; cpx #(20*8)
+ lda add8,x
+ tax
+ bne -
+
+ ; plot the plot
+ lda paddlereg
+ tax
+ and #%11111000
+ clc
+ adc lineaddr+0
+ sta lineaddr3+0
+
+ lda #0
+ adc lineaddr+1
+ sta lineaddr3+1
+
+ lda bitmapbits,x
+
+lineaddr3=*+1
+ sta bitmap + (0 * 8)
+
+ jmp doplot
+
+;-------------------------------------------------------------------------------
+
+clearline:
+ !byte $10,$1b,$10,$1b,$16,$1e,$16,$1e,$16,$1e
+ !byte $16,$0d,$05,$0d,$05,$0d,$05,$0d,$05,$0d
+ !byte $05,$0d,$05,$0d,$05,$0d,$05,$0d,$05,$1e
+ !byte $16,$1e,$16,$1e,$16,$1e,$10,$1b,$10,$1b
+clearline2:
+ !byte $1b,$10,$1b,$10,$1e,$16,$1e,$16,$1e,$16
+ !byte $1e,$05,$0d,$05,$0d,$05,$0d,$05,$0d,$05
+ !byte $0d,$05,$0d,$05,$0d,$05,$0d,$05,$0d,$16
+ !byte $1e,$16,$1e,$16,$1e,$16,$1b,$10,$1b,$10
+
+!align 255,0
+
+bitmapbits:
+ !for n, 0, 31 {
+ !byte %10000000
+ !byte %01000000
+ !byte %00100000
+ !byte %00010000
+ !byte %00001000
+ !byte %00000100
+ !byte %00000010
+ !byte %00000001
+ }
+
+!align 255,0
+
+bitmaphi:
+ !for n, 0, 199 {
+ !byte >(bitmap+32+(((n / 8) * 320) + (n & 7)))
+ }
+
+!align 255,0
+
+bitmaplo:
+ !for n, 0, 199 {
+ !byte <(bitmap+32+(((n / 8) * 320) + (n & 7)))
+ }
+
+!align 255,0
+add8:
+ !for n, 0, 151 {
+ !byte <(n+8)
+ }
+ !for n, 152, 255 {
+ !byte 0
+ }
Added: testprogs/SID/paddlescope/plotter.prg
===================================================================
(Binary files differ)
Index: testprogs/SID/paddlescope/plotter.prg
===================================================================
--- testprogs/SID/paddlescope/plotter.prg 2025-08-03 20:10:04 UTC (rev 45724)
+++ testprogs/SID/paddlescope/plotter.prg 2025-08-06 18:10:13 UTC (rev 45725)
Property changes on: testprogs/SID/paddlescope/plotter.prg
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/x-commodore-exec
\ No newline at end of property
Added: testprogs/SID/paddlescope/readme.txt
===================================================================
--- testprogs/SID/paddlescope/readme.txt (rev 0)
+++ testprogs/SID/paddlescope/readme.txt 2025-08-06 18:10:13 UTC (rev 45725)
@@ -0,0 +1,26 @@
+
+This program continuously samples the POT value from port 1 ($d419) and shows
+a scatter plot of the values.
+
+
+- Each Square is 8 pixel wide, ie 8 values
+
+- The blue area marks the full range, ie values 0-255
+
+- The green area (approximately) marks the range used by the 1351 mouse
+
+
+Observations:
+
+- When a paddle is connected, the value jitters gradually more with higher
+ values. Very low values have almost no jitter, very high values jitter around
+ 6 values or so.
+
+- When a mouse is connected, the value is very precise over the full range,
+ only the LSB jitters.
+
+- With both regular paddles and the 1351 mouse, occasional semi-random (usually
+ much too large) values can be observed. This happens, because the program
+ does _not_ disable interrupts, and the keyboard scanner uses $dc00, which will
+ select the other joystick port for a short time, and mess up the sampling.
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gp...@us...> - 2025-08-03 20:10:06
|
Revision: 45724
http://sourceforge.net/p/vice-emu/code/45724
Author: gpz
Date: 2025-08-03 20:10:04 +0000 (Sun, 03 Aug 2025)
Log Message:
-----------
fix access of open bus when minimon is active, partial fix for #2152
Modified Paths:
--------------
trunk/vice/src/vic20/cart/minimon.c
trunk/vice/src/vic20/cart/vic20cartmem.c
Modified: trunk/vice/src/vic20/cart/minimon.c
===================================================================
--- trunk/vice/src/vic20/cart/minimon.c 2025-08-02 14:54:31 UTC (rev 45723)
+++ trunk/vice/src/vic20/cart/minimon.c 2025-08-03 20:10:04 UTC (rev 45724)
@@ -317,27 +317,37 @@
static uint8_t minimon_io2_read(uint16_t addr)
{
+ if (minimon_bios_type == CARTRIDGE_FILETYPE_NONE) {
+ return (0x9800 + (addr & 0x3ff)) >> 8; /* open bus */
+ }
return minimon_rom[0x000 + (addr & 0x3ff)];
}
static uint8_t minimon_io3_read(uint16_t addr)
{
+ if (minimon_bios_type == CARTRIDGE_FILETYPE_NONE) {
+ return (0x9a00 + (addr & 0x3ff)) >> 8; /* open bus */
+ }
return minimon_rom[0x400 + (addr & 0x3ff)];
}
static void minimon_io2_write(uint16_t addr, uint8_t value)
{
- if (minimon_pgm_enabled) {
- minimon_rom[0x000 + (addr & 0x3ff)] = value;
- minimon_bios_changed = 1;
+ if (minimon_bios_type != CARTRIDGE_FILETYPE_NONE) {
+ if (minimon_pgm_enabled) {
+ minimon_rom[0x000 + (addr & 0x3ff)] = value;
+ minimon_bios_changed = 1;
+ }
}
}
static void minimon_io3_write(uint16_t addr, uint8_t value)
{
- if (minimon_pgm_enabled) {
- minimon_rom[0x400 + (addr & 0x3ff)] = value;
- minimon_bios_changed = 1;
+ if (minimon_bios_type != CARTRIDGE_FILETYPE_NONE) {
+ if (minimon_pgm_enabled) {
+ minimon_rom[0x400 + (addr & 0x3ff)] = value;
+ minimon_bios_changed = 1;
+ }
}
}
@@ -467,6 +477,7 @@
}
/* FIXME: load new image */
+ log_warning(LOG_DEFAULT, "FIXME: load minimon image on resource change");
return 0;
}
@@ -800,6 +811,11 @@
{
/* FIXME */
int ret = -1;
+
+ if (minimon_bios_type == CARTRIDGE_FILETYPE_NONE) {
+ log_warning(LOG_DEFAULT, "Flush: no minimon image attached");
+ return 0;
+ }
if (minimon_bios_changed && minimon_bios_write) {
if (minimon_bios_type == CARTRIDGE_FILETYPE_CRT) {
ret = minimon_crt_save(minimon_image_filename);
Modified: trunk/vice/src/vic20/cart/vic20cartmem.c
===================================================================
--- trunk/vice/src/vic20/cart/vic20cartmem.c 2025-08-02 14:54:31 UTC (rev 45723)
+++ trunk/vice/src/vic20/cart/vic20cartmem.c 2025-08-03 20:10:04 UTC (rev 45724)
@@ -392,9 +392,13 @@
/* "Slot 0" */
if (minimon_cart_enabled()) {
+
if ((res = minimon_blk5_read(addr, &value)) == CART_READ_VALID) {
return value;
}
+ /* open bus value, in case no cartridge is attached to pass through */
+ vic20_cpu_last_data = (addr >> 8);
+ printf("cartridge_read_blk5 %02x %04x\n", vic20_cpu_last_data, addr);
}
/* main slot */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gp...@us...> - 2025-08-02 14:54:33
|
Revision: 45723
http://sourceforge.net/p/vice-emu/code/45723
Author: gpz
Date: 2025-08-02 14:54:31 +0000 (Sat, 02 Aug 2025)
Log Message:
-----------
use 16 bits for the cached sample value, should fix #2142
Modified Paths:
--------------
trunk/vice/src/plus4/ted-sound.c
Modified: trunk/vice/src/plus4/ted-sound.c
===================================================================
--- trunk/vice/src/plus4/ted-sound.c 2025-08-01 23:38:39 UTC (rev 45722)
+++ trunk/vice/src/plus4/ted-sound.c 2025-08-02 14:54:31 UTC (rev 45723)
@@ -47,6 +47,10 @@
/* #define DEBUG_TEDSOUND */
#ifdef DEBUG_TEDSOUND
+#pragma GCC diagnostic warning "-O3"
+#pragma GCC diagnostic warning "-Wall"
+#pragma GCC diagnostic warning "-Wextra"
+#pragma GCC diagnostic ignored "-Wunused-parameter"
#define DBG(x) log_printf x
#else
#define DBG(x)
@@ -178,7 +182,7 @@
uint8_t voice0_cached_output;
uint8_t voice1_cached_output;
- uint8_t digital_cached_output;
+ uint16_t digital_cached_output;
uint32_t oscStep;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gp...@us...> - 2025-08-01 23:38:41
|
Revision: 45722
http://sourceforge.net/p/vice-emu/code/45722
Author: gpz
Date: 2025-08-01 23:38:39 +0000 (Fri, 01 Aug 2025)
Log Message:
-----------
convert the DTV userport ps/2 mouse to a regular userport device, and make it work again. extra work is needed to make it generally work for all emulators
Modified Paths:
--------------
trunk/vice/doc/vice.texi
trunk/vice/src/Makefile.am
trunk/vice/src/c64dtv/c64dtv-resources.c
trunk/vice/src/c64dtv/c64dtv.c
trunk/vice/src/c64dtv/c64dtvcia2.c
trunk/vice/src/c64dtv/c64dtvmem.c
trunk/vice/src/joyport/mouse.c
trunk/vice/src/userport/Makefile.am
trunk/vice/src/userport/userport.c
trunk/vice/src/userport/userport.h
Added Paths:
-----------
trunk/vice/src/userport/userport_ps2mouse.c
trunk/vice/src/userport/userport_ps2mouse.h
Removed Paths:
-------------
trunk/vice/src/ps2mouse.c
trunk/vice/src/ps2mouse.h
Modified: trunk/vice/doc/vice.texi
===================================================================
--- trunk/vice/doc/vice.texi 2025-07-31 20:59:11 UTC (rev 45721)
+++ trunk/vice/doc/vice.texi 2025-08-01 23:38:39 UTC (rev 45722)
@@ -8750,6 +8750,9 @@
@item 26
@tab PET Userport diagnostic pin
@tab xpet
+@item 27
+@tab Userport PS/2 Mouse
+@tab x64dtv
@end multitable
@table @code
@@ -14010,15 +14013,13 @@
The C64DTV userport emulation currently supports three devices:
Hummer ADC, userport joystick and PS/2 mouse.
-The joystick that controls either the Hummer ADC or userport joystick
-can be selected using the same parameter or menu option. (Enable "Hummer userport
-adapter" and use the first extra joystick.)
+The Hummer ADC will be always enabled when a "Hummer" model is selected.
While using the Hummer ADC, joystick UP and DOWN are mapped to
the Hummer buttons A and B respectively. LEFT and RIGHT set the ADCs
output to 0 and 255. Centering the joystick results in the ADC value of 128.
-Currently the Hummer ADC and userport joystick are mutually exclusive.
+The Hummer ADC and userport joystick are mutually exclusive.
This means that enabling one disables the other. PS/2 mouse emulation
can be used simultaneously with either Hummer ADC or userport joystick.
@@ -14030,12 +14031,6 @@
Enable/Disable Hummer ADC
(@code{HummerADC=1}, @code{HummerADC=0}).
-@findex -ps2mouse, +ps2mouse
-@item -ps2mouse
-@itemx +ps2mouse
-Enable/disable PS/2 mouse on userport
-(@code{ps2mouse=1}, @code{ps2mouse=0}).
-
@end table
@@ -14144,10 +14139,6 @@
@item HummerADC
Boolean to enable/disable the Hummer ADC emulation.
-@vindex ps2mouse
-@item ps2mouse
-Boolean to enable/disable PS/2 Mouse emulation.
-
@vindex DtvBlitterLog
@item DtvBlitterLog
Boolean, enables Blitter logging.
Modified: trunk/vice/src/Makefile.am
===================================================================
--- trunk/vice/src/Makefile.am 2025-07-31 20:59:11 UTC (rev 45721)
+++ trunk/vice/src/Makefile.am 2025-08-01 23:38:39 UTC (rev 45722)
@@ -241,7 +241,6 @@
plus4ui.h \
profiler.h \
profiler_data.h \
- ps2mouse.h \
r65c02.h \
ram.h \
rawfile.h \
@@ -345,10 +344,6 @@
zfile.c \
zipcode.c
-
-ps2mouse_sources = \
- ps2mouse.c
-
midi_sources = \
midi.c
@@ -854,7 +849,7 @@
$(hotkeys_lib) \
$(zmbv_lib)
-x64dtv_SOURCES = $(base_sources) $(ps2mouse_sources)
+x64dtv_SOURCES = $(base_sources)
x64dtv_LDADD = $(x64dtv_libs) $(emu_extlibs) @TFE_LIBS@ @NETPLAY_LIBS@ $(X64DTV_RES)
x64dtv_DEPENDENCIES = $(x64dtv_libs)
if HAVE_DEBUG
Modified: trunk/vice/src/c64dtv/c64dtv-resources.c
===================================================================
--- trunk/vice/src/c64dtv/c64dtv-resources.c 2025-07-31 20:59:11 UTC (rev 45721)
+++ trunk/vice/src/c64dtv/c64dtv-resources.c 2025-08-01 23:38:39 UTC (rev 45722)
@@ -34,7 +34,7 @@
#include "c64rom.h"
#include "cartridge.h"
#include "hummeradc.h"
-#include "ps2mouse.h"
+#include "userport_ps2mouse.h"
#include "kbd.h"
#include "keyboard.h"
#include "lib.h"
Modified: trunk/vice/src/c64dtv/c64dtv.c
===================================================================
--- trunk/vice/src/c64dtv/c64dtv.c 2025-07-31 20:59:11 UTC (rev 45721)
+++ trunk/vice/src/c64dtv/c64dtv.c 2025-08-01 23:38:39 UTC (rev 45722)
@@ -88,7 +88,7 @@
#include "parallel.h"
#include "printer.h"
#include "protopad.h"
-#include "ps2mouse.h"
+#include "userport_ps2mouse.h"
#include "resources.h"
#include "rushware_keypad.h"
#include "sampler.h"
Modified: trunk/vice/src/c64dtv/c64dtvcia2.c
===================================================================
--- trunk/vice/src/c64dtv/c64dtvcia2.c 2025-07-31 20:59:11 UTC (rev 45721)
+++ trunk/vice/src/c64dtv/c64dtvcia2.c 2025-08-01 23:38:39 UTC (rev 45722)
@@ -48,7 +48,7 @@
#include "lib.h"
#include "log.h"
#include "maincpu.h"
-#include "ps2mouse.h"
+#include "userport_ps2mouse.h"
#include "types.h"
#include "userport.h"
#include "vicii.h"
@@ -56,18 +56,11 @@
void cia2_store(uint16_t addr, uint8_t data)
{
if ((addr & 0x1f) == 1) {
- /* HACK: for now only call the userport system when ps/2 mouse is disabled */
- if (!ps2mouse_enabled) {
- store_userport_pbx(data, USERPORT_NO_PULSE);
- }
+ store_userport_pbx(data, USERPORT_NO_PULSE);
if (c64dtv_hummer_adc_enabled) {
hummeradc_store(data);
}
- /* FIXME: convert ps/2 mouse support to new userport system */
- if (ps2mouse_enabled) {
- ps2mouse_store(data);
- }
}
ciacore_store(machine_context.cia2, addr, data);
@@ -78,15 +71,8 @@
uint8_t retval = 0xff;
if ((addr & 0x1f) == 1) {
- /* HACK: for now only call the userport system when ps/2 mouse is disabled */
- if (!ps2mouse_enabled) {
- retval = read_userport_pbx(retval);
- }
+ retval = read_userport_pbx(retval);
- /* FIXME: convert ps/2 mouse support to new userport system */
- if (ps2mouse_enabled) {
- retval &= (ps2mouse_read() | 0x3f);
- }
if (c64dtv_hummer_adc_enabled) {
retval &= (hummeradc_read() | 0xf8);
}
Modified: trunk/vice/src/c64dtv/c64dtvmem.c
===================================================================
--- trunk/vice/src/c64dtv/c64dtvmem.c 2025-07-31 20:59:11 UTC (rev 45721)
+++ trunk/vice/src/c64dtv/c64dtvmem.c 2025-08-01 23:38:39 UTC (rev 45722)
@@ -49,7 +49,7 @@
#include "interrupt.h"
#include "alarm.h"
#include "hummeradc.h"
-#include "ps2mouse.h"
+#include "userport_ps2mouse.h"
/* TODO this is a hack */
#define C64_RAM_SIZE 0x200000
Modified: trunk/vice/src/joyport/mouse.c
===================================================================
--- trunk/vice/src/joyport/mouse.c 2025-07-31 20:59:11 UTC (rev 45721)
+++ trunk/vice/src/joyport/mouse.c 2025-08-01 23:38:39 UTC (rev 45722)
@@ -51,6 +51,7 @@
#include "archdep.h"
#include "cmdline.h"
#include "joyport.h"
+#include "log.h"
#include "machine.h"
#include "maincpu.h"
#include "mouse.h"
@@ -145,6 +146,7 @@
{
*x = (int16_t)mouse_x;
*y = (int16_t)mouse_y;
+ DBG(("mouse_get_raw_int16 %d, %d", *x, *y));
}
void mouse_get_last_int16(int16_t *x, int16_t *y)
Deleted: trunk/vice/src/ps2mouse.c
===================================================================
--- trunk/vice/src/ps2mouse.c 2025-07-31 20:59:11 UTC (rev 45721)
+++ trunk/vice/src/ps2mouse.c 2025-08-01 23:38:39 UTC (rev 45722)
@@ -1,554 +0,0 @@
-/*
- * ps2mouse.c -- PS/2 mouse on userport emulation
- *
- * Written by
- * Hannu Nuotio <han...@tu...>
- * Based on code by
- * Andreas Boose <vic...@t-...>
- *
- * This file is part of VICE, the Versatile Commodore Emulator.
- * See README for copyright notice.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- * 02111-1307 USA.
- *
- */
-
-#include "vice.h"
-
-#include "cmdline.h"
-#include "resources.h"
-#include "log.h"
-#include "ps2mouse.h"
-#include "alarm.h"
-#include "maincpu.h"
-#include "mousedrv.h"
-
-static void mouse_button_left(int pressed);
-static void mouse_button_right(int pressed);
-static void mouse_button_middle(int pressed);
-static void mouse_button_up(int pressed);
-static void mouse_button_down(int pressed);
-
-static log_t ps2mouse_log = LOG_DEFAULT;
-
-#if 0
-#define PS2MOUSE_DEBUG(args ...) log_message(ps2mouse_log, args)
-#define PS2MOUSE_DEBUG_ENABLED
-#endif
-
-/* PS/2 mouse port bits */
-#define PS2_CLK_BIT 0x40
-#define PS2_DATA_BIT 0x80
-
-/* PS/2 mouse timing */
-#define PS2_BIT_DELAY_CLK 75
-
-/* PS/2 mouse commands & replies (TODO: support more commands) */
-#define PS2_REPLY_OK 0xfa
-#define PS2_REPLY_ERROR 0xfc
-#define PS2_CMD_SET_REMOTE_MODE 0xf0
-#define PS2_CMD_READ_DATA 0xeb
-#define PS2_CMD_GET_DEV_ID 0xf2
-#define PS2_REPLY_DEV_ID 0x00
-
-/* PS/2 mouse movement packet bits */
-#define PS2_MDATA_YO 0x80
-#define PS2_MDATA_XO 0x40
-#define PS2_MDATA_YS 0x20
-#define PS2_MDATA_XS 0x10
-#define PS2_MDATA_A1 0x08
-#define PS2_MDATA_MB 0x04
-#define PS2_MDATA_RB 0x02
-#define PS2_MDATA_LB 0x01
-
-/* PS/2 mouse variables */
-static uint8_t ps2mouse_value;
-static uint8_t ps2mouse_in;
-static uint8_t ps2mouse_out;
-static uint8_t ps2mouse_prev;
-static uint8_t ps2mouse_parity;
-static int16_t ps2mouse_lastx;
-static int16_t ps2mouse_lasty;
-static uint8_t ps2mouse_buttons;
-
-/* PS/2 transmission state */
-enum {
- PS2_FROMTO_IDLE=0,
- PS2_FROM_START, /* mouse <- cpu */
- PS2_FROM_D0,
- PS2_FROM_D1,
- PS2_FROM_D2,
- PS2_FROM_D3,
- PS2_FROM_D4,
- PS2_FROM_D5,
- PS2_FROM_D6,
- PS2_FROM_D7,
- PS2_FROM_PARITY,
- PS2_FROM_STOP,
- PS2_FROM_ACK,
- PS2_CHECK_SEND, /* mouse -> cpu */
- PS2_TO_D0,
- PS2_TO_D1,
- PS2_TO_D2,
- PS2_TO_D3,
- PS2_TO_D4,
- PS2_TO_D5,
- PS2_TO_D6,
- PS2_TO_D7,
- PS2_TO_PARITY,
- PS2_TO_STOP
-} ps2mouse_xmit_state = PS2_FROMTO_IDLE;
-
-/* Output buffer */
-#define PS2_QUEUE_SIZE 8
-uint8_t ps2mouse_queue[PS2_QUEUE_SIZE];
-uint8_t ps2mouse_queue_head;
-uint8_t ps2mouse_queue_tail;
-
-static int ps2mouse_queue_put(uint8_t value)
-{
- uint8_t new_head = (ps2mouse_queue_head + 1) & (PS2_QUEUE_SIZE - 1);
- if (new_head == ps2mouse_queue_tail) {
-#ifdef PS2MOUSE_DEBUG_ENABLED
- PS2MOUSE_DEBUG("queue full!");
-#endif
- return 0;
- }
- ps2mouse_queue[ps2mouse_queue_head] = value;
- ps2mouse_queue_head = new_head;
- return 1;
-}
-
-static int ps2mouse_queue_empty(void)
-{
- return (ps2mouse_queue_head == ps2mouse_queue_tail);
-}
-
-static uint8_t ps2mouse_queue_get(void)
-{
- uint8_t retval = ps2mouse_queue[ps2mouse_queue_tail];
- ++ps2mouse_queue_tail;
- ps2mouse_queue_tail &= (PS2_QUEUE_SIZE - 1);
- return retval;
-}
-
-/* ------------------------------------------------------------------------- */
-
-
-static int ps2mouse_handle_command(uint8_t value)
-{
- int16_t diff_x, diff_y, new_x, new_y;
- uint8_t new_buttons;
-#ifdef PS2MOUSE_DEBUG_ENABLED
- PS2MOUSE_DEBUG("cmd: got %02x", value);
-#endif
- ps2mouse_xmit_state = PS2_CHECK_SEND;
-
- if (ps2mouse_parity) {
-#ifdef PS2MOUSE_DEBUG_ENABLED
- PS2MOUSE_DEBUG("parity error");
-#endif
- return ps2mouse_queue_put(PS2_REPLY_ERROR);
- }
-
- switch (value) {
- case PS2_CMD_GET_DEV_ID:
- return (ps2mouse_queue_put(PS2_REPLY_OK)
- && ps2mouse_queue_put(PS2_REPLY_DEV_ID));
- break;
-
- case PS2_CMD_SET_REMOTE_MODE:
-#ifdef HAVE_MOUSE
- mouse_get_raw_int16(&ps2mouse_lastx, &ps2mouse_lasty);
-#endif
- return (ps2mouse_queue_put(PS2_REPLY_OK));
- break;
-
- case PS2_CMD_READ_DATA:
- new_buttons = ps2mouse_buttons;
-#ifdef HAVE_MOUSE
- mouse_get_raw_int16(&new_x, &new_y);
- diff_x = (new_x - ps2mouse_lastx);
- if (diff_x < 0) {
- new_buttons |= PS2_MDATA_XS;
- }
- if (diff_x < -256 || diff_x > 255) {
- new_buttons |= PS2_MDATA_XO;
- }
- ps2mouse_lastx = new_x;
-
- diff_y = (int16_t)(new_y - ps2mouse_lasty);
- if (diff_y < 0) {
- new_buttons |= PS2_MDATA_YS;
- }
- if (diff_y < -256 || diff_y > 255) {
- new_buttons |= PS2_MDATA_YO;
- }
- ps2mouse_lasty = new_y;
-#else
- diff_x = 0;
- diff_y = 0;
-#endif
-#ifdef PS2MOUSE_DEBUG_ENABLED
- PS2MOUSE_DEBUG("x/y/b: %02x, %02x, %02x", diff_x, diff_y, new_buttons);
-#endif
- return (ps2mouse_queue_put(PS2_REPLY_OK)
- && ps2mouse_queue_put(new_buttons)
- && ps2mouse_queue_put((uint8_t)diff_x)
- && ps2mouse_queue_put((uint8_t)diff_y));
- break;
-
- default:
-#ifdef PS2MOUSE_DEBUG_ENABLED
- PS2MOUSE_DEBUG("unsupported command %02x", value);
-#endif
- return (ps2mouse_queue_put(PS2_REPLY_ERROR) & 0);
- break;
- }
- return 0;
-}
-
-
-struct alarm_s *c64dtv_ps2mouse_alarm;
-
-static void c64dtv_ps2mouse_alarm_handler(CLOCK offset, void *data)
-{
- int another_alarm = 1;
-
- alarm_unset(c64dtv_ps2mouse_alarm);
-
- ps2mouse_out ^= PS2_CLK_BIT;
- ps2mouse_out &= ~PS2_DATA_BIT;
-
- switch (ps2mouse_xmit_state) {
- case PS2_FROM_START:
- ps2mouse_value = 0;
- ps2mouse_parity = 0;
- ps2mouse_out |= (ps2mouse_in & PS2_DATA_BIT);
-#ifdef PS2MOUSE_DEBUG_ENABLED
- PS2MOUSE_DEBUG("start: clk/data = %i/%i", (ps2mouse_out >> 6) & 1, (ps2mouse_out >> 7) & 1);
-#endif
- if ((ps2mouse_out & PS2_CLK_BIT) == 0) {
- ++ps2mouse_xmit_state;
- }
- break;
-
- case PS2_FROM_D0:
- case PS2_FROM_D1:
- case PS2_FROM_D2:
- case PS2_FROM_D3:
- case PS2_FROM_D4:
- case PS2_FROM_D5:
- case PS2_FROM_D6:
- case PS2_FROM_D7:
- if (ps2mouse_out & PS2_CLK_BIT) {
- ps2mouse_value >>= 1;
- if (ps2mouse_in & PS2_DATA_BIT) {
- ps2mouse_value |= 0x80;
- ps2mouse_parity ^= PS2_DATA_BIT;
- }
- }
- ps2mouse_out |= (ps2mouse_in & PS2_DATA_BIT);
-#ifdef PS2MOUSE_DEBUG_ENABLED
- PS2MOUSE_DEBUG("d%i: clk/data = %i/%i", ps2mouse_xmit_state - PS2_FROM_D0, (ps2mouse_out >> 6) & 1, (ps2mouse_out >> 7) & 1);
-#endif
- if ((ps2mouse_out & PS2_CLK_BIT) == 0) {
- ++ps2mouse_xmit_state;
- }
- break;
-
- case PS2_FROM_PARITY:
- if (ps2mouse_out & PS2_CLK_BIT) {
- if (ps2mouse_in & PS2_DATA_BIT) {
- ps2mouse_parity ^= PS2_DATA_BIT;
- }
- }
- ps2mouse_out |= PS2_DATA_BIT;
-#ifdef PS2MOUSE_DEBUG_ENABLED
- PS2MOUSE_DEBUG("parity: clk/data = %i/%i", (ps2mouse_out >> 6) & 1, (ps2mouse_out >> 7) & 1);
-#endif
- if ((ps2mouse_out & PS2_CLK_BIT) == 0) {
- ++ps2mouse_xmit_state;
- }
- break;
-
- case PS2_FROM_STOP:
- if (ps2mouse_out & PS2_CLK_BIT) {
- if (ps2mouse_in & PS2_DATA_BIT) {
- ps2mouse_parity ^= PS2_DATA_BIT;
- }
- ps2mouse_out |= PS2_DATA_BIT;
- } else {
- ps2mouse_out |= ps2mouse_parity;
- }
-#ifdef PS2MOUSE_DEBUG_ENABLED
- PS2MOUSE_DEBUG("stop: clk/data = %i/%i", (ps2mouse_out >> 6) & 1, (ps2mouse_out >> 7) & 1);
-#endif
- if ((ps2mouse_out & PS2_CLK_BIT) == 0) {
- ++ps2mouse_xmit_state;
- }
- break;
-
- case PS2_FROM_ACK:
- ps2mouse_out |= PS2_DATA_BIT; /* ps2mouse_parity; */
-#ifdef PS2MOUSE_DEBUG_ENABLED
- PS2MOUSE_DEBUG("got %02x, parity: %02x, clk/data = %i/%i", ps2mouse_value, ps2mouse_parity, (ps2mouse_out >> 6) & 1, (ps2mouse_out >> 7) & 1);
-#endif
- another_alarm = ps2mouse_handle_command(ps2mouse_value);
- break;
-
- case PS2_CHECK_SEND:
- if (ps2mouse_queue_empty()) {
- ps2mouse_out |= (PS2_DATA_BIT | PS2_CLK_BIT);
- another_alarm = 0;
- ps2mouse_xmit_state = PS2_FROMTO_IDLE;
-#ifdef PS2MOUSE_DEBUG_ENABLED
- PS2MOUSE_DEBUG("all sent. clk/data = %i/%i", (ps2mouse_out >> 6) & 1, (ps2mouse_out >> 7) & 1);
-#endif
- break;
- }
- if ((ps2mouse_in & PS2_CLK_BIT) == 0) {
- ps2mouse_out &= ~PS2_CLK_BIT;
-#ifdef PS2MOUSE_DEBUG_ENABLED
- PS2MOUSE_DEBUG("hold! clk/data = %i/%i", (ps2mouse_out >> 6) & 1, (ps2mouse_out >> 7) & 1);
-#endif
- break;
- }
-
- if ((ps2mouse_out & PS2_CLK_BIT) == 0) {
- ps2mouse_parity = PS2_DATA_BIT;
- ps2mouse_value = ps2mouse_queue_get();
-#ifdef PS2MOUSE_DEBUG_ENABLED
- PS2MOUSE_DEBUG("sending %02x, clk/data = %i/%i", ps2mouse_value, (ps2mouse_out >> 6) & 1, (ps2mouse_out >> 7) & 1);
-#endif
- ps2mouse_xmit_state = PS2_TO_D0;
- }
- break;
-
- case PS2_TO_D0:
- case PS2_TO_D1:
- case PS2_TO_D2:
- case PS2_TO_D3:
- case PS2_TO_D4:
- case PS2_TO_D5:
- case PS2_TO_D6:
- case PS2_TO_D7:
- if (ps2mouse_out & PS2_CLK_BIT) {
- ps2mouse_out |= (ps2mouse_value & 1) ? PS2_DATA_BIT : 0;
- ps2mouse_prev = ps2mouse_out;
- ps2mouse_parity ^= (ps2mouse_value & 1) ? PS2_DATA_BIT : 0;
- ps2mouse_value >>= 1;
- } else {
- ps2mouse_out |= (ps2mouse_prev & PS2_DATA_BIT);
- }
-#ifdef PS2MOUSE_DEBUG_ENABLED
- PS2MOUSE_DEBUG("to_d%i: clk/data = %i/%i", ps2mouse_xmit_state - PS2_TO_D0, (ps2mouse_out >> 6) & 1, (ps2mouse_out >> 7) & 1);
-#endif
- if ((ps2mouse_out & PS2_CLK_BIT) == 0) {
- ++ps2mouse_xmit_state;
- }
- break;
-
- case PS2_TO_PARITY:
- if (ps2mouse_out & PS2_CLK_BIT) {
- ps2mouse_out |= ps2mouse_parity;
- ps2mouse_prev = ps2mouse_out;
- } else {
- ps2mouse_out |= (ps2mouse_prev & PS2_DATA_BIT);
- }
-#ifdef PS2MOUSE_DEBUG_ENABLED
- PS2MOUSE_DEBUG("to_parity: clk/data = %i/%i", (ps2mouse_out >> 6) & 1, (ps2mouse_out >> 7) & 1);
-#endif
- if ((ps2mouse_out & PS2_CLK_BIT) == 0) {
- ++ps2mouse_xmit_state;
- }
- break;
-
- case PS2_TO_STOP:
- ps2mouse_out |= PS2_DATA_BIT;
-#ifdef PS2MOUSE_DEBUG_ENABLED
- PS2MOUSE_DEBUG("stop: clk/data = %i/%i", (ps2mouse_out >> 6) & 1, (ps2mouse_out >> 7) & 1);
-#endif
- if ((ps2mouse_out & PS2_CLK_BIT) == 0) {
- ps2mouse_xmit_state = PS2_CHECK_SEND;
- }
- break;
-
- default:
- ps2mouse_out |= (PS2_DATA_BIT | PS2_CLK_BIT);
- another_alarm = 0;
- ps2mouse_xmit_state = PS2_FROMTO_IDLE;
-#ifdef PS2MOUSE_DEBUG_ENABLED
- PS2MOUSE_DEBUG("bug! state %i. clk/data = %i/%i", ps2mouse_xmit_state, (ps2mouse_out >> 6) & 1, (ps2mouse_out >> 7) & 1);
-#endif
- break;
- }
-
- if (another_alarm) {
- alarm_set(c64dtv_ps2mouse_alarm, maincpu_clk + PS2_BIT_DELAY_CLK);
- }
-}
-
-
-void ps2mouse_store(uint8_t value)
-{
- ps2mouse_in = value;
- if (((ps2mouse_prev & PS2_CLK_BIT) == 0) && (value & PS2_CLK_BIT)
- && (ps2mouse_xmit_state == PS2_FROMTO_IDLE) && ((value & PS2_DATA_BIT) == 0)) {
- ps2mouse_xmit_state = PS2_FROM_START;
- ps2mouse_out = value;
- alarm_set(c64dtv_ps2mouse_alarm, maincpu_clk + PS2_BIT_DELAY_CLK);
- }
- ps2mouse_prev = value;
- return;
-}
-
-uint8_t ps2mouse_read(void)
-{
- return ps2mouse_out;
-}
-
-/* ------------------------------------------------------------------------- */
-
-
-static void c64dtv_ps2mouse_alarm_init(void)
-{
- c64dtv_ps2mouse_alarm = alarm_new(maincpu_alarm_context, "PS2MOUSEAlarm",
- c64dtv_ps2mouse_alarm_handler, NULL);
-}
-
-void ps2mouse_reset(void)
-{
- ps2mouse_in = 0xff;
- ps2mouse_out = 0xff;
- ps2mouse_prev = 0xff;
- ps2mouse_xmit_state = PS2_FROMTO_IDLE;
- ps2mouse_parity = 0;
- ps2mouse_lastx = 0;
- ps2mouse_lasty = 0;
- ps2mouse_buttons = PS2_MDATA_A1;
- ps2mouse_queue_head = 0;
- ps2mouse_queue_tail = 0;
- return;
-}
-
-/* ------------------------------------------------------------------------- */
-
-int ps2mouse_enabled = 0;
-
-static int set_ps2mouse_enable(int val, void *param)
-{
- ps2mouse_enabled = (unsigned int)(val ? 1 : 0);
-
- return 0;
-}
-
-static const resource_int_t resources_int[] = {
- { "ps2mouse", 0, RES_EVENT_SAME, NULL,
- &ps2mouse_enabled, set_ps2mouse_enable, NULL },
- RESOURCE_INT_LIST_END
-};
-
-static const cmdline_option_t cmdline_options[] =
-{
- { "-ps2mouse", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
- NULL, NULL, "PS2Mouse", (void *)1,
- NULL, "Enable PS/2 mouse on userport" },
- { "+ps2mouse", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
- NULL, NULL, "PS2Mouse", (void *)0,
- NULL, "Disable PS/2 mouse on userport" },
- CMDLINE_LIST_END
-};
-
-/* ------------------------------------------------------------------------- */
-
-static const mouse_func_t mouse_funcs =
-{
- mouse_button_left,
- mouse_button_right,
- mouse_button_middle,
- mouse_button_up,
- mouse_button_down
-};
-
-int mouse_ps2_resources_init(void)
-{
- if (resources_register_int(resources_int) < 0) {
- return -1;
- }
-
- return mousedrv_resources_init(&mouse_funcs);
-}
-
-int mouse_ps2_cmdline_options_init(void)
-{
- if (cmdline_register_options(cmdline_options) < 0) {
- return -1;
- }
-
- return mousedrv_cmdline_options_init();
-}
-
-void mouse_ps2_init(void)
-{
- if (ps2mouse_log == LOG_DEFAULT) {
- ps2mouse_log = log_open("ps2mouse");
- }
-
- c64dtv_ps2mouse_alarm_init();
-
- ps2mouse_reset();
- mousedrv_init();
-}
-
-void mouse_ps2_shutdown(void)
-{
-}
-
-static void mouse_button_left(int pressed)
-{
- if (pressed) {
- ps2mouse_buttons |= PS2_MDATA_LB;
- } else {
- ps2mouse_buttons &= ~PS2_MDATA_LB;
- }
-}
-
-static void mouse_button_middle(int pressed)
-{
- if (pressed) {
- ps2mouse_buttons |= PS2_MDATA_MB;
- } else {
- ps2mouse_buttons &= ~PS2_MDATA_MB;
- }
-}
-
-static void mouse_button_right(int pressed)
-{
- if (pressed) {
- ps2mouse_buttons |= PS2_MDATA_RB;
- } else {
- ps2mouse_buttons &= ~PS2_MDATA_RB;
- }
-}
-
-static void mouse_button_up(int pressed)
-{
-}
-
-static void mouse_button_down(int pressed)
-{
-}
Deleted: trunk/vice/src/ps2mouse.h
===================================================================
--- trunk/vice/src/ps2mouse.h 2025-07-31 20:59:11 UTC (rev 45721)
+++ trunk/vice/src/ps2mouse.h 2025-08-01 23:38:39 UTC (rev 45722)
@@ -1,51 +0,0 @@
-/*
- * ps2mouse.h - PS/2 mouse on userport emulation
- *
- * Written by
- * Hannu Nuotio <han...@tu...>
- * Based on code by
- * Andreas Boose <vic...@t-...>
- *
- * This file is part of VICE, the Versatile Commodore Emulator.
- * See README for copyright notice.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- * 02111-1307 USA.
- *
- */
-
-#ifndef VICE_PS2MOUSE_H
-#define VICE_PS2MOUSE_H
-
-#include "types.h"
-
-void ps2mouse_reset(void);
-
-uint8_t ps2mouse_read(void);
-void ps2mouse_store(uint8_t value);
-
-int ps2mouse_resources_init(void);
-int ps2mouse_cmdline_options_init(void);
-
-extern int ps2mouse_enabled;
-
-int mouse_ps2_resources_init(void);
-int mouse_ps2_cmdline_options_init(void);
-void mouse_ps2_init(void);
-void mouse_ps2_shutdown(void);
-
-extern int _mouse_enabled;
-
-#endif
Modified: trunk/vice/src/userport/Makefile.am
===================================================================
--- trunk/vice/src/userport/Makefile.am 2025-07-31 20:59:11 UTC (rev 45721)
+++ trunk/vice/src/userport/Makefile.am 2025-08-01 23:38:39 UTC (rev 45722)
@@ -49,6 +49,8 @@
userport_joystick.h \
userport_petscii_snespad.c \
userport_petscii_snespad.h \
+ userport_ps2mouse.c \
+ userport_ps2mouse.h \
userport_rtc_58321a.c \
userport_rtc_58321a.h \
userport_rtc_ds1307.c \
Modified: trunk/vice/src/userport/userport.c
===================================================================
--- trunk/vice/src/userport/userport.c 2025-07-31 20:59:11 UTC (rev 45721)
+++ trunk/vice/src/userport/userport.c 2025-08-01 23:38:39 UTC (rev 45722)
@@ -145,6 +145,7 @@
#include "userport_hummer_joystick.h"
#include "userport_io_sim.h"
#include "userport_petscii_snespad.h"
+#include "userport_ps2mouse.h"
#include "userport_rtc_58321a.h"
#include "userport_rtc_ds1307.h"
#include "userport_spt_joystick.h"
@@ -184,6 +185,7 @@
#ifdef USERPORT_EXPERIMENTAL_DEVICES
{ USERPORT_DEVICE_TYPE_HARNESS, "Diagnostic harness" },
#endif
+ { USERPORT_DEVICE_TYPE_MOUSE_ADAPTER, "Mouse adapter" },
{ -1, NULL }
};
@@ -778,6 +780,13 @@
userport_diag_pin_cmdline_options_init /* cmdline options init function */
},
+ { USERPORT_DEVICE_MOUSE_PS2, /* device id */
+ UP_DTV, /* emulators this device works on */
+ userport_ps2mouse_resources_init, /* resources init function */
+ NULL, /* resources shutdown function */
+ NULL /* cmdline options init function */
+ },
+
{ USERPORT_DEVICE_NONE, VICE_MACHINE_NONE, NULL, NULL, NULL }, /* end of the devices list */
};
Modified: trunk/vice/src/userport/userport.h
===================================================================
--- trunk/vice/src/userport/userport.h 2025-07-31 20:59:11 UTC (rev 45721)
+++ trunk/vice/src/userport/userport.h 2025-08-01 23:38:39 UTC (rev 45722)
@@ -70,6 +70,7 @@
USERPORT_DEVICE_SPACEBALLS, /* CAUTION: also connects to the controller port(s) */
USERPORT_DEVICE_SPT_JOYSTICK,
USERPORT_DEVICE_DIAGNOSTIC_PIN,
+ USERPORT_DEVICE_MOUSE_PS2,
/* This item always needs to be at the end */
USERPORT_MAX_DEVICES
@@ -91,7 +92,8 @@
USERPORT_DEVICE_TYPE_WIFI,
#endif
USERPORT_DEVICE_TYPE_IO_SIMULATION,
- USERPORT_DEVICE_TYPE_DIAGNOSTIC
+ USERPORT_DEVICE_TYPE_DIAGNOSTIC,
+ USERPORT_DEVICE_TYPE_MOUSE_ADAPTER,
};
/* 24 pin userport pin defines */
Copied: trunk/vice/src/userport/userport_ps2mouse.c (from rev 45721, trunk/vice/src/ps2mouse.c)
===================================================================
--- trunk/vice/src/userport/userport_ps2mouse.c (rev 0)
+++ trunk/vice/src/userport/userport_ps2mouse.c 2025-08-01 23:38:39 UTC (rev 45722)
@@ -0,0 +1,588 @@
+/*
+ * ps2mouse.c -- PS/2 mouse on userport emulation
+ *
+ * Written by
+ * Hannu Nuotio <han...@tu...>
+ * Based on code by
+ * Andreas Boose <vic...@t-...>
+ *
+ * This file is part of VICE, the Versatile Commodore Emulator.
+ * See README for copyright notice.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ *
+ */
+
+#include "vice.h"
+
+#include "cmdline.h"
+#include "resources.h"
+#include "log.h"
+#include "joyport.h"
+#include "userport.h"
+#include "userport_ps2mouse.h"
+#include "alarm.h"
+#include "maincpu.h"
+#include "mousedrv.h"
+
+static void mouse_button_left(int pressed);
+static void mouse_button_right(int pressed);
+static void mouse_button_middle(int pressed);
+static void mouse_button_up(int pressed);
+static void mouse_button_down(int pressed);
+
+static log_t ps2mouse_log = LOG_DEFAULT;
+
+#if 0
+#define PS2MOUSE_DEBUG(args ...) log_message(ps2mouse_log, args)
+#define PS2MOUSE_DEBUG_ENABLED
+#endif
+
+/* PS/2 mouse port bits */
+#define PS2_CLK_BIT 0x40
+#define PS2_DATA_BIT 0x80
+
+/* PS/2 mouse timing */
+#define PS2_BIT_DELAY_CLK 75
+
+/* PS/2 mouse commands & replies (TODO: support more commands) */
+#define PS2_REPLY_OK 0xfa
+#define PS2_REPLY_ERROR 0xfc
+#define PS2_CMD_SET_REMOTE_MODE 0xf0
+#define PS2_CMD_READ_DATA 0xeb
+#define PS2_CMD_GET_DEV_ID 0xf2
+#define PS2_REPLY_DEV_ID 0x00
+
+/* PS/2 mouse movement packet bits */
+#define PS2_MDATA_YO 0x80
+#define PS2_MDATA_XO 0x40
+#define PS2_MDATA_YS 0x20
+#define PS2_MDATA_XS 0x10
+#define PS2_MDATA_A1 0x08
+#define PS2_MDATA_MB 0x04
+#define PS2_MDATA_RB 0x02
+#define PS2_MDATA_LB 0x01
+
+/* PS/2 mouse variables */
+static uint8_t ps2mouse_value;
+static uint8_t ps2mouse_in;
+static uint8_t ps2mouse_out;
+static uint8_t ps2mouse_prev;
+static uint8_t ps2mouse_parity;
+static int16_t ps2mouse_lastx;
+static int16_t ps2mouse_lasty;
+static uint8_t ps2mouse_buttons;
+
+/* PS/2 transmission state */
+enum {
+ PS2_FROMTO_IDLE=0,
+ PS2_FROM_START, /* mouse <- cpu */
+ PS2_FROM_D0,
+ PS2_FROM_D1,
+ PS2_FROM_D2,
+ PS2_FROM_D3,
+ PS2_FROM_D4,
+ PS2_FROM_D5,
+ PS2_FROM_D6,
+ PS2_FROM_D7,
+ PS2_FROM_PARITY,
+ PS2_FROM_STOP,
+ PS2_FROM_ACK,
+ PS2_CHECK_SEND, /* mouse -> cpu */
+ PS2_TO_D0,
+ PS2_TO_D1,
+ PS2_TO_D2,
+ PS2_TO_D3,
+ PS2_TO_D4,
+ PS2_TO_D5,
+ PS2_TO_D6,
+ PS2_TO_D7,
+ PS2_TO_PARITY,
+ PS2_TO_STOP
+} ps2mouse_xmit_state = PS2_FROMTO_IDLE;
+
+/* Output buffer */
+#define PS2_QUEUE_SIZE 8
+static uint8_t ps2mouse_queue[PS2_QUEUE_SIZE];
+static uint8_t ps2mouse_queue_head;
+static uint8_t ps2mouse_queue_tail;
+
+/* ------------------------------------------------------------------------- */
+
+static uint8_t userport_ps2mouse_read_pbx(uint8_t orig);
+static void userport_ps2mouse_store_pbx(uint8_t value, int pulse);
+static int userport_ps2mouse_enable(int val);
+static int userport_ps2mouse_write_snapshot_module(snapshot_t *s);
+static int userport_ps2mouse_read_snapshot_module(snapshot_t *s);
+
+static userport_device_t ps2mouse_device = {
+ "PS/2 Mouse", /* device name */
+ JOYSTICK_ADAPTER_ID_NONE, /* this is NOT a joystick adapter */
+ USERPORT_DEVICE_TYPE_MOUSE_ADAPTER, /* device is a mouse adapter */
+ userport_ps2mouse_enable, /* enable function */
+ userport_ps2mouse_read_pbx, /* read pb0-pb7 function */
+ userport_ps2mouse_store_pbx, /* store pb0-pb7 function */
+ NULL, /* NO read pa2 pin function */
+ NULL, /* NO store pa2 pin function */
+ NULL, /* NO read pa3 pin function */
+ NULL, /* NO store pa3 pin function */
+ 0, /* pc pin is NOT needed */
+ NULL, /* NO store sp1 pin function */
+ NULL, /* NO read sp1 pin function */
+ NULL, /* NO store sp2 pin function */
+ NULL, /* NO read sp2 pin function */
+ NULL, /* NO reset function */
+ NULL, /* NO powerup function */
+ userport_ps2mouse_write_snapshot_module, /* snapshot write function */
+ userport_ps2mouse_read_snapshot_module /* snapshot read function */
+};
+
+static int ps2mouse_enabled = 0;
+
+static int userport_ps2mouse_enable(int val)
+{
+ ps2mouse_enabled = (unsigned int)(val ? 1 : 0);
+
+ return 0;
+}
+
+int userport_ps2mouse_resources_init(void)
+{
+ return userport_device_register(USERPORT_DEVICE_MOUSE_PS2, &ps2mouse_device);
+}
+
+/* ---------------------------------------------------------------------*/
+
+static int userport_ps2mouse_write_snapshot_module(snapshot_t *s)
+{
+ /* FIXME */
+ return 0;
+}
+
+static int userport_ps2mouse_read_snapshot_module(snapshot_t *s)
+{
+ /* FIXME */
+ return 0;
+}
+
+/* ------------------------------------------------------------------------- */
+
+
+static int ps2mouse_queue_put(uint8_t value)
+{
+ uint8_t new_head = (ps2mouse_queue_head + 1) & (PS2_QUEUE_SIZE - 1);
+ if (new_head == ps2mouse_queue_tail) {
+#ifdef PS2MOUSE_DEBUG_ENABLED
+ PS2MOUSE_DEBUG("queue full!");
+#endif
+ return 0;
+ }
+ ps2mouse_queue[ps2mouse_queue_head] = value;
+ ps2mouse_queue_head = new_head;
+ return 1;
+}
+
+static int ps2mouse_queue_empty(void)
+{
+ return (ps2mouse_queue_head == ps2mouse_queue_tail);
+}
+
+static uint8_t ps2mouse_queue_get(void)
+{
+ uint8_t retval = ps2mouse_queue[ps2mouse_queue_tail];
+ ++ps2mouse_queue_tail;
+ ps2mouse_queue_tail &= (PS2_QUEUE_SIZE - 1);
+ return retval;
+}
+
+/* ------------------------------------------------------------------------- */
+
+
+static int ps2mouse_handle_command(uint8_t value)
+{
+ int16_t diff_x, diff_y, new_x, new_y;
+ uint8_t new_buttons;
+#ifdef PS2MOUSE_DEBUG_ENABLED
+ PS2MOUSE_DEBUG("cmd: got %02x", value);
+#endif
+ ps2mouse_xmit_state = PS2_CHECK_SEND;
+
+ if (ps2mouse_parity) {
+#ifdef PS2MOUSE_DEBUG_ENABLED
+ PS2MOUSE_DEBUG("parity error");
+#endif
+ return ps2mouse_queue_put(PS2_REPLY_ERROR);
+ }
+
+ switch (value) {
+ case PS2_CMD_GET_DEV_ID:
+ return (ps2mouse_queue_put(PS2_REPLY_OK)
+ && ps2mouse_queue_put(PS2_REPLY_DEV_ID));
+ break;
+
+ case PS2_CMD_SET_REMOTE_MODE:
+#ifdef HAVE_MOUSE
+ mouse_poll(); /* HACK: should probably happen elsewhere */
+ mouse_get_raw_int16(&ps2mouse_lastx, &ps2mouse_lasty);
+#endif
+ return (ps2mouse_queue_put(PS2_REPLY_OK));
+ break;
+
+ case PS2_CMD_READ_DATA:
+ new_buttons = ps2mouse_buttons;
+#ifdef HAVE_MOUSE
+ mouse_poll(); /* HACK: should probably happen elsewhere */
+ mouse_get_raw_int16(&new_x, &new_y);
+
+ diff_x = (new_x - ps2mouse_lastx);
+ if (diff_x < 0) {
+ new_buttons |= PS2_MDATA_XS;
+ }
+ if (diff_x < -256 || diff_x > 255) {
+ new_buttons |= PS2_MDATA_XO;
+ }
+ ps2mouse_lastx = new_x;
+
+ diff_y = (int16_t)(new_y - ps2mouse_lasty);
+ if (diff_y < 0) {
+ new_buttons |= PS2_MDATA_YS;
+ }
+ if (diff_y < -256 || diff_y > 255) {
+ new_buttons |= PS2_MDATA_YO;
+ }
+ ps2mouse_lasty = new_y;
+#else
+ diff_x = 0;
+ diff_y = 0;
+#endif
+#ifdef PS2MOUSE_DEBUG_ENABLED
+ PS2MOUSE_DEBUG("x/y/b: %02x, %02x, %02x", diff_x, diff_y, new_buttons);
+#endif
+ return (ps2mouse_queue_put(PS2_REPLY_OK)
+ && ps2mouse_queue_put(new_buttons)
+ && ps2mouse_queue_put((uint8_t)diff_x)
+ && ps2mouse_queue_put((uint8_t)diff_y));
+ break;
+
+ default:
+#ifdef PS2MOUSE_DEBUG_ENABLED
+ PS2MOUSE_DEBUG("unsupported command %02x", value);
+#endif
+ return (ps2mouse_queue_put(PS2_REPLY_ERROR) & 0);
+ break;
+ }
+ return 0;
+}
+
+
+struct alarm_s *c64dtv_ps2mouse_alarm;
+
+static void c64dtv_ps2mouse_alarm_handler(CLOCK offset, void *data)
+{
+ int another_alarm = 1;
+
+ alarm_unset(c64dtv_ps2mouse_alarm);
+
+ ps2mouse_out ^= PS2_CLK_BIT;
+ ps2mouse_out &= ~PS2_DATA_BIT;
+
+ switch (ps2mouse_xmit_state) {
+ case PS2_FROM_START:
+ ps2mouse_value = 0;
+ ps2mouse_parity = 0;
+ ps2mouse_out |= (ps2mouse_in & PS2_DATA_BIT);
+#ifdef PS2MOUSE_DEBUG_ENABLED
+ PS2MOUSE_DEBUG("start: clk/data = %i/%i", (ps2mouse_out >> 6) & 1, (ps2mouse_out >> 7) & 1);
+#endif
+ if ((ps2mouse_out & PS2_CLK_BIT) == 0) {
+ ++ps2mouse_xmit_state;
+ }
+ break;
+
+ case PS2_FROM_D0:
+ case PS2_FROM_D1:
+ case PS2_FROM_D2:
+ case PS2_FROM_D3:
+ case PS2_FROM_D4:
+ case PS2_FROM_D5:
+ case PS2_FROM_D6:
+ case PS2_FROM_D7:
+ if (ps2mouse_out & PS2_CLK_BIT) {
+ ps2mouse_value >>= 1;
+ if (ps2mouse_in & PS2_DATA_BIT) {
+ ps2mouse_value |= 0x80;
+ ps2mouse_parity ^= PS2_DATA_BIT;
+ }
+ }
+ ps2mouse_out |= (ps2mouse_in & PS2_DATA_BIT);
+#ifdef PS2MOUSE_DEBUG_ENABLED
+ PS2MOUSE_DEBUG("d%i: clk/data = %i/%i", ps2mouse_xmit_state - PS2_FROM_D0, (ps2mouse_out >> 6) & 1, (ps2mouse_out >> 7) & 1);
+#endif
+ if ((ps2mouse_out & PS2_CLK_BIT) == 0) {
+ ++ps2mouse_xmit_state;
+ }
+ break;
+
+ case PS2_FROM_PARITY:
+ if (ps2mouse_out & PS2_CLK_BIT) {
+ if (ps2mouse_in & PS2_DATA_BIT) {
+ ps2mouse_parity ^= PS2_DATA_BIT;
+ }
+ }
+ ps2mouse_out |= PS2_DATA_BIT;
+#ifdef PS2MOUSE_DEBUG_ENABLED
+ PS2MOUSE_DEBUG("parity: clk/data = %i/%i", (ps2mouse_out >> 6) & 1, (ps2mouse_out >> 7) & 1);
+#endif
+ if ((ps2mouse_out & PS2_CLK_BIT) == 0) {
+ ++ps2mouse_xmit_state;
+ }
+ break;
+
+ case PS2_FROM_STOP:
+ if (ps2mouse_out & PS2_CLK_BIT) {
+ if (ps2mouse_in & PS2_DATA_BIT) {
+ ps2mouse_parity ^= PS2_DATA_BIT;
+ }
+ ps2mouse_out |= PS2_DATA_BIT;
+ } else {
+ ps2mouse_out |= ps2mouse_parity;
+ }
+#ifdef PS2MOUSE_DEBUG_ENABLED
+ PS2MOUSE_DEBUG("stop: clk/data = %i/%i", (ps2mouse_out >> 6) & 1, (ps2mouse_out >> 7) & 1);
+#endif
+ if ((ps2mouse_out & PS2_CLK_BIT) == 0) {
+ ++ps2mouse_xmit_state;
+ }
+ break;
+
+ case PS2_FROM_ACK:
+ ps2mouse_out |= PS2_DATA_BIT; /* ps2mouse_parity; */
+#ifdef PS2MOUSE_DEBUG_ENABLED
+ PS2MOUSE_DEBUG("got %02x, parity: %02x, clk/data = %i/%i", ps2mouse_value, ps2mouse_parity, (ps2mouse_out >> 6) & 1, (ps2mouse_out >> 7) & 1);
+#endif
+ another_alarm = ps2mouse_handle_command(ps2mouse_value);
+ break;
+
+ case PS2_CHECK_SEND:
+ if (ps2mouse_queue_empty()) {
+ ps2mouse_out |= (PS2_DATA_BIT | PS2_CLK_BIT);
+ another_alarm = 0;
+ ps2mouse_xmit_state = PS2_FROMTO_IDLE;
+#ifdef PS2MOUSE_DEBUG_ENABLED
+ PS2MOUSE_DEBUG("all sent. clk/data = %i/%i", (ps2mouse_out >> 6) & 1, (ps2mouse_out >> 7) & 1);
+#endif
+ break;
+ }
+ if ((ps2mouse_in & PS2_CLK_BIT) == 0) {
+ ps2mouse_out &= ~PS2_CLK_BIT;
+#ifdef PS2MOUSE_DEBUG_ENABLED
+ PS2MOUSE_DEBUG("hold! clk/data = %i/%i", (ps2mouse_out >> 6) & 1, (ps2mouse_out >> 7) & 1);
+#endif
+ break;
+ }
+
+ if ((ps2mouse_out & PS2_CLK_BIT) == 0) {
+ ps2mouse_parity = PS2_DATA_BIT;
+ ps2mouse_value = ps2mouse_queue_get();
+#ifdef PS2MOUSE_DEBUG_ENABLED
+ PS2MOUSE_DEBUG("sending %02x, clk/data = %i/%i", ps2mouse_value, (ps2mouse_out >> 6) & 1, (ps2mouse_out >> 7) & 1);
+#endif
+ ps2mouse_xmit_state = PS2_TO_D0;
+ }
+ break;
+
+ case PS2_TO_D0:
+ case PS2_TO_D1:
+ case PS2_TO_D2:
+ case PS2_TO_D3:
+ case PS2_TO_D4:
+ case PS2_TO_D5:
+ case PS2_TO_D6:
+ case PS2_TO_D7:
+ if (ps2mouse_out & PS2_CLK_BIT) {
+ ps2mouse_out |= (ps2mouse_value & 1) ? PS2_DATA_BIT : 0;
+ ps2mouse_prev = ps2mouse_out;
+ ps2mouse_parity ^= (ps2mouse_value & 1) ? PS2_DATA_BIT : 0;
+ ps2mouse_value >>= 1;
+ } else {
+ ps2mouse_out |= (ps2mouse_prev & PS2_DATA_BIT);
+ }
+#ifdef PS2MOUSE_DEBUG_ENABLED
+ PS2MOUSE_DEBUG("to_d%i: clk/data = %i/%i", ps2mouse_xmit_state - PS2_TO_D0, (ps2mouse_out >> 6) & 1, (ps2mouse_out >> 7) & 1);
+#endif
+ if ((ps2mouse_out & PS2_CLK_BIT) == 0) {
+ ++ps2mouse_xmit_state;
+ }
+ break;
+
+ case PS2_TO_PARITY:
+ if (ps2mouse_out & PS2_CLK_BIT) {
+ ps2mouse_out |= ps2mouse_parity;
+ ps2mouse_prev = ps2mouse_out;
+ } else {
+ ps2mouse_out |= (ps2mouse_prev & PS2_DATA_BIT);
+ }
+#ifdef PS2MOUSE_DEBUG_ENABLED
+ PS2MOUSE_DEBUG("to_parity: clk/data = %i/%i", (ps2mouse_out >> 6) & 1, (ps2mouse_out >> 7) & 1);
+#endif
+ if ((ps2mouse_out & PS2_CLK_BIT) == 0) {
+ ++ps2mouse_xmit_state;
+ }
+ break;
+
+ case PS2_TO_STOP:
+ ps2mouse_out |= PS2_DATA_BIT;
+#ifdef PS2MOUSE_DEBUG_ENABLED
+ PS2MOUSE_DEBUG("stop: clk/data = %i/%i", (ps2mouse_out >> 6) & 1, (ps2mouse_out >> 7) & 1);
+#endif
+ if ((ps2mouse_out & PS2_CLK_BIT) == 0) {
+ ps2mouse_xmit_state = PS2_CHECK_SEND;
+ }
+ break;
+
+ default:
+ ps2mouse_out |= (PS2_DATA_BIT | PS2_CLK_BIT);
+ another_alarm = 0;
+ ps2mouse_xmit_state = PS2_FROMTO_IDLE;
+#ifdef PS2MOUSE_DEBUG_ENABLED
+ PS2MOUSE_DEBUG("bug! state %i. clk/data = %i/%i", ps2mouse_xmit_state, (ps2mouse_out >> 6) & 1, (ps2mouse_out >> 7) & 1);
+#endif
+ break;
+ }
+
+ if (another_alarm) {
+ alarm_set(c64dtv_ps2mouse_alarm, maincpu_clk + PS2_BIT_DELAY_CLK);
+ }
+}
+
+
+void userport_ps2mouse_store_pbx(uint8_t value, int pulse)
+{
+ ps2mouse_in = value;
+ if (((ps2mouse_prev & PS2_CLK_BIT) == 0) && (value & PS2_CLK_BIT)
+ && (ps2mouse_xmit_state == PS2_FROMTO_IDLE) && ((value & PS2_DATA_BIT) == 0)) {
+ ps2mouse_xmit_state = PS2_FROM_START;
+ ps2mouse_out = value;
+ alarm_set(c64dtv_ps2mouse_alarm, maincpu_clk + PS2_BIT_DELAY_CLK);
+ }
+ ps2mouse_prev = value;
+ return;
+}
+
+uint8_t userport_ps2mouse_read_pbx(uint8_t orig)
+{
+ return ps2mouse_out;
+}
+
+/* ------------------------------------------------------------------------- */
+
+static void userport_ps2mouse_alarm_init(void)
+{
+ c64dtv_ps2mouse_alarm = alarm_new(maincpu_alarm_context, "PS2MOUSEAlarm",
+ c64dtv_ps2mouse_alarm_handler, NULL);
+}
+
+/* called from src/c64dtv/c64dtvmem.c:979 */
+void ps2mouse_reset(void)
+{
+ ps2mouse_in = 0xff;
+ ps2mouse_out = 0xff;
+ ps2mouse_prev = 0xff;
+ ps2mouse_xmit_state = PS2_FROMTO_IDLE;
+ ps2mouse_parity = 0;
+ ps2mouse_lastx = 0;
+ ps2mouse_lasty = 0;
+ ps2mouse_buttons = PS2_MDATA_A1;
+ ps2mouse_queue_head = 0;
+ ps2mouse_queue_tail = 0;
+ return;
+}
+
+/* ------------------------------------------------------------------------- */
+
+static const mouse_func_t mouse_funcs =
+{
+ mouse_button_left,
+ mouse_button_right,
+ mouse_button_middle,
+ mouse_button_up,
+ mouse_button_down
+};
+
+/* called from src/c64dtv/c64dtv.c:507 */
+int mouse_ps2_resources_init(void)
+{
+ return mousedrv_resources_init(&mouse_funcs);
+}
+
+/* called from src/c64dtv/c64dtv.c:637 */
+int mouse_ps2_cmdline_options_init(void)
+{
+ return mousedrv_cmdline_options_init();
+}
+
+/* called from src/c64dtv/c64dtv.c:776 */
+void mouse_ps2_init(void)
+{
+ if (ps2mouse_log == LOG_DEFAULT) {
+ ps2mouse_log = log_open("ps2mouse");
+ }
+
+ userport_ps2mouse_alarm_init();
+
+ ps2mouse_reset();
+ mousedrv_init();
+}
+
+/* called from src/c64dtv/c64dtv.c:823 */
+void mouse_ps2_shutdown(void)
+{
+}
+
+static void mouse_button_left(int pressed)
+{
+ if (pressed) {
+ ps2mouse_buttons |= PS2_MDATA_LB;
+ } else {
+ ps2mouse_buttons &= ~PS2_MDATA_LB;
+ }
+}
+
+static void mouse_button_middle(int pressed)
+{
+ if (pressed) {
+ ps2mouse_buttons |= PS2_MDATA_MB;
+ } else {
+ ps2mouse_buttons &= ~PS2_MDATA_MB;
+ }
+}
+
+static void mouse_button_right(int pressed)
+{
+ if (pressed) {
+ ps2mouse_buttons |= PS2_MDATA_RB;
+ } else {
+ ps2mouse_buttons &= ~PS2_MDATA_RB;
+ }
+}
+
+static void mouse_button_up(int pressed)
+{
+}
+
+static void mouse_button_down(int pressed)
+{
+}
Copied: trunk/vice/src/userport/userport_ps2mouse.h (from rev 45721, trunk/vice/src/ps2mouse.h)
===================================================================
--- trunk/vice/src/userport/userport_ps2mouse.h (rev 0)
+++ trunk/vice/src/userport/userport_ps2mouse.h 2025-08-01 23:38:39 UTC (rev 45722)
@@ -0,0 +1,43 @@
+/*
+ * ps2mouse.h - PS/2 mouse on userport emulation
+ *
+ * Written by
+ * Hannu Nuotio <han...@tu...>
+ * Based on code by
+ * Andreas Boose <vic...@t-...>
+ *
+ * This file is part of VICE, the Versatile Commodore Emulator.
+ * See README for copyright notice.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ *
+ */
+
+#ifndef VICE_PS2MOUSE_H
+#define VICE_PS2MOUSE_H
+
+#include "types.h"
+
+int userport_ps2mouse_resources_init(void);
+
+void ps2mouse_reset(void);
+
+int mouse_ps2_resources_init(void);
+int mouse_ps2_cmdline_options_init(void);
+void mouse_ps2_init(void);
+void mouse_ps2_shutdown(void);
+
+#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gp...@us...> - 2025-07-31 20:59:14
|
Revision: 45721
http://sourceforge.net/p/vice-emu/code/45721
Author: gpz
Date: 2025-07-31 20:59:11 +0000 (Thu, 31 Jul 2025)
Log Message:
-----------
some refactoring, move all hummer-adc related code into hummeradc.c, and handle it like any other joystick adapter
Modified Paths:
--------------
trunk/vice/src/c64dtv/c64dtv-cmdline-options.c
trunk/vice/src/c64dtv/c64dtv-resources.c
trunk/vice/src/c64dtv/c64dtv-resources.h
trunk/vice/src/c64dtv/c64dtv-snapshot.c
trunk/vice/src/c64dtv/c64dtv.c
trunk/vice/src/c64dtv/c64dtvcia2.c
trunk/vice/src/c64dtv/c64dtvmemsnapshot.c
trunk/vice/src/c64dtv/c64dtvmemsnapshot.h
trunk/vice/src/c64dtv/hummeradc.c
trunk/vice/src/c64dtv/hummeradc.h
Modified: trunk/vice/src/c64dtv/c64dtv-cmdline-options.c
===================================================================
--- trunk/vice/src/c64dtv/c64dtv-cmdline-options.c 2025-07-31 00:06:54 UTC (rev 45720)
+++ trunk/vice/src/c64dtv/c64dtv-cmdline-options.c 2025-07-31 20:59:11 UTC (rev 45721)
@@ -97,13 +97,7 @@
"<Name>", "Specify name of character generator ROM image" },
{ "-model", CALL_FUNCTION, CMDLINE_ATTRIB_NEED_ARGS,
set_dtv_model, NULL, NULL, NULL,
- "<Model>", "Set DTV model (v2/v2pal/v2ntsc, v3/v3pal/v3ntsc, hummer)" },
- { "-hummeradc", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
- NULL, NULL, "HummerADC", (void *)1,
- NULL, "Enable Hummer ADC" },
- { "+hummeradc", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
- NULL, NULL, "HummerADC", (void *)0,
- NULL, "Disable Hummer ADC" },
+ "<Model>", "Set DTV model (v2/v2pal/v2ntsc, v3/v3pal/v3ntsc, hummer/hummerpal/hummerntsc)" },
CMDLINE_LIST_END
};
Modified: trunk/vice/src/c64dtv/c64dtv-resources.c
===================================================================
--- trunk/vice/src/c64dtv/c64dtv-resources.c 2025-07-31 00:06:54 UTC (rev 45720)
+++ trunk/vice/src/c64dtv/c64dtv-resources.c 2025-07-31 20:59:11 UTC (rev 45721)
@@ -147,14 +147,6 @@
}
#endif
-int c64dtv_hummer_adc_enabled = 0;
-
-static int c64dtv_hummer_adc_set(int val, void *param)
-{
- c64dtv_hummer_adc_enabled = val ? 1 : 0;
- return 0;
-}
-
static const resource_string_t resources_string[] = {
{ "ChargenName", C64_CHARGEN_NAME, RES_EVENT_NO, NULL,
/* FIXME: should be same but names may differ */
@@ -171,8 +163,6 @@
static const resource_int_t resources_int[] = {
{ "MachineVideoStandard", MACHINE_SYNC_PAL, RES_EVENT_SAME, NULL,
&sync_factor, set_sync_factor, NULL },
- { "HummerADC", 0, RES_EVENT_SAME, NULL,
- (int *)&c64dtv_hummer_adc_enabled, c64dtv_hummer_adc_set, NULL },
RESOURCE_INT_LIST_END
};
Modified: trunk/vice/src/c64dtv/c64dtv-resources.h
===================================================================
--- trunk/vice/src/c64dtv/c64dtv-resources.h 2025-07-31 00:06:54 UTC (rev 45720)
+++ trunk/vice/src/c64dtv/c64dtv-resources.h 2025-07-31 20:59:11 UTC (rev 45721)
@@ -30,6 +30,4 @@
int c64dtv_resources_init(void);
void c64dtv_resources_shutdown(void);
-extern int c64dtv_hummer_adc_enabled;
-
#endif
Modified: trunk/vice/src/c64dtv/c64dtv-snapshot.c
===================================================================
--- trunk/vice/src/c64dtv/c64dtv-snapshot.c 2025-07-31 00:06:54 UTC (rev 45720)
+++ trunk/vice/src/c64dtv/c64dtv-snapshot.c 2025-07-31 20:59:11 UTC (rev 45721)
@@ -41,6 +41,7 @@
#include "cia.h"
#include "drive-snapshot.h"
#include "drive.h"
+#include "hummeradc.h"
#include "joyport.h"
#include "joystick.h"
#include "keyboard.h"
@@ -82,7 +83,7 @@
|| c64dtv_snapshot_write_module(s, save_roms) < 0
|| c64dtvdma_snapshot_write_module(s) < 0
|| c64dtvblitter_snapshot_write_module(s) < 0
- || c64dtvmisc_snapshot_write_module(s) < 0
+ || hummeradc_snapshot_write_module(s) < 0
|| ciacore_snapshot_write_module(machine_context.cia1, s) < 0
|| ciacore_snapshot_write_module(machine_context.cia2, s) < 0
|| sid_snapshot_write_module(s) < 0
@@ -127,7 +128,7 @@
|| c64dtv_snapshot_read_module(s) < 0
|| c64dtvdma_snapshot_read_module(s) < 0
|| c64dtvblitter_snapshot_read_module(s) < 0
- || c64dtvmisc_snapshot_read_module(s) < 0
+ || hummeradc_snapshot_read_module(s) < 0
|| ciacore_snapshot_read_module(machine_context.cia1, s) < 0
|| ciacore_snapshot_read_module(machine_context.cia2, s) < 0
|| sid_snapshot_read_module(s) < 0
Modified: trunk/vice/src/c64dtv/c64dtv.c
===================================================================
--- trunk/vice/src/c64dtv/c64dtv.c 2025-07-31 00:06:54 UTC (rev 45720)
+++ trunk/vice/src/c64dtv/c64dtv.c 2025-07-31 20:59:11 UTC (rev 45721)
@@ -61,6 +61,7 @@
#include "fliplist.h"
#include "fsdevice.h"
#include "gfxoutput.h"
+#include "hummeradc.h"
#include "imagecontents.h"
#include "inception.h"
#include "init.h"
@@ -409,6 +410,10 @@
init_resource_fail("c64dtv");
return -1;
}
+ if (hummeradc_resources_init() < 0) {
+ init_resource_fail("hummer adc");
+ return -1;
+ }
if (c64dtvmem_resources_init() < 0) {
init_resource_fail("c64dtvmem");
return -1;
@@ -544,6 +549,10 @@
init_cmdline_options_fail("c64dtv");
return -1;
}
+ if (hummeradc_cmdline_options_init() < 0) {
+ init_cmdline_options_fail("hummer adc");
+ return -1;
+ }
if (c64dtvmem_cmdline_options_init() < 0) {
init_cmdline_options_fail("c64dtvmem");
return -1;
Modified: trunk/vice/src/c64dtv/c64dtvcia2.c
===================================================================
--- trunk/vice/src/c64dtv/c64dtvcia2.c 2025-07-31 00:06:54 UTC (rev 45720)
+++ trunk/vice/src/c64dtv/c64dtvcia2.c 2025-07-31 20:59:11 UTC (rev 45721)
@@ -56,16 +56,15 @@
void cia2_store(uint16_t addr, uint8_t data)
{
if ((addr & 0x1f) == 1) {
- /* HACK: for now only call the userport system when neither ps/2 mouse
- nor hummer adc is enabled */
- if (!c64dtv_hummer_adc_enabled && !ps2mouse_enabled) {
+ /* HACK: for now only call the userport system when ps/2 mouse is disabled */
+ if (!ps2mouse_enabled) {
store_userport_pbx(data, USERPORT_NO_PULSE);
}
- /* FIXME: convert hummer adc and ps/2 mouse support to new userport system */
if (c64dtv_hummer_adc_enabled) {
hummeradc_store(data);
}
+ /* FIXME: convert ps/2 mouse support to new userport system */
if (ps2mouse_enabled) {
ps2mouse_store(data);
}
@@ -79,13 +78,12 @@
uint8_t retval = 0xff;
if ((addr & 0x1f) == 1) {
- /* HACK: for now only call the userport system when neither ps/2 mouse
- nor hummer adc is enabled */
- if (!c64dtv_hummer_adc_enabled && !ps2mouse_enabled) {
+ /* HACK: for now only call the userport system when ps/2 mouse is disabled */
+ if (!ps2mouse_enabled) {
retval = read_userport_pbx(retval);
}
- /* FIXME: convert hummer adc and ps/2 mouse support to new userport system */
+ /* FIXME: convert ps/2 mouse support to new userport system */
if (ps2mouse_enabled) {
retval &= (ps2mouse_read() | 0x3f);
}
Modified: trunk/vice/src/c64dtv/c64dtvmemsnapshot.c
===================================================================
--- trunk/vice/src/c64dtv/c64dtvmemsnapshot.c 2025-07-31 00:06:54 UTC (rev 45720)
+++ trunk/vice/src/c64dtv/c64dtvmemsnapshot.c 2025-07-31 20:59:11 UTC (rev 45721)
@@ -276,82 +276,3 @@
return -1;
}
-#define SNAP_MAJOR 0
-#define SNAP_MINOR 0
-static const char snap_misc_module_name[] = "C64DTVMISC";
-
-int c64dtvmisc_snapshot_write_module(snapshot_t *s)
-{
- snapshot_module_t *m;
-
- /* Misc. module. */
- m = snapshot_module_create(s, snap_misc_module_name, SNAP_MAJOR, SNAP_MINOR);
- if (m == NULL) {
- return -1;
- }
-
- if (SMW_B(m, hummeradc_value) < 0
- || SMW_B(m, hummeradc_channel) < 0
- || SMW_B(m, hummeradc_control) < 0
- || SMW_B(m, hummeradc_chanattr) < 0
- || SMW_B(m, hummeradc_chanwakeup) < 0
- || SMW_B(m, hummeradc_prev) < 0) {
- goto fail;
- }
-
- if (snapshot_module_close(m) < 0) {
- goto fail;
- }
- m = NULL;
-
- return 0;
-
-fail:
- if (m != NULL) {
- snapshot_module_close(m);
- }
- return -1;
-}
-
-int c64dtvmisc_snapshot_read_module(snapshot_t *s)
-{
- uint8_t major_version, minor_version;
- snapshot_module_t *m;
-
- /* Misc. module. */
- m = snapshot_module_open(s, snap_misc_module_name,
- &major_version, &minor_version);
- if (m == NULL) {
- return -1;
- }
-
- if (snapshot_version_is_bigger(major_version, minor_version, SNAP_MAJOR, SNAP_MINOR)) {
- log_error(c64_snapshot_log,
- "Snapshot module version (%d.%d) newer than %d.%d.",
- major_version, minor_version,
- SNAP_MAJOR, SNAP_MINOR);
- goto fail;
- }
-
- if (SMR_B(m, &hummeradc_value) < 0
- || SMR_B(m, &hummeradc_channel) < 0
- || SMR_B(m, &hummeradc_control) < 0
- || SMR_B(m, &hummeradc_chanattr) < 0
- || SMR_B(m, &hummeradc_chanwakeup) < 0
- || SMR_B(m, &hummeradc_prev) < 0) {
- goto fail;
- }
-
- if (snapshot_module_close(m) < 0) {
- goto fail;
- }
- m = NULL;
-
- return 0;
-
-fail:
- if (m != NULL) {
- snapshot_module_close(m);
- }
- return -1;
-}
Modified: trunk/vice/src/c64dtv/c64dtvmemsnapshot.h
===================================================================
--- trunk/vice/src/c64dtv/c64dtvmemsnapshot.h 2025-07-31 00:06:54 UTC (rev 45720)
+++ trunk/vice/src/c64dtv/c64dtvmemsnapshot.h 2025-07-31 20:59:11 UTC (rev 45721)
@@ -31,7 +31,5 @@
int c64dtv_snapshot_write_module(struct snapshot_s *s, int save_roms);
int c64dtv_snapshot_read_module(struct snapshot_s *s);
-int c64dtvmisc_snapshot_write_module(struct snapshot_s *s);
-int c64dtvmisc_snapshot_read_module(struct snapshot_s *s);
#endif
Modified: trunk/vice/src/c64dtv/hummeradc.c
===================================================================
--- trunk/vice/src/c64dtv/hummeradc.c 2025-07-31 00:06:54 UTC (rev 45720)
+++ trunk/vice/src/c64dtv/hummeradc.c 2025-07-31 20:59:11 UTC (rev 45721)
@@ -27,10 +27,12 @@
#include "vice.h"
#include "c64dtv-resources.h"
+#include "cmdline.h"
#include "hummeradc.h"
#include "joystick.h"
#include "log.h"
#include "resources.h"
+#include "uiapi.h"
static log_t hummeradc_log = LOG_DEFAULT;
@@ -45,13 +47,12 @@
#define ADC_DIO_BIT 0x01
/* Hummer ADC variables */
-/* FIXME: move code from c64dtvmemsnapshot.c here, make static */
-uint8_t hummeradc_value;
-uint8_t hummeradc_channel;
-uint8_t hummeradc_control;
-uint8_t hummeradc_chanattr;
-uint8_t hummeradc_chanwakeup;
-uint8_t hummeradc_prev;
+static uint8_t hummeradc_value;
+static uint8_t hummeradc_channel;
+static uint8_t hummeradc_control;
+static uint8_t hummeradc_chanattr;
+static uint8_t hummeradc_chanwakeup;
+static uint8_t hummeradc_prev;
/* Hummer ADC state */
enum {
@@ -311,6 +312,12 @@
/* ------------------------------------------------------------------------- */
+
+int hummeradc_enable(int value)
+{
+ return 0;
+}
+
void hummeradc_init(void)
{
if (hummeradc_log == LOG_DEFAULT) {
@@ -337,3 +344,139 @@
hummeradc_chanwakeup = 0;
return;
}
+
+int c64dtv_hummer_adc_enabled = 0;
+
+static int c64dtv_hummer_adc_set(int value, void *param)
+{
+ int val = value ? 1 : 0;
+
+ if (c64dtv_hummer_adc_enabled == val) {
+ return 0;
+ }
+
+ if (val) {
+ /* check if a different joystick adapter is already active */
+ if (joystick_adapter_get_id()) {
+ ui_error("Joystick adapter %s is already active", joystick_adapter_get_name());
+ return -1;
+ }
+ joystick_adapter_activate(JOYSTICK_ADAPTER_ID_GENERIC_USERPORT, "Hummer ADC");
+
+ /* Enable 1 extra joystick port, without +5VDC support */
+ joystick_adapter_set_ports(1, 0);
+ } else {
+ joystick_adapter_deactivate();
+ }
+
+ c64dtv_hummer_adc_enabled = val;
+
+ return 0;
+}
+
+static const resource_int_t resources_int[] = {
+ { "HummerADC", 0, RES_EVENT_SAME, NULL,
+ (int *)&c64dtv_hummer_adc_enabled, c64dtv_hummer_adc_set, NULL },
+ RESOURCE_INT_LIST_END
+};
+
+int hummeradc_resources_init(void)
+{
+ return resources_register_int(resources_int);
+}
+
+static const cmdline_option_t cmdline_options[] =
+{
+ { "-hummeradc", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
+ NULL, NULL, "HummerADC", (void *)1,
+ NULL, "Enable Hummer ADC" },
+ { "+hummeradc", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
+ NULL, NULL, "HummerADC", (void *)0,
+ NULL, "Disable Hummer ADC" },
+ CMDLINE_LIST_END
+};
+
+int hummeradc_cmdline_options_init(void)
+{
+ return cmdline_register_options(cmdline_options);
+}
+
+#define SNAP_MAJOR 0
+#define SNAP_MINOR 0
+static const char snap_misc_module_name[] = "HUMMERADC";
+
+int hummeradc_snapshot_write_module(snapshot_t *s)
+{
+ snapshot_module_t *m;
+
+ /* Misc. module. */
+ m = snapshot_module_create(s, snap_misc_module_name, SNAP_MAJOR, SNAP_MINOR);
+ if (m == NULL) {
+ return -1;
+ }
+
+ if (SMW_B(m, hummeradc_value) < 0
+ || SMW_B(m, hummeradc_channel) < 0
+ || SMW_B(m, hummeradc_control) < 0
+ || SMW_B(m, hummeradc_chanattr) < 0
+ || SMW_B(m, hummeradc_chanwakeup) < 0
+ || SMW_B(m, hummeradc_prev) < 0) {
+ goto fail;
+ }
+
+ if (snapshot_module_close(m) < 0) {
+ goto fail;
+ }
+ m = NULL;
+
+ return 0;
+
+fail:
+ if (m != NULL) {
+ snapshot_module_close(m);
+ }
+ return -1;
+}
+
+int hummeradc_snapshot_read_module(snapshot_t *s)
+{
+ uint8_t major_version, minor_version;
+ snapshot_module_t *m;
+
+ /* Misc. module. */
+ m = snapshot_module_open(s, snap_misc_module_name,
+ &major_version, &minor_version);
+ if (m == NULL) {
+ return -1;
+ }
+
+ if (snapshot_version_is_bigger(major_version, minor_version, SNAP_MAJOR, SNAP_MINOR)) {
+ log_error(hummeradc_log,
+ "Snapshot module version (%d.%d) newer than %d.%d.",
+ major_version, minor_version,
+ SNAP_MAJOR, SNAP_MINOR);
+ goto fail;
+ }
+
+ if (SMR_B(m, &hummeradc_value) < 0
+ || SMR_B(m, &hummeradc_channel) < 0
+ || SMR_B(m, &hummeradc_control) < 0
+ || SMR_B(m, &hummeradc_chanattr) < 0
+ || SMR_B(m, &hummeradc_chanwakeup) < 0
+ || SMR_B(m, &hummeradc_prev) < 0) {
+ goto fail;
+ }
+
+ if (snapshot_module_close(m) < 0) {
+ goto fail;
+ }
+ m = NULL;
+
+ return 0;
+
+fail:
+ if (m != NULL) {
+ snapshot_module_close(m);
+ }
+ return -1;
+}
Modified: trunk/vice/src/c64dtv/hummeradc.h
===================================================================
--- trunk/vice/src/c64dtv/hummeradc.h 2025-07-31 00:06:54 UTC (rev 45720)
+++ trunk/vice/src/c64dtv/hummeradc.h 2025-07-31 20:59:11 UTC (rev 45721)
@@ -28,6 +28,7 @@
#define VICE_HUMMERADC_H
#include "types.h"
+#include "snapshot.h"
void hummeradc_init(void);
void hummeradc_reset(void);
@@ -36,11 +37,14 @@
uint8_t hummeradc_read(void);
void hummeradc_store(uint8_t value);
-extern uint8_t hummeradc_value;
-extern uint8_t hummeradc_channel;
-extern uint8_t hummeradc_control;
-extern uint8_t hummeradc_chanattr;
-extern uint8_t hummeradc_chanwakeup;
-extern uint8_t hummeradc_prev;
+int hummeradc_enable(int value);
+extern int c64dtv_hummer_adc_enabled;
+
+int hummeradc_cmdline_options_init(void);
+int hummeradc_resources_init(void);
+
+int hummeradc_snapshot_write_module(snapshot_t *s);
+int hummeradc_snapshot_read_module(snapshot_t *s);
+
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|