Revision: 45698
http://sourceforge.net/p/vice-emu/code/45698
Author: gpz
Date: 2025-06-13 18:24:22 +0000 (Fri, 13 Jun 2025)
Log Message:
-----------
fix Comal 80 cartridge implementation, add a subtype for the older 'grey' cartridge. should fix #2145
Modified Paths:
--------------
trunk/vice/doc/vice.texi
trunk/vice/src/c64/cart/c64cart.c
trunk/vice/src/c64/cart/c64carthooks.c
trunk/vice/src/c64/cart/comal80.c
trunk/vice/src/c64/cart/comal80.h
Modified: trunk/vice/doc/vice.texi
===================================================================
--- trunk/vice/doc/vice.texi 2025-06-13 08:11:00 UTC (rev 45697)
+++ trunk/vice/doc/vice.texi 2025-06-13 18:24:22 UTC (rev 45698)
@@ -10210,6 +10210,11 @@
@item CartridgeFile
String specifying the filename of the image for the cartridge emulated in the "main" slot.
+@vindex Comal80Revision
+@item Comal80Revision
+Integer specifying the Comal 80 hardware revision.
+(0: Grey, 1: Commodore/Black)
+
@vindex DQBB
@item DQBB
Boolean specifying whether the Double Quick Brown Box should be emulated or not.
@@ -10727,6 +10732,12 @@
@item -cartcomal <name>
Attach raw 64KiB Comal 80 cartridge image.
+@findex -comal80rev
+@item -comal80rev <Revision>
+Set the Comal 80 hardware revision
+(@code{Comal80Revision}).
+(0: Grey, 1: Commodore/Black)
+
@findex -cartdep256
@item -cartdep256 <name>
Attach raw Dela EP256 cartridge image.
@@ -31684,19 +31695,53 @@
banks of ROM memory and the cart has 1 (write-only) bank control register which
is located at $DE00 and mirrored throughout the $DE00-$DEFF range.
+ Two variants of this Cartridge existed:
+
+ 1. Grey Cartridge (Comal Users Group, USA)
+ Produced around 1984-1985, likely with UniComal Denmarks approval.
+ Approx. 2,000 units distributed (according to COMAL Today).
+
+@itemize @bullet
+@item 4 sockets populated with 16 KB EPROMs (27128)
+@item NO additional socket, but it was possible to piggyback a fifth EPROM via
+ minor hardware mod
+@end itemize
+
@example
bit meaning
--- -------
- 7 exrom?
- 6 game?
- 5 unknown function (used by the software to disable the cartridge)
- 4 unused?
- 3 unused?
- 2 unknown function (used by the software however)
- 0-1 selects bank
+ 7 -
+ 6 GAME
+ 5 EXROM
+ 4 -
+ 3 -
+ 2 -
+ 0-1 selects EPROM (16k bank)
@end example
+ 2. Black Cartridge (Official Commodore Release)
+ Used internationally and with a different hardware configuration.
+@itemize @bullet
+@item Two fixed 32 KB ROMs (Commodore) and one socket for a 32 KB (or with
+ hardware modification 64 KB ) EPROM
+@end itemize
+
+@example
+ bit meaning
+ --- -------
+ 7 -
+ 6 GAME + EXROM
+ 5 -
+ 4 -
+ 3 -
+ 2 switches to the optional third socket (additional 2x16k)
+ 0-1 selects EPROM+bank (4x16k bank)
+@end example
+
+If the Cartridge Hardware Subtype/Revision (Offset 0x1A in the CRT Header) is 1,
+then VICE emulates the older "Grey" cartridge variant.
+
@c @node FIXME
@subsubsection 22 - Structured Basic
Modified: trunk/vice/src/c64/cart/c64cart.c
===================================================================
--- trunk/vice/src/c64/cart/c64cart.c 2025-06-13 08:11:00 UTC (rev 45697)
+++ trunk/vice/src/c64/cart/c64cart.c 2025-06-13 18:24:22 UTC (rev 45698)
@@ -806,7 +806,7 @@
rc = capture_crt_attach(fd, rawcart);
break;
case CARTRIDGE_COMAL80:
- rc = comal80_crt_attach(fd, rawcart);
+ rc = comal80_crt_attach(fd, rawcart, header.subtype);
break;
case CARTRIDGE_DELA_EP256:
rc = delaep256_crt_attach(fd, rawcart);
Modified: trunk/vice/src/c64/cart/c64carthooks.c
===================================================================
--- trunk/vice/src/c64/cart/c64carthooks.c 2025-06-13 08:11:00 UTC (rev 45697)
+++ trunk/vice/src/c64/cart/c64carthooks.c 2025-06-13 18:24:22 UTC (rev 45698)
@@ -527,6 +527,7 @@
|| ethernetcart_cmdline_options_init() < 0
#endif
/* "Main Slot" */
+ || comal80_cmdline_options_init() < 0
|| easyflash_cmdline_options_init() < 0
|| gmod2_cmdline_options_init() < 0
|| gmod3_cmdline_options_init() < 0
@@ -593,6 +594,7 @@
|| aciacart_resources_init() < 0
#endif
/* "Main Slot" */
+ || comal80_resources_init() < 0
|| easyflash_resources_init() < 0
|| gmod2_resources_init() < 0
|| gmod3_resources_init() < 0
@@ -643,6 +645,7 @@
#endif
/* "Main Slot" */
+ comal80_resources_shutdown();
easyflash_resources_shutdown();
gmod2_resources_shutdown();
gmod3_resources_shutdown();
Modified: trunk/vice/src/c64/cart/comal80.c
===================================================================
--- trunk/vice/src/c64/cart/comal80.c 2025-06-13 08:11:00 UTC (rev 45697)
+++ trunk/vice/src/c64/cart/comal80.c 2025-06-13 18:24:22 UTC (rev 45698)
@@ -38,9 +38,12 @@
#include "c64mem.h"
#include "cartio.h"
#include "cartridge.h"
+#include "cmdline.h"
#include "comal80.h"
#include "export.h"
+#include "log.h"
#include "monitor.h"
+#include "resources.h"
#include "snapshot.h"
#include "types.h"
#include "util.h"
@@ -47,7 +50,7 @@
#include "crt.h"
#ifdef DEBUGCART
-#define DBG(x) printf x
+#define DBG(x) log_printf x
#else
#define DBG(x)
#endif
@@ -58,44 +61,74 @@
- 64K ROM (32K mapped to $8000 and 32K mapped to $A000)
- free socket for another 64K eprom
- The cart has 1 (write-only) bank control register which
- is located at $DE00 and mirrored throughout the $DE00-$DEFF
- range.
+ The cart has 1 (write-only) bank control register which is located at $DE00
+ and mirrored throughout the $DE00-$DEFF range.
- bit 7 : exrom?
- bit 6 : game?
- bit 5 : unknown function (used by the software to disable the cartridge)
- bit 4 : unused?
- bit 3 : unused?
- bit 2 : selects user eprom (bank MSB)
- bit 0-1 : selects bank
+ Two variants of this Cartridge existed:
+
+ 1. Grey Cartridge (Comal Users Group, USA)
+ Produced around 1984-1985, likely with UniComal Denmark’s approval.
+ Approx. 2,000 units distributed (according to COMAL Today).
+
+ - 4 sockets populated with 16 KB EPROMs (27128)
+ - NO additional socket, but it was possible to piggyback a fifth EPROM via
+ minor hardware mod
+
+ bit 7 : -
+ bit 6 : GAME
+ bit 5 : EXROM
+ bit 4 : -
+ bit 3 : -
+ bit 2 : -
+ bit 0-1 : selects EPROM (16k bank)
+
+ 2. Black Cartridge (Official Commodore Release)
+ Used internationally and with a different hardware configuration.
+
+ - Two fixed 32 KB ROMs (Commodore) and one socket for a 32 KB (or with
+ hardware modification 64 KB ) EPROM
+
+ bit 7 : -
+ bit 6 : GAME + EXROM
+ bit 5 : -
+ bit 4 : -
+ bit 3 : -
+ bit 2 : switches to the optional third socket (additional 2x16k)
+ bit 0-1 : selects EPROM+bank (4x16k bank)
+
*/
static int currregval = 0;
static int extrarom = 0;
+#define VARIANT_GREY 0
+#define VARIANT_BLACK 1
+static int comal80_variant = VARIANT_BLACK;
+
static void comal80_io1_store(uint16_t addr, uint8_t value)
{
int cmode, currbank;
- currregval = value & 0xc7;
- currbank = value & 7;
-
- switch (value & 0xe0) {
- case 0xe0:
- cmode = CMODE_RAM;
- break;
- default:
- case 0x80:
- cmode = CMODE_16KGAME;
- break;
- case 0x40:
- cmode = CMODE_8KGAME;
- break;
+ if (comal80_variant == VARIANT_GREY) {
+ static int modes[4] = {
+ CMODE_16KGAME, CMODE_ULTIMAX, CMODE_8KGAME, CMODE_RAM
+ };
+ currregval = value & 0x63;
+ cmode = modes[(value & 0x60) >> 5];
+ currbank = value & 3;
+ } else {
+ currregval = value & 0x47;
+ cmode = (value & 0x40) ? CMODE_RAM : CMODE_16KGAME;
+ currbank = value & 7;
}
#ifdef DEBUGCART
- if ((value != 0x82) && (value != 0x83)) {
- DBG(("COMAL80: IO1W %04x %02x mode: %d bank: %d\n", addr, value, cmode, currbank));
+ if (currregval != value) {
+ static unsigned int last = 0;
+ unsigned int now = value ^ currregval;
+ if (last != now) {
+ DBG(("using unconnected bits: 0x%02x", now));
+ last = now;
+ }
}
#endif
cart_config_changed_slotmain(0, (uint8_t)(cmode | (currbank << CMODE_BANK_SHIFT)), CMODE_READ);
@@ -108,8 +141,9 @@
static int comal80_dump(void)
{
- mon_out("extra eprom is installed: %s\n", extrarom ? "yes" : "no");
- mon_out("register value: $%02x\n", (unsigned int)currregval);
+ mon_out("Cartridge variant: %s", (comal80_variant == VARIANT_GREY) ? "grey" : "black");
+ mon_out("Extra eprom is installed: %s\n", extrarom ? "yes" : "no");
+ mon_out("Register value: $%02x\n", (unsigned int)currregval);
mon_out(" bank: %d/%d\n", currregval & 7, extrarom ? 8 : 4);
return 0;
}
@@ -176,8 +210,48 @@
}
/* ---------------------------------------------------------------------*/
+
+static int set_comal80_variant(int val, void *param)
+{
+ comal80_variant = val ? 1 : 0;
+ return 0;
+}
+
+static const resource_int_t resources_int[] = {
+ { "Comal80Revision", VARIANT_BLACK, RES_EVENT_NO, NULL,
+ &comal80_variant, set_comal80_variant, NULL },
+ RESOURCE_INT_LIST_END
+};
+
+int comal80_resources_init(void)
+{
+ return resources_register_int(resources_int);
+}
+
+void comal80_resources_shutdown(void)
+{
+
+}
+
+static const cmdline_option_t cmdline_options[] =
+{
+ { "-comal80rev", SET_RESOURCE, CMDLINE_ATTRIB_NEED_ARGS,
+ NULL, NULL, "Comal80Revision", NULL,
+ "<Revision>", "Set Comal 80 Revision (0: Grey, 1: Commodore/Black)" },
+ CMDLINE_LIST_END
+};
+
+int comal80_cmdline_options_init(void)
+{
+ if (cmdline_register_options(cmdline_options) < 0) {
+ return -1;
+ }
+ return 0;
+}
+
static int comal80_common_attach(void)
{
+ DBG(("using comal 80 variant: %s", (comal80_variant == VARIANT_GREY) ? "grey" : "black (commodore)"));
if (export_add(&export_res) < 0) {
return -1;
}
@@ -197,11 +271,13 @@
return comal80_common_attach();
}
-int comal80_crt_attach(FILE *fd, uint8_t *rawcart)
+int comal80_crt_attach(FILE *fd, uint8_t *rawcart, int variant)
{
crt_chip_header_t chip;
extrarom = 0;
+ /* NOTE: in the CRT file we use 0 for the "black" variant, 1 for "grey" */
+ comal80_variant = (variant == 1) ? VARIANT_GREY : VARIANT_BLACK;
while (1) {
if (crt_read_chip_header(&chip, fd)) {
@@ -228,6 +304,7 @@
export_remove(&export_res);
io_source_unregister(comal80_list_item);
comal80_list_item = NULL;
+ comal80_variant = VARIANT_BLACK;
}
/* ---------------------------------------------------------------------*/
@@ -238,6 +315,7 @@
------------------------------
BYTE | register | control register
BYTE | extra rom| image contains extra eprom
+ BYTE | revision | hardware variant
ARRAY | ROML | 32768 or 65536 BYTES of ROML data
ARRAY | ROMH | 32768 or 65536 BYTES of ROMH data
*/
@@ -244,7 +322,7 @@
static const char snap_module_name[] = "CARTCOMAL";
#define SNAP_MAJOR 0
-#define SNAP_MINOR 1
+#define SNAP_MINOR 2
int comal80_snapshot_write_module(snapshot_t *s)
{
@@ -259,6 +337,7 @@
if (0
|| (SMW_B(m, (uint8_t)currregval) < 0)
|| (SMW_B(m, (uint8_t)extrarom) < 0)
+ || (SMW_B(m, (uint8_t)comal80_variant) < 0)
|| (SMW_BA(m, roml_banks, extrarom ? 0x10000 : 0x8000) < 0)
|| (SMW_BA(m, romh_banks, extrarom ? 0x10000 : 0x8000) < 0)) {
snapshot_module_close(m);
@@ -288,6 +367,7 @@
if (0
|| (SMR_B_INT(m, &currregval) < 0)
|| (SMR_B_INT(m, &extrarom) < 0)
+ || (SMR_B_INT(m, &comal80_variant) < 0)
|| (SMR_BA(m, roml_banks, extrarom ? 0x10000 : 0x8000) < 0)
|| (SMR_BA(m, romh_banks, extrarom ? 0x10000 : 0x8000) < 0)) {
goto fail;
Modified: trunk/vice/src/c64/cart/comal80.h
===================================================================
--- trunk/vice/src/c64/cart/comal80.h 2025-06-13 08:11:00 UTC (rev 45697)
+++ trunk/vice/src/c64/cart/comal80.h 2025-06-13 18:24:22 UTC (rev 45698)
@@ -34,9 +34,13 @@
void comal80_config_init(void);
void comal80_config_setup(uint8_t *rawcart);
int comal80_bin_attach(const char *filename, uint8_t *rawcart);
-int comal80_crt_attach(FILE *fd, uint8_t *rawcart);
+int comal80_crt_attach(FILE *fd, uint8_t *rawcart, int variant);
void comal80_detach(void);
+int comal80_cmdline_options_init(void);
+int comal80_resources_init(void);
+void comal80_resources_shutdown(void);
+
struct snapshot_s;
int comal80_snapshot_write_module(struct snapshot_s *s);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|