vice-emu-commit Mailing List for VICE (Page 6)
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
(18) |
Nov
|
Dec
|
From: <gp...@us...> - 2025-05-12 15:33:19
|
Revision: 45673 http://sourceforge.net/p/vice-emu/code/45673 Author: gpz Date: 2025-05-12 15:33:17 +0000 (Mon, 12 May 2025) Log Message: ----------- some minimon fixes, better handling of the case when no rom image is attached at startup Modified Paths: -------------- trunk/vice/src/vic20/cart/minimon.c Modified: trunk/vice/src/vic20/cart/minimon.c =================================================================== --- trunk/vice/src/vic20/cart/minimon.c 2025-05-12 05:23:26 UTC (rev 45672) +++ trunk/vice/src/vic20/cart/minimon.c 2025-05-12 15:33:17 UTC (rev 45673) @@ -179,6 +179,48 @@ /* ------------------------------------------------------------------------- */ +static int minimon_rom_reload(char *filename); + +/* FIXME: this still needs to be tweaked to match the hardware */ +static RAMINITPARAM ramparam = { + .start_value = 255, + .value_invert = 2, + .value_offset = 1, + + .pattern_invert = 0x100, + .pattern_invert_value = 255, + + .random_start = 0, + .random_repeat = 0, + .random_chance = 0, +}; + +static void clear_ram(void) +{ + DBG(("clear_rom: clear buffer with RAM pattern")); + ram_init_with_pattern(minimon_rom, CART_ROM_SIZE, &ramparam); +} + +static void clear_eprom(void) +{ + DBG(("clear_rom: clear buffer with EPROM pattern")); + memset(minimon_rom, CART_ROM_SIZE, 0xff); +} + +static void allocate_rom(void) +{ + if (!minimon_rom) { + DBG(("allocate_rom: allocate buffer")); + minimon_rom = lib_malloc(CART_ROM_SIZE); + clear_ram(); + if (minimon_image_filename) { + minimon_rom_reload(minimon_image_filename); + } + } +} + +/* ------------------------------------------------------------------------- */ + /* Some prototypes are needed */ static uint8_t minimon_io2_read(uint16_t addr); static uint8_t minimon_io3_read(uint16_t addr); @@ -231,6 +273,9 @@ /* (only) register the io devices */ static int io_register(void) { + DBG(("io_register")); + allocate_rom(); + /* HACK: mem_cart_blocks is reserved for main slot */ minimon_io23_temp = mem_cart_blocks & (VIC_CART_IO2 | VIC_CART_IO3); mem_cart_blocks |= (VIC_CART_IO2 | VIC_CART_IO3); @@ -251,6 +296,7 @@ /* (only) un-register the io devices */ static int io_unregister(void) { + DBG(("io_unregister")); if (minimon_io2_list_item != NULL) { io_source_unregister(minimon_io2_list_item); minimon_io2_list_item = NULL; @@ -321,30 +367,6 @@ /* ------------------------------------------------------------------------- */ -/* FIXME: this still needs to be tweaked to match the hardware */ -static RAMINITPARAM ramparam = { - .start_value = 255, - .value_invert = 2, - .value_offset = 1, - - .pattern_invert = 0x100, - .pattern_invert_value = 255, - - .random_start = 0, - .random_repeat = 0, - .random_chance = 0, -}; - -static void allocate_rom(void) -{ - if (!minimon_rom) { - DBG(("allocate_rom: allocate buffer")); - minimon_rom = lib_malloc(CART_ROM_SIZE); - } - DBG(("allocate_rom: clear buffer with pattern")); - ram_init_with_pattern(minimon_rom, CART_ROM_SIZE, &ramparam); -} - void minimon_freeze(void) { DBG(("minimon_freeze")); @@ -425,16 +447,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) { return 0; } - if (name != NULL && *name != '\0') { + if ((name != NULL) && (*name != '\0')) { if (util_check_filename_access(name) < 0) { return -1; } } + DBG(("set_minimon_image_filename")); if (minimon_enabled) { minimon_flush_image(); util_string_set(&minimon_image_filename, name); @@ -442,6 +466,8 @@ util_string_set(&minimon_image_filename, name); } + /* FIXME: load new image */ + return 0; } @@ -463,6 +489,15 @@ DBG(("set_minimon_enabled: %d to %d", minimon_enabled, val)); if (val) { + + /* prepare the RAM/ROM */ + if (minimon_rom) { + clear_ram(); + if (minimon_image_filename) { + minimon_rom_reload(minimon_image_filename); + } + } + /* enable cartridge */ if (export_add(&export_res23) < 0) { return -1; @@ -470,6 +505,7 @@ if (minimon_io_enabled) { io_register(); } + /* FIXME: minimon_reload_file(); */ minimon_alarm_install(); } else { /* disable cartridge */ @@ -578,11 +614,62 @@ return 0; } +static int minimon_rom_reload(char *filename) +{ + crt_header_t header; + crt_chip_header_t chip; + FILE *fd = NULL; + + DBG(("minimon_rom_attach")); + + clear_eprom(); + if (minimon_bios_type != CARTRIDGE_FILETYPE_BIN) { + fd = crt_open(filename, &header); + + if (fd == NULL) { + return -1; + } + if (crt_read_chip_header(&chip, fd)) { + fclose(fd); + goto trybinary; + } + + if (chip.size != CART_ROM_SIZE) { + fclose(fd); + goto trybinary; + } + + if (crt_read_chip(&minimon_rom[0], 0, &chip, fd)) { + fclose(fd); + goto trybinary; + } + + minimon_bios_type = CARTRIDGE_FILETYPE_CRT; + DBG(("minimon_rom_attach (loaded: crt)")); + fclose(fd); + return 0; + } +trybinary: + + if (minimon_bios_type != CARTRIDGE_FILETYPE_CRT) { + if (zfile_load(filename, minimon_rom, (size_t)CART_ROM_SIZE) < 0) { + return -1; + } + minimon_bios_type = CARTRIDGE_FILETYPE_BIN; + DBG(("minimon_rom_attach (loaded: bin)")); + return 0; + } + return -1; +} + int minimon_crt_attach(FILE *fd, uint8_t *rawcart) { crt_chip_header_t chip; + DBG(("minimon_crt_attach")); + allocate_rom(); + clear_eprom(); if (crt_read_chip_header(&chip, fd)) { goto exiterror; @@ -606,6 +693,9 @@ minimon_enabled = 1; /* resource */ minimon_io_enabled = 1; /* resource */ + minimon_bios_type = CARTRIDGE_FILETYPE_CRT; + /* FIXME: set_minimon_image_filename(filename, NULL); */ /* set the resource */ + minimon_alarm_install(); return CARTRIDGE_VIC20_MINIMON; @@ -617,7 +707,10 @@ int minimon_bin_attach(const char *filename, uint8_t *rawcart) { + DBG(("minimon_bin_attach")); + allocate_rom(); + clear_eprom(); if (zfile_load(filename, minimon_rom, (size_t)CART_ROM_SIZE) < 0) { minimon_detach(); @@ -699,32 +792,6 @@ return -1; } -#if 0 -static int minimon_activate(void) -{ - minimon_bios_changed = 0; - /* mmc64_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_bios_filename); - } else { - ret = minimon_bin_save(minimon_bios_filename); - } - if (ret <= 0) { - return 0; /* FIXME */ - } - } - return 0; -} -#endif - int minimon_flush_image(void) { /* FIXME */ @@ -768,6 +835,7 @@ return set_minimon_enabled(0, (void*)1); /* setup the resource */ } + /* ------------------------------------------------------------------------- */ /* MINIMON snapshot module format: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <co...@us...> - 2025-05-12 05:23:28
|
Revision: 45672 http://sourceforge.net/p/vice-emu/code/45672 Author: compyx Date: 2025-05-12 05:23:26 +0000 (Mon, 12 May 2025) Log Message: ----------- Fix printf format specifier warning Modified Paths: -------------- trunk/vice/src/monitor/monitor_binary.c Modified: trunk/vice/src/monitor/monitor_binary.c =================================================================== --- trunk/vice/src/monitor/monitor_binary.c 2025-05-11 15:51:30 UTC (rev 45671) +++ trunk/vice/src/monitor/monitor_binary.c 2025-05-12 05:23:26 UTC (rev 45672) @@ -1497,7 +1497,7 @@ response_size = 4 + count * (item_size + 1); if (response_size > UINT32_MAX) { monitor_binary_error(e_MON_ERR_INVALID_PARAMETER, command->request_id); - log_message(LOG_DEFAULT, "monitor binary cpuhistory: Response too long %lu", response_size); + log_message(LOG_DEFAULT, "monitor binary cpuhistory: Response too long %"PRI_SIZE_T, response_size); return; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gp...@us...> - 2025-05-11 15:51:33
|
Revision: 45671 http://sourceforge.net/p/vice-emu/code/45671 Author: gpz Date: 2025-05-11 15:51:30 +0000 (Sun, 11 May 2025) Log Message: ----------- don't use g_memdup2 Modified Paths: -------------- trunk/vice/src/arch/gtk3/novte/table.cc Modified: trunk/vice/src/arch/gtk3/novte/table.cc =================================================================== --- trunk/vice/src/arch/gtk3/novte/table.cc 2025-05-11 14:22:41 UTC (rev 45670) +++ trunk/vice/src/arch/gtk3/novte/table.cc 2025-05-11 15:51:30 UTC (rev 45671) @@ -211,7 +211,7 @@ } table->handler = handler; g_free(table->original); - table->original = (unsigned char *) g_memdup2(original, original_length); + table->original = (unsigned char *) g_memdup(original, (guint)original_length); table->original_length = original_length; return; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gp...@us...> - 2025-05-11 14:22:44
|
Revision: 45670 http://sourceforge.net/p/vice-emu/code/45670 Author: gpz Date: 2025-05-11 14:22:41 +0000 (Sun, 11 May 2025) Log Message: ----------- test this yourself Modified Paths: -------------- trunk/vice/src/arch/gtk3/novte/vte.cc Modified: trunk/vice/src/arch/gtk3/novte/vte.cc =================================================================== --- trunk/vice/src/arch/gtk3/novte/vte.cc 2025-05-11 14:17:23 UTC (rev 45669) +++ trunk/vice/src/arch/gtk3/novte/vte.cc 2025-05-11 14:22:41 UTC (rev 45670) @@ -351,7 +351,7 @@ */ rect.x = (int)(column_start * (m_cell_width - 1)); /* The extra + 1 is for the faux-bold overdraw */ - int xend = (int)(((column_start + n_columns) * m_cell_width) + 1 + 1)); + int xend = (int)(((column_start + n_columns) * m_cell_width) + 1 + 1); rect.width = xend - rect.x; rect.y = (int)(row_to_pixel(row_start) - 1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gp...@us...> - 2025-05-11 14:17:26
|
Revision: 45669 http://sourceforge.net/p/vice-emu/code/45669 Author: gpz Date: 2025-05-11 14:17:23 +0000 (Sun, 11 May 2025) Log Message: ----------- recklessly sprinkle typecasts all over the novte stuff, this should remove those annoying warnings about 64 to 32 bit truncation. please tests this Modified Paths: -------------- trunk/vice/src/arch/gtk3/novte/iso2022.cc trunk/vice/src/arch/gtk3/novte/keymap.cc trunk/vice/src/arch/gtk3/novte/ring.cc trunk/vice/src/arch/gtk3/novte/table.cc trunk/vice/src/arch/gtk3/novte/vte.cc trunk/vice/src/arch/gtk3/novte/vteaccess.cc trunk/vice/src/arch/gtk3/novte/vteconv.cc trunk/vice/src/arch/gtk3/novte/vtedefines.hh trunk/vice/src/arch/gtk3/novte/vtedraw.cc trunk/vice/src/arch/gtk3/novte/vtegtk.cc trunk/vice/src/arch/gtk3/novte/vterowdata.cc trunk/vice/src/arch/gtk3/novte/vteseq.cc trunk/vice/src/arch/gtk3/novte/vtestream-file.h Modified: trunk/vice/src/arch/gtk3/novte/iso2022.cc =================================================================== --- trunk/vice/src/arch/gtk3/novte/iso2022.cc 2025-05-10 23:53:22 UTC (rev 45668) +++ trunk/vice/src/arch/gtk3/novte/iso2022.cc 2025-05-11 14:17:23 UTC (rev 45669) @@ -170,7 +170,7 @@ /* skip blanks -- TODOegmont: why here? */ j = gunichars->len; - g_array_set_size(gunichars, gunichars->len + outbuf-buf); + g_array_set_size(gunichars, (guint)(gunichars->len + (outbuf - buf))); for (i = 0; buf + i < outbuf; i++) { c = buf[i]; if (G_UNLIKELY (c == '\0')) { Modified: trunk/vice/src/arch/gtk3/novte/keymap.cc =================================================================== --- trunk/vice/src/arch/gtk3/novte/keymap.cc 2025-05-10 23:53:22 UTC (rev 45668) +++ trunk/vice/src/arch/gtk3/novte/keymap.cc 2025-05-11 14:17:23 UTC (rev 45669) @@ -943,7 +943,7 @@ char **normal, gssize *normal_length) { - int modifier, offset; + int modifier; ssize_t offset; char *nnormal; enum _vte_modifier_encoding_method modifier_encoding_method; guint significant_modifiers; Modified: trunk/vice/src/arch/gtk3/novte/ring.cc =================================================================== --- trunk/vice/src/arch/gtk3/novte/ring.cc 2025-05-10 23:53:22 UTC (rev 45668) +++ trunk/vice/src/arch/gtk3/novte/ring.cc 2025-05-11 14:17:23 UTC (rev 45669) @@ -1012,7 +1012,7 @@ if (position >= ring->end) { offset->text_offset = _vte_stream_head (ring->text_stream) + position - ring->end; offset->fragment_cells = 0; - offset->eol_cells = column; + offset->eol_cells = (gint)column; return TRUE; } @@ -1056,7 +1056,7 @@ for (i = 0, cell = row->cells; i < row->len && i < column; i++, cell++) { if (G_LIKELY (!cell->attr.fragment())) { if (G_UNLIKELY (i + cell->attr.columns() > column)) { - offset->fragment_cells = column - i; + offset->fragment_cells = (gint) (column - i); break; } num_chars += _vte_unistr_strlen(cell->c); @@ -1063,7 +1063,7 @@ } } if (i >= row->len) { - offset->eol_cells = column - i; + offset->eol_cells = (gint) (column - i); } /* count the number of UTF-8 bytes for the given number of characters */ @@ -1134,7 +1134,7 @@ /* row and buffer now contain the same text, in different representation */ /* count the number of characters for the given UTF-8 text offset */ - off = offset->text_offset - records[0].text_start_offset; + off = (unsigned int) (offset->text_offset - records[0].text_start_offset); num_chars = 0; for (i = 0; i < off && i < buffer->len; i++) { if ((buffer->str[i] & 0xC0) != 0x80) { @@ -1343,7 +1343,7 @@ if (paragraph_is_ascii) { /* Shortcut for quickly wrapping ASCII (excluding TAB) text. Don't read text_stream, and advance by a whole row of characters. */ - int len = MIN(runlength, (gsize) (columns - col)); + ssize_t len = MIN(runlength, (gsize) (columns - col)); col += len; text_offset += len; paragraph_len -= len; @@ -1351,7 +1351,7 @@ } else { /* Process one character only. */ char textbuf[6]; /* fits at least one UTF-8 character */ - int textbuf_len; + ssize_t textbuf_len; col += attr_change.attr.columns(); /* Find beginning of next UTF-8 character */ text_offset++; paragraph_len--; runlength--; Modified: trunk/vice/src/arch/gtk3/novte/table.cc =================================================================== --- trunk/vice/src/arch/gtk3/novte/table.cc 2025-05-10 23:53:22 UTC (rev 45668) +++ trunk/vice/src/arch/gtk3/novte/table.cc 2025-05-11 14:17:23 UTC (rev 45669) @@ -94,7 +94,7 @@ info = head->list; head->list = last->next; if (last >= &head->stack[0] && last < &head->stack[G_N_ELEMENTS(head->stack)]){ - head->stack_allocated = last - &head->stack[0]; + head->stack_allocated = (guint) (last - &head->stack[0]); /* FIXME */ } do { struct _vte_table_arginfo *next = info->next; @@ -211,7 +211,7 @@ } table->handler = handler; g_free(table->original); - table->original = (unsigned char *) g_memdup(original, original_length); + table->original = (unsigned char *) g_memdup2(original, original_length); table->original_length = original_length; return; } @@ -242,11 +242,11 @@ int initial; GByteArray *b; - initial = original_length - length; + initial = (int) (original_length - length); /* FIXME */ b = g_byte_array_new(); g_byte_array_set_size(b, 0); g_byte_array_append(b, original, initial); - g_byte_array_append(b, (const guint8*)pattern + 2, length - 2); + g_byte_array_append(b, (const guint8*)pattern + 2, (guint)(length - 2)); _vte_table_addi(table, b->data, b->len, (const char *)b->data + initial, b->len - initial, handler); g_byte_array_free(b, TRUE); Modified: trunk/vice/src/arch/gtk3/novte/vte.cc =================================================================== --- trunk/vice/src/arch/gtk3/novte/vte.cc 2025-05-10 23:53:22 UTC (rev 45668) +++ trunk/vice/src/arch/gtk3/novte/vte.cc 2025-05-11 14:17:23 UTC (rev 45669) @@ -349,13 +349,13 @@ * by multiplying by the size of a character cell. * Always include the extra pixel border and overlap pixel. */ - rect.x = column_start * m_cell_width - 1; + rect.x = (int)(column_start * (m_cell_width - 1)); /* The extra + 1 is for the faux-bold overdraw */ - int xend = (column_start + n_columns) * m_cell_width + 1 + 1; + int xend = (int)(((column_start + n_columns) * m_cell_width) + 1 + 1)); rect.width = xend - rect.x; - rect.y = row_to_pixel(row_start) - 1; - int yend = row_to_pixel(row_start + n_rows) + 1; + rect.y = (int)(row_to_pixel(row_start) - 1); + int yend = (int)(row_to_pixel(row_start + n_rows) + 1); rect.height = yend - rect.y; _vte_debug_print (VTE_DEBUG_UPDATES, "Invalidating pixels at (%d,%d)x(%d,%d).\n", @@ -385,11 +385,11 @@ bool block) { if (block || srow == erow) { - invalidate_cells(scolumn, ecolumn - scolumn + 1, srow, erow - srow + 1); + invalidate_cells(scolumn, (int)(ecolumn - scolumn + 1), srow, (int)(erow - srow + 1)); } else { - invalidate_cells(scolumn, m_column_count - scolumn, srow, 1); - invalidate_cells(0, m_column_count, srow + 1, erow - srow - 1); - invalidate_cells(0, ecolumn + 1, erow, 1); + invalidate_cells(scolumn, (int)(m_column_count - scolumn), srow, 1); + invalidate_cells(0, (int)m_column_count, srow + 1, (int)(erow - srow - 1)); + invalidate_cells(0, (int)ecolumn + 1, erow, 1); } } @@ -450,8 +450,8 @@ /* We have to repaint the area which is to be * scrolled. */ invalidate_cells( - 0, m_column_count, - row, count); + 0, (int)m_column_count, + row, (int)count); } } @@ -607,7 +607,7 @@ if (cell->c != 0) { int right; _vte_draw_get_char_edges(m_draw, cell->c, columns, style, NULL, &right); - columns = MAX(columns, howmany(right, m_cell_width)); + columns = MAX(columns, howmany(right, ((int)m_cell_width))); } } } @@ -647,7 +647,7 @@ auto style = _vte_draw_get_style(cell->attr.bold(), cell->attr.italic()); if (cell->c != 0) { int right; - _vte_draw_get_char_edges(m_draw, cell->c, columns, style, NULL, &right); + _vte_draw_get_char_edges(m_draw, cell->c, (int)columns, style, NULL, &right); columns = MAX(columns, howmany(right, m_cell_width)); } } @@ -658,7 +658,7 @@ _vte_debug_print(VTE_DEBUG_UPDATES, "Invalidating cursor at (%ld,%ld-%ld).\n", row, column, column + columns); - invalidate_cells(column, columns, row, 1); + invalidate_cells(column, (int)columns, row, 1); } } @@ -870,10 +870,10 @@ emit_selection_changed(); - sx = m_selection_start.col; - sy = m_selection_start.row; - ex = m_selection_end.col; - ey = m_selection_end.row; + sx = (gint)m_selection_start.col; + sy = (gint)m_selection_start.row; + ex = (gint)m_selection_end.col; + ey = (gint)m_selection_end.row; extra = m_selection_block_mode ? (VTE_TAB_WIDTH_MAX - 1) : 0; invalidate_region(MIN (sx, ex), MAX (sx, ex) + extra, MIN (sy, ey), MAX (sy, ey), @@ -1102,7 +1102,7 @@ return NULL; } - _vte_ring_get_hyperlink_at_position(m_screen->row_data, row, col, false, &hyperlink); + _vte_ring_get_hyperlink_at_position(m_screen->row_data, row, (int)col, false, &hyperlink); if (hyperlink != NULL) { /* URI is after the first semicolon */ @@ -1374,7 +1374,7 @@ NULL); if (obuf2 != NULL) { _vte_byte_array_clear(m_outgoing); - _vte_byte_array_append(m_outgoing, obuf2, bytes_written); + _vte_byte_array_append(m_outgoing, obuf2, (guint)bytes_written); g_free(obuf2); } g_free(obuf1); @@ -1427,9 +1427,9 @@ /* Figure out how many rows we need to add. */ //FIXMEchpe use long, not int - int delta = m_screen->cursor.row - _vte_ring_next(m_screen->row_data) + 1; + ssize_t delta = m_screen->cursor.row - _vte_ring_next(m_screen->row_data) + 1; if (delta > 0) { - row = insert_rows(delta); + row = insert_rows((int)delta); adjust_adjustments(); } else { /* Find the row the cursor is in. */ @@ -1457,7 +1457,7 @@ auto rows = _vte_ring_next(m_screen->row_data); auto delta = m_screen->cursor.row - rows + 1; if (G_UNLIKELY (delta > 0)) { - insert_rows(delta); + insert_rows((guint)delta); rows = _vte_ring_next(m_screen->row_data); } @@ -1671,7 +1671,7 @@ color.red += 0x3fff; } } else if (i < 232) { - int j = i - 16; + int j = (int)(i - 16); int r = j / 36, g = (j / 6) % 6, b = j % 6; int red = (r == 0) ? 0 : r * 40 + 55; int green = (g == 0) ? 0 : g * 40 + 55; @@ -1680,7 +1680,7 @@ color.green = green | green << 8; color.blue = blue | blue << 8; } else if (i < 256) { - int shade = 8 + (i - 232) * 10; + int shade = (int)(8 + (i - 232) * 10); color.red = color.green = color.blue = shade | shade << 8; } else switch (i) { case VTE_DEFAULT_BG: @@ -1725,9 +1725,9 @@ /* Set up the color entry. */ if (unset) { - reset_color(i, VTE_COLOR_SOURCE_API); + reset_color((int)i, VTE_COLOR_SOURCE_API); } else { - set_color(i, VTE_COLOR_SOURCE_API, color); + set_color((int)i, VTE_COLOR_SOURCE_API, color); } } } @@ -1932,7 +1932,7 @@ cell_end->c = '\t'; cell_end->attr.set_fragment(false); g_assert(cell_col->attr.columns() > end - col); - cell_end->attr.set_columns(cell_col->attr.columns() - (end - col)); + cell_end->attr.set_columns((int)(cell_col->attr.columns() - (end - col))); } else { _vte_debug_print(VTE_DEBUG_MISC, "Cleaning CJK right half at %ld\n", @@ -2014,7 +2014,7 @@ ring_insert(end, true); /* Update the display. */ scroll_region(start, end - start + 1, -1); - invalidate_cells(0, m_column_count, end - 2, 2); + invalidate_cells(0, (int)m_column_count, end - 2, 2); } } else { /* Scroll up with history. */ @@ -2293,7 +2293,7 @@ /* Signal that this part of the window needs drawing. */ if (G_UNLIKELY (invalidate_now)) { invalidate_cells(col - columns, - insert ? m_column_count : columns, + insert ? (int)m_column_count : columns, m_screen->cursor.row, 1); } @@ -2383,7 +2383,7 @@ if (G_UNLIKELY (processed != chunk->len)) { /* shuffle the data about */ g_memmove (chunk->data, chunk->data + processed, chunk->len - processed); - chunk->len = chunk->len - processed; + chunk->len = (guint)(chunk->len - processed); processed = sizeof (chunk->data) - chunk->len; if (processed != 0 && next_chunk != NULL) { if (next_chunk->len <= processed) { @@ -2492,10 +2492,10 @@ m_screen->cursor.row < bbox_topleft.y - VTE_CELL_BBOX_SLACK))) { /* Clip off any part of the box which isn't already on-screen. */ bbox_topleft.x = MAX(bbox_topleft.x, 0); - bbox_topleft.y = MAX(bbox_topleft.y, top_row); - bbox_bottomright.x = MIN(bbox_bottomright.x, m_column_count); + bbox_topleft.y = MAX(bbox_topleft.y, ((int)top_row)); + bbox_bottomright.x = MIN(bbox_bottomright.x, ((gint)m_column_count)); /* lazily apply the +1 to the cursor_row */ - bbox_bottomright.y = MIN(bbox_bottomright.y + 1, bottom_row + 1); + bbox_bottomright.y = MIN(bbox_bottomright.y + 1, ((gint)(bottom_row + 1))); invalidate_cells(bbox_topleft.x, bbox_bottomright.x - bbox_topleft.x, @@ -2521,10 +2521,10 @@ if ((c != *next) && ((*next & 0x1f) == *next) && //FIXMEchpe what about C1 controls - (start + 1 < next - wbuf)) { + ((start + 1) < (next - wbuf))) { const gunichar *tnext = NULL; gunichar ctrl; - int i; + ptrdiff_t i; /* We don't want to permute it if it's another * control sequence, so check if it is. */ sequence_handler_t thandler; @@ -2536,13 +2536,13 @@ NULL); /* We only do this for non-control-sequence * characters and random garbage. */ - if (tnext == next + 1) { + if (tnext == (next + 1)) { /* Save the control character. */ ctrl = *next; /* Move everything before it up a * slot. */ /* FIXMEchpe memmove! */ - for (i = next - wbuf; i > start; i--) { + for (i = (next - wbuf); i > start; i--) { wbuf[i] = wbuf[i - 1]; } /* Move the control character to the @@ -2566,8 +2566,8 @@ } } - bbox_topleft.x = MIN(bbox_topleft.x, m_screen->cursor.col); - bbox_topleft.y = MIN(bbox_topleft.y, m_screen->cursor.row); + bbox_topleft.x = MIN(bbox_topleft.x, ((gint)m_screen->cursor.col)); + bbox_topleft.y = MIN(bbox_topleft.y, ((int)m_screen->cursor.row)); /* Insert the character. */ /* FIXMEchpe should not use UNLIKELY here */ @@ -2580,10 +2580,10 @@ m_screen->cursor.row < bbox_topleft.y - VTE_CELL_BBOX_SLACK)) { /* Clip off any part of the box which isn't already on-screen. */ bbox_topleft.x = MAX(bbox_topleft.x, 0); - bbox_topleft.y = MAX(bbox_topleft.y, top_row); - bbox_bottomright.x = MIN(bbox_bottomright.x, m_column_count); + bbox_topleft.y = MAX(bbox_topleft.y, ((gint)top_row)); + bbox_bottomright.x = MIN(bbox_bottomright.x, ((gint)m_column_count)); /* lazily apply the +1 to the cursor_row */ - bbox_bottomright.y = MIN(bbox_bottomright.y + 1, bottom_row + 1); + bbox_bottomright.y = MIN(bbox_bottomright.y + 1, ((gint)(bottom_row + 1))); invalidate_cells(bbox_topleft.x, bbox_bottomright.x - bbox_topleft.x, @@ -2593,13 +2593,13 @@ bbox_topleft.x = bbox_topleft.y = G_MAXINT; } bbox_topleft.x = MIN(bbox_topleft.x, 0); - bbox_topleft.y = MIN(bbox_topleft.y, m_screen->cursor.row); + bbox_topleft.y = MIN(bbox_topleft.y, ((int)m_screen->cursor.row)); } /* Add the cells over which we have moved to the region * which we need to refresh for the user. */ - bbox_bottomright.x = MAX(bbox_bottomright.x, m_screen->cursor.col); + bbox_bottomright.x = MAX(bbox_bottomright.x, ((int)m_screen->cursor.col)); /* cursor.row + 1 (defer until inv.) */ - bbox_bottomright.y = MAX(bbox_bottomright.y, m_screen->cursor.row); + bbox_bottomright.y = MAX(bbox_bottomright.y, ((int)m_screen->cursor.row)); invalidated_text = TRUE; /* We *don't* emit flush pending signals here. */ @@ -2614,7 +2614,7 @@ * data to consult. If we have data following the * middle of the sequence, then it's just garbage data, * and for compatibility, we should discard it. */ - if (wbuf + wcount > next) { + if ((wbuf + wcount) > next) { _vte_debug_print(VTE_DEBUG_PARSE, "Invalid control " "sequence, discarding %ld " @@ -2649,7 +2649,7 @@ /* Remove most of the processed characters. */ if (start < wcount) { - g_array_remove_range(m_pending, 0, start); + g_array_remove_range(m_pending, 0, (guint)start); } else { g_array_set_size(m_pending, 0); /* If we're out of data, we needn't pause to let the @@ -2690,10 +2690,10 @@ if (invalidated_text) { /* Clip off any part of the box which isn't already on-screen. */ bbox_topleft.x = MAX(bbox_topleft.x, 0); - bbox_topleft.y = MAX(bbox_topleft.y, top_row); - bbox_bottomright.x = MIN(bbox_bottomright.x, m_column_count); + bbox_topleft.y = MAX(bbox_topleft.y, ((gint)top_row)); + bbox_bottomright.x = MIN(bbox_bottomright.x, (gint)m_column_count); /* lazily apply the +1 to the cursor_row */ - bbox_bottomright.y = MIN(bbox_bottomright.y + 1, bottom_row + 1); + bbox_bottomright.y = MIN(bbox_bottomright.y + 1, ((gint)bottom_row + 1)); invalidate_cells(bbox_topleft.x, bbox_bottomright.x - bbox_topleft.x, @@ -2948,11 +2948,11 @@ } cairo_rectangle_int_t rect; - rect.x = m_screen->cursor.col * m_cell_width + m_padding.left + - get_preedit_width(false) * m_cell_width; - rect.width = m_cell_width; /* FIXMEchpe: if columns > 1 ? */ - rect.y = row_to_pixel(m_screen->cursor.row) + m_padding.top; - rect.height = m_cell_height; + rect.x = (int)(m_screen->cursor.col * m_cell_width + m_padding.left + + get_preedit_width(false) * m_cell_width); + rect.width = (int)m_cell_width; /* FIXMEchpe: if columns > 1 ? */ + rect.y = (int)(row_to_pixel(m_screen->cursor.row) + m_padding.top); + rect.height = (int)m_cell_height; gtk_im_context_set_cursor_location(m_im_context, &rect); } @@ -4042,10 +4042,10 @@ g_assert (top != LONG_MAX && bottom != -1 && left != LONG_MAX && right != -1); auto allocation = get_allocated_rect(); - bbox->x = allocation.x + m_padding.left + left * m_cell_width; - bbox->y = allocation.y + m_padding.top + row_to_pixel(top); - bbox->width = (right - left + 1) * m_cell_width; - bbox->height = (bottom - top + 1) * m_cell_height; + bbox->x = (int)(allocation.x + m_padding.left + left * m_cell_width); + bbox->y = (int)(allocation.y + m_padding.top + row_to_pixel(top)); + bbox->width = (int)((right - left + 1) * m_cell_width); + bbox->height = (int)((bottom - top + 1) * m_cell_height); _vte_debug_print (VTE_DEBUG_HYPERLINK, "Hyperlink bounding box: x=%d y=%d w=%d h=%d\n", bbox->x, bbox->y, bbox->width, bbox->height); @@ -4104,7 +4104,7 @@ * the pseudo idx VTE_HYPERLINK_IDX_TARGET_IN_STREAM and now a real idx is allocated. * Plus, the ring's internal belief of the hovered hyperlink is also updated. */ if (do_check_hilite) { - m_hyperlink_hover_idx = _vte_ring_get_hyperlink_at_position(m_screen->row_data, rowcol.row(), rowcol.column(), true, &m_hyperlink_hover_uri); + m_hyperlink_hover_idx = _vte_ring_get_hyperlink_at_position(m_screen->row_data, rowcol.row(), (int)rowcol.column(), true, &m_hyperlink_hover_uri); } else { m_hyperlink_hover_idx = 0; m_hyperlink_hover_uri = nullptr; @@ -4229,7 +4229,7 @@ if (info == VTE_TARGET_TEXT) { gtk_selection_data_set_text(data, m_selection[sel]->str, - m_selection[sel]->len); + (gint)m_selection[sel]->len); } else if (info == VTE_TARGET_HTML) { gsize len; auto selection = text_to_utf16_mozilla(m_selection[sel], &len); @@ -4239,7 +4239,7 @@ gdk_atom_intern_static_string("text/html"), 16, (const guchar *)selection, - len); + (gint)len); } g_free(selection); } else { @@ -4361,7 +4361,7 @@ * attributes, one per byte. */ if (attributes) { vte_g_array_fill(attributes, - &attr, string->len); + &attr, (guint)(string->len)); } } @@ -4392,7 +4392,7 @@ if (pcell == NULL) { g_string_truncate(string, last_nonempty); if (attributes) { - g_array_set_size(attributes, string->len); + g_array_set_size(attributes, (guint)string->len); } attr.column = last_nonemptycol; } @@ -4418,7 +4418,7 @@ /* Make sure that the attributes array is as long as the string. */ if (attributes) { - vte_g_array_fill (attributes, &attr, string->len); + vte_g_array_fill (attributes, &attr, (guint)(string->len)); } } @@ -5768,9 +5768,9 @@ case GDK_MOTION_NOTIFY: if (m_selecting_after_threshold) { if (!gtk_drag_check_threshold (m_widget, - m_mouse_last_position.x, - m_mouse_last_position.y, - pos.x, pos.y)) { + (gint)m_mouse_last_position.x, + (gint)m_mouse_last_position.y, + (gint)pos.x, (gint)pos.y)) { return true; } @@ -6192,7 +6192,7 @@ } /* Emit a signal that the font changed. */ if (cresize) { - emit_char_size_changed(m_cell_width, m_cell_height); + emit_char_size_changed((int)m_cell_width, (int)m_cell_height); } /* Repaint. */ invalidate_all(); @@ -6428,7 +6428,7 @@ drop3 = old_top_lines - new_top_lines; drop = MIN(MIN(drop1, drop2), drop3); if (drop > 0) { - int new_ring_next = screen_->insert_delta + m_row_count - drop; + long new_ring_next = screen_->insert_delta + m_row_count - drop; _vte_debug_print(VTE_DEBUG_RESIZE, "Dropping %ld [== MIN(%ld, %ld, %ld)] rows at the bottom\n", drop, drop1, drop2, drop3); @@ -6814,13 +6814,11 @@ #if 0 refresh_size(); /* FIXME */ #endif - *minimum_width = m_cell_width * 1; - *natural_width = m_cell_width * m_column_count; + *minimum_width = (int)(m_cell_width * 1); + *natural_width = (int)(m_cell_width * m_column_count); - *minimum_width += m_padding.left + - m_padding.right; - *natural_width += m_padding.left + - m_padding.right; + *minimum_width += (int)(m_padding.left + m_padding.right); + *natural_width += (int)(m_padding.left + m_padding.right); _vte_debug_print(VTE_DEBUG_WIDGET_SIZE, "[Terminal %p] minimum_width=%d, natural_width=%d for %ldx%ld cells (padding %d,%d;%d,%d).\n", @@ -6842,13 +6840,11 @@ refresh_size(); /* FIXME */ #endif - *minimum_height = m_cell_height * 1; - *natural_height = m_cell_height * m_row_count; + *minimum_height = (int)(m_cell_height * 1); + *natural_height = (int)(m_cell_height * m_row_count); - *minimum_height += m_padding.top + - m_padding.bottom; - *natural_height += m_padding.top + - m_padding.bottom; + *minimum_height += m_padding.top + m_padding.bottom; + *natural_height += m_padding.top + m_padding.bottom; _vte_debug_print(VTE_DEBUG_WIDGET_SIZE, "[Terminal %p] minimum_height=%d, natural_height=%d for %ldx%ld cells (padding %d,%d;%d,%d).\n", @@ -7106,7 +7102,7 @@ * and also put text/html on if it's VTE_FORMAT_HTML */ gtk_clipboard_set_text(m_clipboard[sel], m_selection[sel]->str, - m_selection[sel]->len); + (gint)(m_selection[sel]->len)); } g_string_free(m_selection[sel], TRUE); m_selection[sel] = nullptr; @@ -7509,9 +7505,9 @@ case 1: _vte_draw_draw_line(m_draw, x, - y + m_underline_position, + (int)(y + m_underline_position), x + (columns * column_width) - 1, - y + m_underline_position + m_underline_thickness - 1, + (int)(y + m_underline_position + m_underline_thickness - 1), VTE_LINE_WIDTH, &dc, VTE_DRAW_OPAQUE); break; @@ -7518,16 +7514,16 @@ case 2: _vte_draw_draw_line(m_draw, x, - y + m_double_underline_position, + (int)(y + m_double_underline_position), x + (columns * column_width) - 1, - y + m_double_underline_position + m_double_underline_thickness - 1, + (int)(y + m_double_underline_position + m_double_underline_thickness - 1), VTE_LINE_WIDTH, &dc, VTE_DRAW_OPAQUE); _vte_draw_draw_line(m_draw, x, - y + m_double_underline_position + 2 * m_double_underline_thickness, + (int)(y + m_double_underline_position + 2 * m_double_underline_thickness), x + (columns * column_width) - 1, - y + m_double_underline_position + 3 * m_double_underline_thickness - 1, + (int)(y + m_double_underline_position + 3 * m_double_underline_thickness - 1), VTE_LINE_WIDTH, &dc, VTE_DRAW_OPAQUE); break; @@ -7543,9 +7539,9 @@ if (attr & VTE_ATTR_STRIKETHROUGH) { _vte_draw_draw_line(m_draw, x, - y + m_strikethrough_position, + (int)(y + m_strikethrough_position), x + (columns * column_width) - 1, - y + m_strikethrough_position + m_strikethrough_thickness - 1, + (int)(y + m_strikethrough_position + m_strikethrough_thickness - 1), VTE_LINE_WIDTH, &fg, VTE_DRAW_OPAQUE); } @@ -7552,9 +7548,9 @@ if (attr & VTE_ATTR_OVERLINE) { _vte_draw_draw_line(m_draw, x, - y + m_overline_position, + (int)(y + m_overline_position), x + (columns * column_width) - 1, - y + m_overline_position + m_overline_thickness - 1, + (int)(y + m_overline_position + m_overline_thickness - 1), VTE_LINE_WIDTH, &fg, VTE_DRAW_OPAQUE); } @@ -7561,9 +7557,9 @@ if (hilite) { _vte_draw_draw_line(m_draw, x, - y + m_regex_underline_position, + (int)(y + m_regex_underline_position), x + (columns * column_width) - 1, - y + m_regex_underline_position + m_regex_underline_thickness - 1, + (int)(y + m_regex_underline_position + m_regex_underline_thickness - 1), VTE_LINE_WIDTH, &fg, VTE_DRAW_OPAQUE); } else if (hyperlink) { @@ -7570,9 +7566,9 @@ for (double j = 1.0 / 6.0; j < columns; j += 0.5) { _vte_draw_fill_rectangle(m_draw, x + j * column_width, - y + m_regex_underline_position, + (int)(y + m_regex_underline_position), MAX(column_width / 6.0, 1.0), - m_regex_underline_thickness, + (int)(m_regex_underline_thickness), &fg, VTE_DRAW_OPAQUE); } } @@ -7609,7 +7605,7 @@ for (i = 0; i < n; i++) { gchar ubuf[7]; gint len = g_unichar_to_utf8 (cells[i].c, ubuf); - props[i].index = sumlen; + props[i].index = (guint)sumlen; props[i].saw_fg = props[i].saw_bg = FALSE; sumlen += len; } @@ -7943,9 +7939,9 @@ rgb_from_index<8, 8, 8>(back, bg); _vte_draw_fill_rectangle ( m_draw, - x + i * column_width, - y, - (j - i) * column_width + bold_offset, + (int)(x + i * column_width), + (int)y, + (gint)((j - i) * column_width + bold_offset), row_height, &bg, VTE_DRAW_OPAQUE); } @@ -7969,9 +7965,9 @@ vte::color::rgb bg; rgb_from_index<8, 8, 8>(back, bg); _vte_draw_fill_rectangle (m_draw, - x + i *column_width, - y, - (j - i) * column_width, + (int)(x + i * column_width), + (int)y, + (int)((j - i) * column_width), row_height, &bg, VTE_DRAW_OPAQUE); } @@ -8183,10 +8179,10 @@ #if VTE_DEBUG cairo_rectangle_int_t old_rect = rect; #endif - rect.x = col * m_cell_width; - rect.width = (col_stop - col) * m_cell_width; - rect.y = row_to_pixel(row); - rect.height = (row_stop - row) * m_cell_height; + rect.x = (int)(col * m_cell_width); + rect.width = (int)((col_stop - col) * m_cell_width); + rect.y = (int)row_to_pixel(row); + rect.height = (int)((row_stop - row) * m_cell_height); _vte_debug_print (VTE_DEBUG_UPDATES, "expand_rectangle" @@ -8235,10 +8231,10 @@ draw_rows(m_screen, row, row_stop, col, col_stop, - col * m_cell_width, - row_to_pixel(row), - m_cell_width, - m_cell_height); + (gint)(col * m_cell_width), + (gint)row_to_pixel(row), + (gint)m_cell_width, + (gint)m_cell_height); } void VteTerminalPrivate::paint_cursor() @@ -8263,8 +8259,8 @@ col = m_screen->cursor.col; drow = m_screen->cursor.row; - width = m_cell_width; - height = m_cell_height; + width = (int)m_cell_width; + height = (int)m_cell_height; /* TODOegmont: clamp on rows? tricky... */ if (CLAMP(col, 0, m_column_count - 1) != col) { @@ -8316,10 +8312,11 @@ int stem_width; stem_width = (int) (((float) (m_char_ascent + m_char_descent)) * m_cursor_aspect_ratio + 0.5); - stem_width = CLAMP (stem_width, VTE_LINE_WIDTH, m_cell_width); + stem_width = CLAMP (stem_width, VTE_LINE_WIDTH, (int)m_cell_width); _vte_draw_fill_rectangle(m_draw, - x, y + m_char_padding.top, stem_width, m_char_ascent + m_char_descent, + x, y + m_char_padding.top, stem_width, + (int)(m_char_ascent + m_char_descent), &bg, VTE_DRAW_OPAQUE); break; } @@ -8337,10 +8334,10 @@ /* use height (not width) so underline and ibeam will * be equally visible */ line_height = (int) (((float) (m_char_ascent + m_char_descent)) * m_cursor_aspect_ratio + 0.5); - line_height = CLAMP (line_height, VTE_LINE_WIDTH, m_char_ascent + m_char_descent); + line_height = CLAMP (line_height, VTE_LINE_WIDTH, (int)(m_char_ascent + m_char_descent)); left = m_char_padding.left; - right = item.columns * m_cell_width - m_char_padding.right; + right = (int)(item.columns * m_cell_width - m_char_padding.right); if (cell && cell->c != 0 && cell->c != ' ' && cell->c != '\t') { int l, r; @@ -8350,7 +8347,8 @@ } _vte_draw_fill_rectangle(m_draw, - x + left, y + m_cell_height - m_char_padding.bottom - line_height, + x + left, + (gint)(y + m_cell_height - m_char_padding.bottom - line_height), right - left, line_height, &bg, VTE_DRAW_OPAQUE); break; @@ -8413,14 +8411,14 @@ height = m_cell_height; /* Find out how many columns the pre-edit string takes up. */ - columns = get_preedit_width(false); - len = get_preedit_length(false); + columns = (int)get_preedit_width(false); + len = (int)get_preedit_length(false); /* If the pre-edit string won't fit on the screen if we start * drawing it at the cursor's position, move it left. */ - col = m_screen->cursor.col; + col = (int)(m_screen->cursor.col); if (col + columns > m_column_count) { - col = MAX(0, m_column_count - columns); + col = MAX(0, (int)(m_column_count - columns)); } /* Draw the preedit string, boxed. */ @@ -8440,10 +8438,10 @@ } if (G_LIKELY(m_clear_background)) { _vte_draw_clear(m_draw, - col * width, - row_to_pixel(m_screen->cursor.row), - width * columns, - height, + (int)(col * width), + (gint)row_to_pixel(m_screen->cursor.row), + (int)(width * columns), + (int)height, get_color(VTE_DEFAULT_BG), m_background_alpha); } draw_cells_with_attributes( @@ -8450,7 +8448,7 @@ items, len, m_im_preedit_attrs, TRUE, - width, height); + (int)width, (int)height); preedit_cursor = m_im_preedit_cursor; if (preedit_cursor >= 0 && preedit_cursor < len) { @@ -8466,7 +8464,7 @@ VTE_ATTR_NONE | VTE_ATTR_BOXED, FALSE, /* hyperlink */ FALSE, /* hilite */ - width, height); + (int)width, (int)height); } g_free(items); } @@ -8496,8 +8494,8 @@ return; } - allocated_width = get_allocated_width(); - allocated_height = get_allocated_height(); + allocated_width = (int)get_allocated_width(); + allocated_height = (int)get_allocated_height(); /* Designate the start of the drawing operation and clear the area. */ _vte_draw_set_cairo(m_draw, cr); Modified: trunk/vice/src/arch/gtk3/novte/vteaccess.cc =================================================================== --- trunk/vice/src/arch/gtk3/novte/vteaccess.cc 2025-05-10 23:53:22 UTC (rev 45668) +++ trunk/vice/src/arch/gtk3/novte/vteaccess.cc 2025-05-11 14:17:23 UTC (rev 45669) @@ -200,7 +200,7 @@ char *next; long row, offset, caret; long ccol, crow; - guint i; + long i; /* If nothing's changed, just return immediately. */ if ((priv->snapshot_contents_invalid == FALSE) && @@ -290,7 +290,7 @@ if (next == NULL) { break; } else { - i = next - priv->snapshot_text->str; + i = (int)(next - priv->snapshot_text->str); } } /* Find offsets for the beginning of lines. */ @@ -341,7 +341,7 @@ /* Make a note that we'll need to notify observers if the caret moved. * But only notify them after sending text-changed. */ if (caret != priv->snapshot_caret) { - priv->snapshot_caret = caret; + priv->snapshot_caret = (gint)caret; priv->text_caret_moved_pending = TRUE; } @@ -476,7 +476,7 @@ VteTerminalAccessiblePrivate *priv = (VteTerminalAccessiblePrivate *)_vte_terminal_accessible_get_instance_private(accessible); struct _VteCharAttributes attr; long delta, row_count; - guint i, len; + long i, len; /* TODOegmont: Fix this for smooth scrolling */ /* g_assert(howmuch != 0); */ @@ -777,7 +777,7 @@ { VteTerminalAccessible *accessible = VTE_TERMINAL_ACCESSIBLE(text); VteTerminalAccessiblePrivate *priv = (VteTerminalAccessiblePrivate *)_vte_terminal_accessible_get_instance_private(accessible); - int start, end; + ssize_t start, end; gchar *ret; g_assert(VTE_IS_TERMINAL_ACCESSIBLE(accessible)); @@ -1262,8 +1262,8 @@ cell_height = novte_terminal_get_char_height (terminal); *x *= cell_width; *y *= cell_height; - *width = cell_width; - *height = cell_height; + *width = (gint)cell_width; + *height = (gint)cell_height; *x += base_x; *y += base_y; } @@ -1344,8 +1344,8 @@ auto start_sel = impl->m_selection_start; auto end_sel = impl->m_selection_end; - *start_offset = offset_from_xy (priv, start_sel.col, start_sel.row); - *end_offset = offset_from_xy (priv, end_sel.col, end_sel.row); + *start_offset = offset_from_xy (priv, (gint)start_sel.col, (gint)start_sel.row); + *end_offset = offset_from_xy (priv, (gint)end_sel.col, (gint)end_sel.row); return g_strdup(impl->m_selection[VTE_SELECTION_PRIMARY]->str); } Modified: trunk/vice/src/arch/gtk3/novte/vteconv.cc =================================================================== --- trunk/vice/src/arch/gtk3/novte/vteconv.cc 2025-05-10 23:53:22 UTC (rev 45668) +++ trunk/vice/src/arch/gtk3/novte/vteconv.cc 2025-05-11 14:17:23 UTC (rev 45669) @@ -253,7 +253,7 @@ /* Possibly convert the input data from gunichars to UTF-8. */ if (converter->in_unichar) { - int i, char_count; + int i; gulong char_count; guchar *p, *end; gunichar *g; @@ -324,7 +324,7 @@ /* Possibly convert the output from UTF-8 to gunichars. */ if (converter->out_unichar) { - int left = *outbytes_left; + gulong left = *outbytes_left; gunichar *g; gchar *p; Modified: trunk/vice/src/arch/gtk3/novte/vtedefines.hh =================================================================== --- trunk/vice/src/arch/gtk3/novte/vtedefines.hh 2025-05-10 23:53:22 UTC (rev 45668) +++ trunk/vice/src/arch/gtk3/novte/vtedefines.hh 2025-05-11 14:17:23 UTC (rev 45669) @@ -57,11 +57,11 @@ #define VTE_COLOR_PLAIN_OFFSET 0 #define VTE_COLOR_BRIGHT_OFFSET 8 #define VTE_DIM_COLOR (1U << 10) -#define VTE_RGB_COLOR_MASK(rb,gb,bb) (1U << ((rb) + (gb) + (bb))) -#define VTE_RGB_COLOR(bb,gb,rb,r,g,b) (VTE_RGB_COLOR_MASK(rb,gb,bb) | \ +#define VTE_RGB_COLOR_MASK(rb,gb,bb) ((uint32_t)(1U << ((rb) + (gb) + (bb)))) +#define VTE_RGB_COLOR(bb,gb,rb,r,g,b) ((uint32_t)(VTE_RGB_COLOR_MASK(rb,gb,bb) | \ ((((r) >> (8 - (rb))) & ((1U << (rb)) - 1U)) << ((gb) + (bb))) | \ ((((g) >> (8 - (gb))) & ((1U << (gb)) - 1U)) << (bb)) | \ - (((b) >> (8 - (bb))) & ((1U << (bb)) - 1U))) + (((b) >> (8 - (bb))) & ((1U << (bb)) - 1U)))) #define VTE_RGB_COLOR_GET_COMPONENT(packed,shift,bits) \ ((((packed) >> (shift)) & ((1U << (bits)) - 1U)) << (8 - bits) | ((1U << (8 - bits)) >> 1)) Modified: trunk/vice/src/arch/gtk3/novte/vtedraw.cc =================================================================== --- trunk/vice/src/arch/gtk3/novte/vtedraw.cc 2025-05-10 23:53:22 UTC (rev 45668) +++ trunk/vice/src/arch/gtk3/novte/vtedraw.cc 2025-05-11 14:17:23 UTC (rev 45669) @@ -565,7 +565,7 @@ { return pango_units_from_double (pango_cairo_context_get_resolution (context)) ^ pango_font_description_hash (pango_context_get_font_description (context)) - ^ cairo_font_options_hash (pango_cairo_context_get_font_options (context)) + ^ (guint)cairo_font_options_hash (pango_cairo_context_get_font_options (context)) ^ GPOINTER_TO_UINT (pango_context_get_language (context)) ^ vte_pango_context_get_fontconfig_timestamp (context); } @@ -677,7 +677,7 @@ g_string_set_size (info->string, 0); _vte_unistr_append_to_string (c, info->string); - pango_layout_set_text (info->layout, info->string->str, info->string->len); + pango_layout_set_text (info->layout, info->string->str, (int)info->string->len); pango_layout_get_extents (info->layout, NULL, &logical); uinfo->width = PANGO_PIXELS_CEIL (logical.width); Modified: trunk/vice/src/arch/gtk3/novte/vtegtk.cc =================================================================== --- trunk/vice/src/arch/gtk3/novte/vtegtk.cc 2025-05-10 23:53:22 UTC (rev 45668) +++ trunk/vice/src/arch/gtk3/novte/vtegtk.cc 2025-05-11 14:17:23 UTC (rev 45669) @@ -506,7 +506,7 @@ g_value_set_boolean (value, vte_terminal_get_rewrap_on_resize (terminal)); break; case PROP_SCROLLBACK_LINES: - g_value_set_uint (value, vte_terminal_get_scrollback_lines(terminal)); + g_value_set_uint (value, (guint)vte_terminal_get_scrollback_lines(terminal)); break; case PROP_SCROLL_ON_KEYSTROKE: g_value_set_boolean (value, vte_terminal_get_scroll_on_keystroke(terminal)); @@ -2910,8 +2910,8 @@ hints->base_width = padding.left + padding.right; hints->base_height = padding.top + padding.bottom; - hints->width_inc = impl->m_cell_width; - hints->height_inc = impl->m_cell_height; + hints->width_inc = (gint)impl->m_cell_width; + hints->height_inc = (gint)impl->m_cell_height; hints->min_width = hints->base_width + hints->width_inc * min_columns; hints->min_height = hints->base_height + hints->height_inc * min_rows; Modified: trunk/vice/src/arch/gtk3/novte/vterowdata.cc =================================================================== --- trunk/vice/src/arch/gtk3/novte/vterowdata.cc 2025-05-10 23:53:22 UTC (rev 45668) +++ trunk/vice/src/arch/gtk3/novte/vterowdata.cc 2025-05-11 14:17:23 UTC (rev 45669) @@ -45,7 +45,7 @@ return (VteCells *) (((guchar *) cells) - G_STRUCT_OFFSET (VteCells, cells)); } -static VteCells *_vte_cells_realloc (VteCells *cells, guint32 len) +static VteCells *_vte_cells_realloc (VteCells *cells, gsize len) { guint32 alloc_len = (1 << g_bit_storage (MAX (len, 80))) - 1; Modified: trunk/vice/src/arch/gtk3/novte/vteseq.cc =================================================================== --- trunk/vice/src/arch/gtk3/novte/vteseq.cc 2025-05-10 23:53:22 UTC (rev 45668) +++ trunk/vice/src/arch/gtk3/novte/vteseq.cc 2025-05-11 14:17:23 UTC (rev 45669) @@ -216,7 +216,7 @@ char buf[32]; /* gsize len; */ - int id = params.number_or_default_at(0, 0); + int id = (int)params.number_or_default_at(0, 0); #ifndef VTE_DEBUG /* Send a dummy reply */ @@ -328,7 +328,7 @@ _vte_row_data_fill (rowdata, &m_fill_defaults, m_column_count); rowdata->attr.soft_wrapped = 0; /* Repaint this row. */ - invalidate_cells(0, m_column_count, m_screen->cursor.row, 1); + invalidate_cells(0, (int)m_column_count, m_screen->cursor.row, 1); } /* We've modified the display. Make a note of it. */ @@ -351,7 +351,7 @@ _vte_row_data_fill (rowdata, &m_fill_defaults, m_column_count); rowdata->attr.soft_wrapped = 0; /* Repaint the row. */ - invalidate_cells(0, m_column_count, i, 1); + invalidate_cells(0, (int)m_column_count, i, 1); } } /* We've modified the display. Make a note of it. */ @@ -851,7 +851,7 @@ case 3: /* 3: DECCOLM set/reset to 132/80 columns mode, clear screen and cursor home */ if (m_deccolm_mode) { - emit_resize_window(set ? 132 : 80, m_row_count); + emit_resize_window(set ? 132 : 80, (guint)m_row_count); clear_screen(); home_cursor(); } @@ -979,7 +979,7 @@ /* Find the next tabstop. */ while (newcol > 0) { newcol--; - if (get_tabstop(newcol % m_column_count)) { + if (get_tabstop(newcol % ((int)m_column_count))) { break; } } @@ -1015,7 +1015,7 @@ } } /* Repaint this row. */ - invalidate_cells(0, m_screen->cursor.col+1, + invalidate_cells(0, (int)m_screen->cursor.col + 1, m_screen->cursor.row, 1); /* We've modified the display. Make a note of it. */ @@ -1073,7 +1073,7 @@ } rowdata->attr.soft_wrapped = 0; /* Repaint this row. */ - invalidate_cells(0, m_column_count, i, 1); + invalidate_cells(0, (int)m_column_count, i, 1); } /* We've modified the display. Make a note of it. */ @@ -1111,7 +1111,7 @@ } rowdata->attr.soft_wrapped = 0; /* Repaint this row. */ - invalidate_cells(m_screen->cursor.col, m_column_count - m_screen->cursor.col, + invalidate_cells(m_screen->cursor.col, (int)(m_column_count - m_screen->cursor.col), m_screen->cursor.row, 1); } @@ -1144,11 +1144,11 @@ { vte::grid::row_t start_row, end_row; if (m_origin_mode && m_scrolling_restricted) { - start_row = m_scrolling_region.start; - end_row = m_scrolling_region.end; + start_row = (int)m_scrolling_region.start; + end_row = (int)m_scrolling_region.end; } else { start_row = 0; - end_row = m_row_count - 1; + end_row = (int)(m_row_count - 1); } row += start_row; row = CLAMP(row, start_row, end_row); @@ -1247,8 +1247,8 @@ } /* Set the right values. */ - m_scrolling_region.start = start; - m_scrolling_region.end = end; + m_scrolling_region.start = (int)start; + m_scrolling_region.end = (int)end; m_scrolling_restricted = TRUE; if (m_scrolling_region.start == 0 && m_scrolling_region.end == m_row_count - 1) { @@ -1315,7 +1315,7 @@ } rowdata->attr.soft_wrapped = 0; /* Repaint this row. */ - invalidate_cells(col, len - col, m_screen->cursor.row, 1); + invalidate_cells(col, (int)(len - col), m_screen->cursor.row, 1); } } @@ -1396,7 +1396,7 @@ } } /* Repaint this row. */ - invalidate_cells(m_screen->cursor.col, count, m_screen->cursor.row, 1); + invalidate_cells(m_screen->cursor.col, (int)count, m_screen->cursor.row, 1); } /* We've modified the display. Make a note of it. */ @@ -1533,7 +1533,8 @@ } vte::color::rgb color; - guint idx, i; + size_t idx; + guint i; for (i = 0; pairs[i] && pairs[i + 1]; i += 2) { idx = strtoul (pairs[i], (char **) NULL, 10); @@ -1543,16 +1544,16 @@ } if (color.parse(pairs[i + 1])) { - set_color(idx == 256 ? VTE_BOLD_FG : idx, VTE_COLOR_SOURCE_ESCAPE, color); + set_color(idx == 256 ? VTE_BOLD_FG : (int)idx, VTE_COLOR_SOURCE_ESCAPE, color); } else if (strcmp (pairs[i + 1], "?") == 0) { gchar buf[128]; - auto c = get_color(idx == 256 ? VTE_BOLD_FG : idx); + auto c = get_color(idx == 256 ? VTE_BOLD_FG : (int)idx); if (c == NULL && idx == 256) { c = get_color(VTE_DEFAULT_FG); } g_assert(c != NULL); g_snprintf (buf, sizeof (buf), - _VTE_CAP_OSC "4;%u;rgb:%04x/%04x/%04x%s", + _VTE_CAP_OSC "4;%lu;rgb:%04x/%04x/%04x%s", idx, c->red, c->green, c->blue, terminator); /*feed_child(buf, -1);*/ /* FIXME: removed */ } @@ -1592,7 +1593,7 @@ continue; } - reset_color(value == 256 ? VTE_BOLD_FG : value, VTE_COLOR_SOURCE_ESCAPE); + reset_color(value == 256 ? VTE_BOLD_FG : (int)value, VTE_COLOR_SOURCE_ESCAPE); } } else { for (unsigned int idx = 0; idx < VTE_DEFAULT_FG; idx++) { @@ -1643,7 +1644,7 @@ ring_insert(start, true); /* Update the display. */ scroll_region(start, end - start + 1, 1); - invalidate_cells(0, m_column_count, start, 2); + invalidate_cells(0, (int)m_column_count, start, 2); } else { /* Otherwise, just move the cursor up. */ m_screen->cursor.row--; @@ -1660,7 +1661,7 @@ if (m_tabstops == NULL) { m_tabstops = g_hash_table_new(NULL, NULL); } - set_tabstop(m_screen->cursor.col); + set_tabstop((int)m_screen->cursor.col); } /* Tab. */ @@ -1683,7 +1684,7 @@ if (m_tabstops != NULL) { /* Find the next tabstop. */ for (newcol++; newcol < VTE_TAB_MAX; newcol++) { - if (get_tabstop(newcol)) { + if (get_tabstop((int)newcol)) { break; } } @@ -1722,7 +1723,7 @@ glong i; VteCell *cell = _vte_row_data_get_writable (rowdata, col); VteCell tab = *cell; - tab.attr.set_columns(newcol - col); + tab.attr.set_columns((int)(newcol - col)); tab.c = '\t'; /* Save tab char */ *cell = tab; @@ -1735,7 +1736,7 @@ } } - invalidate_cells(m_screen->cursor.col, newcol - m_screen->cursor.col, + invalidate_cells(m_screen->cursor.col, (int)(newcol - m_screen->cursor.col), m_screen->cursor.row, 1); m_screen->cursor.col = newcol; } @@ -1756,7 +1757,7 @@ auto param = params.number_or_default_at(0, 0); if (param == 0) { - clear_tabstop(m_screen->cursor.col); + clear_tabstop((int)m_screen->cursor.col); } else if (param == 3) { if (m_tabstops != nullptr) { g_hash_table_destroy(m_tabstops); @@ -1852,7 +1853,7 @@ return -1; } *index += 1; - return param1; + return (int)param1; } } } @@ -1881,7 +1882,7 @@ switch (param0) { case 4: if (subparams.number_at(1, param1) && param1 >= 0 && param1 <= 3) { - m_defaults.attr.set_underline(param1); + m_defaults.attr.set_underline((int)param1); } break; case 38: @@ -1889,7 +1890,7 @@ unsigned int index = 1; auto color = parse_sgr_38_48_parameters<8, 8, 8>(subparams, &index, true); if (G_LIKELY (color != -1)) { - m_defaults.attr.set_fore(color); + m_defaults.attr.set_fore((uint32_t)color); } break; } @@ -1898,7 +1899,7 @@ unsigned int index = 1; auto color = parse_sgr_38_48_parameters<8, 8, 8>(subparams, &index, true); if (G_LIKELY (color != -1)) { - m_defaults.attr.set_back(color); + m_defaults.attr.set_back((uint32_t)color); } break; } @@ -1981,7 +1982,7 @@ case 35: case 36: case 37: - m_defaults.attr.set_fore(VTE_LEGACY_COLORS_OFFSET + (param - 30)); + m_defaults.attr.set_fore((uint32_t)(VTE_LEGACY_COLORS_OFFSET + (param - 30))); break; case 38: case 48: @@ -2037,7 +2038,7 @@ case 45: case 46: case 47: - m_defaults.attr.set_back(VTE_LEGACY_COLORS_OFFSET + (param - 40)); + m_defaults.attr.set_back((uint32_t)(VTE_LEGACY_COLORS_OFFSET + (param - 40))); break; /* case 48: was handled above at 38 to avoid code duplication */ case 49: @@ -2063,8 +2064,8 @@ case 95: case 96: case 97: - m_defaults.attr.set_fore(VTE_LEGACY_COLORS_OFFSET + (param - 90) + - VTE_COLOR_BRIGHT_OFFSET); + m_defaults.attr.set_fore((uint32_t)(VTE_LEGACY_COLORS_OFFSET + (param - 90) + + VTE_COLOR_BRIGHT_OFFSET)); break; case 100: case 101: @@ -2074,8 +2075,8 @@ case 105: case 106: case 107: - m_defaults.attr.set_back(VTE_LEGACY_COLORS_OFFSET + (param - 100) + - VTE_COLOR_BRIGHT_OFFSET); + m_defaults.attr.set_back((uint32_t)(VTE_LEGACY_COLORS_OFFSET + (param - 100) + + VTE_COLOR_BRIGHT_OFFSET)); break; } } @@ -2663,7 +2664,7 @@ _vte_debug_print(VTE_DEBUG_PARSE, "Moving window to " "%ld,%ld.\n", arg1, arg2); - emit_move_window(arg1, arg2); + emit_move_window((guint)arg1, (guint)arg2); } break; case 4: @@ -2674,7 +2675,7 @@ arg2, arg1, arg2 / m_cell_width, arg1 / m_cell_height); - emit_resize_window(arg2 / m_cell_width, arg1 / m_cell_height); + emit_resize_window((guint)(arg2 / m_cell_width), (guint)(arg1 / m_cell_height)); } break; case 5: @@ -2696,7 +2697,7 @@ "Resizing window " "(to %ld columns, %ld rows).\n", arg2, arg1); - emit_resize_window(arg2, arg1); + emit_resize_window((guint)arg2, (guint)arg1); } break; case 9: @@ -2811,7 +2812,7 @@ param); /* Resize to the specified number of * rows. */ - emit_resize_window(m_column_count, param); + emit_resize_wi... [truncated message content] |
From: <gp...@us...> - 2025-05-10 23:53:23
|
Revision: 45668 http://sourceforge.net/p/vice-emu/code/45668 Author: gpz Date: 2025-05-10 23:53:22 +0000 (Sat, 10 May 2025) Log Message: ----------- fix warning Modified Paths: -------------- trunk/vice/src/arch/sdl/uiimagefilereq.c Modified: trunk/vice/src/arch/sdl/uiimagefilereq.c =================================================================== --- trunk/vice/src/arch/sdl/uiimagefilereq.c 2025-05-10 23:46:26 UTC (rev 45667) +++ trunk/vice/src/arch/sdl/uiimagefilereq.c 2025-05-10 23:53:22 UTC (rev 45668) @@ -67,7 +67,7 @@ int i, j; char* title_string; char* name; - uint8_t oldbg; + uint8_t oldbg = 0; image_contents_file_list_t *entry; title_string = image_contents_to_string(contents, IMAGE_CONTENTS_STRING_PETSCII); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gp...@us...> - 2025-05-10 23:46:29
|
Revision: 45667 http://sourceforge.net/p/vice-emu/code/45667 Author: gpz Date: 2025-05-10 23:46:26 +0000 (Sat, 10 May 2025) Log Message: ----------- instead of performing arithmetics on array pointers directly, set them up indirectly. this gets rid of the long standing array out of bounds access warnings. needs a bit of testing perhaps :) Modified Paths: -------------- trunk/vice/src/c128/c128mem.c trunk/vice/src/c128/c128mem.h trunk/vice/src/c128/c128meminit.c trunk/vice/src/c64/c64mem.c trunk/vice/src/c64/c64mem.h trunk/vice/src/c64/c64meminit.c trunk/vice/src/c64/c64memsc.c trunk/vice/src/c64/cart/ltkernal.c trunk/vice/src/c64/cart/magicvoice.c trunk/vice/src/c64/vsidmem.c trunk/vice/src/c64/vsidmeminit.c trunk/vice/src/scpu64/scpu64mem.c trunk/vice/src/scpu64/scpu64mem.h trunk/vice/src/scpu64/scpu64meminit.c Modified: trunk/vice/src/c128/c128mem.c =================================================================== --- trunk/vice/src/c128/c128mem.c 2025-05-10 17:30:53 UTC (rev 45666) +++ trunk/vice/src/c128/c128mem.c 2025-05-10 23:46:26 UTC (rev 45667) @@ -1536,11 +1536,18 @@ mem_read_tab[base][index] = read_func; } +/* set c128 base */ void mem_read_base_set(unsigned int base, unsigned int index, uint8_t *mem_ptr) { mem_read_base_tab[base][index] = mem_ptr; } +/* add actual pointer */ +void mem_read_addr_set(unsigned int base, unsigned int index, uintptr_t addr) +{ + mem_read_base_tab[base][index] += addr; +} + void mem_read_limit_set(unsigned int base, unsigned int index, uint32_t limit) { mem_read_limit_tab[base][index] = limit; @@ -1672,6 +1679,8 @@ /* Setup character generator ROM at $D000-$DFFF (memory configs 1, 2, 3, 9, 10, 11, 26, 27). */ for (i = 0xd0; i <= 0xdf; i++) { + uintptr_t addr = 0 - 0xd000; + mem_read_tab[base + 1][i] = chargen_read; mem_read_tab[base + 2][i] = chargen_read; mem_read_tab[base + 3][i] = chargen_read; @@ -1680,6 +1689,7 @@ mem_read_tab[base + 11][i] = chargen_read; mem_read_tab[base + 26][i] = chargen_read; mem_read_tab[base + 27][i] = chargen_read; +#if 0 mem_read_base_tab[base + 1][i] = (uint8_t *)(mem_chargen_rom - (uint8_t *)0xd000); mem_read_base_tab[base + 2][i] = (uint8_t *)(mem_chargen_rom - (uint8_t *)0xd000); mem_read_base_tab[base + 3][i] = (uint8_t *)(mem_chargen_rom - (uint8_t *)0xd000); @@ -1688,6 +1698,25 @@ mem_read_base_tab[base + 11][i] = (uint8_t *)(mem_chargen_rom - (uint8_t *)0xd000); mem_read_base_tab[base + 26][i] = (uint8_t *)(mem_chargen_rom - (uint8_t *)0xd000); mem_read_base_tab[base + 27][i] = (uint8_t *)(mem_chargen_rom - (uint8_t *)0xd000); +#else + mem_read_base_set(base + 1, i, (uint8_t*)addr); + mem_read_base_set(base + 2, i, (uint8_t*)addr); + mem_read_base_set(base + 3, i, (uint8_t*)addr); + mem_read_base_set(base + 9, i, (uint8_t*)addr); + mem_read_base_set(base + 10, i, (uint8_t*)addr); + mem_read_base_set(base + 11, i, (uint8_t*)addr); + mem_read_base_set(base + 26, i, (uint8_t*)addr); + mem_read_base_set(base + 27, i, (uint8_t*)addr); + + mem_read_addr_set(base + 1, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(base + 2, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(base + 3, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(base + 9, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(base + 10, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(base + 11, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(base + 26, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(base + 27, i, (uintptr_t)mem_chargen_rom); +#endif } c64meminit(base); Modified: trunk/vice/src/c128/c128mem.h =================================================================== --- trunk/vice/src/c128/c128mem.h 2025-05-10 17:30:53 UTC (rev 45666) +++ trunk/vice/src/c128/c128mem.h 2025-05-10 23:46:26 UTC (rev 45667) @@ -65,6 +65,7 @@ void mem_set_write_hook(int config, int page, store_func_t *f); void mem_read_tab_set(unsigned int base, unsigned int index, read_func_ptr_t read_func); void mem_read_base_set(unsigned int base, unsigned int index, uint8_t *mem_ptr); +void mem_read_addr_set(unsigned int base, unsigned int index, uintptr_t addr); void mem_read_limit_set(unsigned int base, unsigned int index, uint32_t limit); uint8_t ram_read(uint16_t addr); Modified: trunk/vice/src/c128/c128meminit.c =================================================================== --- trunk/vice/src/c128/c128meminit.c 2025-05-10 17:30:53 UTC (rev 45666) +++ trunk/vice/src/c128/c128meminit.c 2025-05-10 23:46:26 UTC (rev 45667) @@ -100,7 +100,12 @@ if ((j & 0x2) == 0) { mem_read_tab_set(j + base, i, basic_lo_read); mem_set_write_hook(j + base, i, basic_lo_store); +#if 0 mem_read_base_set(j + base, i, c128memrom_basic_rom - 0x4000); +#else + mem_read_base_set(j + base, i, (uint8_t*)(0 - 0x4000)); + mem_read_addr_set(j + base, i, (uintptr_t)c128memrom_basic_rom); +#endif mem_read_limit_set(j + base, i, 0x40007fff - 2); } else { mem_read_tab_set(j + base, i, ram_read); @@ -116,7 +121,12 @@ case 0: mem_read_tab_set(j + base, i, basic_hi_read); mem_set_write_hook(j + base, i, basic_hi_store); +#if 0 mem_read_base_set(j + base, i, c128memrom_basic_rom - 0x4000); +#else + mem_read_base_set(j + base, i, (uint8_t*)(0 - 0x4000)); + mem_read_addr_set(j + base, i, (uintptr_t)c128memrom_basic_rom); +#endif mem_read_limit_set(j + base, i, 0x8000bfff - 2); break; case 1: @@ -144,7 +154,12 @@ case 0: mem_read_tab_set(j + base, i, editor_read); mem_set_write_hook(j + base, i, editor_store); +#if 0 mem_read_base_set(j + base, i, c128memrom_basic_rom - 0x4000); +#else + mem_read_base_set(j + base, i, (uint8_t*)(0 - 0x4000)); + mem_read_addr_set(j + base, i, (uintptr_t)c128memrom_basic_rom); +#endif mem_read_limit_set(j + base, i, 0xc000cfff - 2); break; case 1: @@ -279,7 +294,12 @@ case 0: mem_read_tab_set(j + base, i, hi_read); mem_set_write_hook(j + base, i, hi_store); +#if 0 mem_read_base_set(j + base, i, c128memrom_kernal_trap_rom - 0xe000); +#else + mem_read_base_set(j + base, i, (uint8_t*)(0 - 0xe000)); + mem_read_addr_set(j + base, i, (uintptr_t)c128memrom_kernal_trap_rom); +#endif mem_read_limit_set(j + base, i, 0xe000feff - 2); break; case 1: Modified: trunk/vice/src/c64/c64mem.c =================================================================== --- trunk/vice/src/c64/c64mem.c 2025-05-10 17:30:53 UTC (rev 45666) +++ trunk/vice/src/c64/c64mem.c 2025-05-10 23:46:26 UTC (rev 45667) @@ -797,11 +797,20 @@ mem_read_tab[base][index] = read_func; } + +/* set c64 base */ void mem_read_base_set(unsigned int base, unsigned int index, uint8_t *mem_ptr) { mem_read_base_tab[base][index] = mem_ptr; } +/* add actual pointer */ +void mem_read_addr_set(unsigned int base, unsigned int index, uintptr_t addr) +{ + mem_read_base_tab[base][index] += addr; +} + + void mem_read_limit_set(unsigned int base, unsigned int index, uint32_t limit) { mem_read_limit_tab[base][index] = limit; @@ -883,6 +892,8 @@ /* Setup character generator ROM at $D000-$DFFF (memory configs 1, 2, 3, 9, 10, 11, 26, 27). */ for (i = 0xd0; i <= 0xdf; i++) { + uintptr_t addr = 0 - 0xd000; + mem_read_tab[1][i] = chargen_read; mem_read_tab[2][i] = chargen_read; mem_read_tab[3][i] = chargen_read; @@ -891,6 +902,7 @@ mem_read_tab[11][i] = chargen_read; mem_read_tab[26][i] = chargen_read; mem_read_tab[27][i] = chargen_read; +#if 0 mem_read_base_tab[1][i] = (uint8_t *)(mem_chargen_rom - (uint8_t *)0xd000); mem_read_base_tab[2][i] = (uint8_t *)(mem_chargen_rom - (uint8_t *)0xd000); mem_read_base_tab[3][i] = (uint8_t *)(mem_chargen_rom - (uint8_t *)0xd000); @@ -899,6 +911,25 @@ mem_read_base_tab[11][i] = (uint8_t *)(mem_chargen_rom - (uint8_t *)0xd000); mem_read_base_tab[26][i] = (uint8_t *)(mem_chargen_rom - (uint8_t *)0xd000); mem_read_base_tab[27][i] = (uint8_t *)(mem_chargen_rom - (uint8_t *)0xd000); +#else + mem_read_base_set(1, i, (uint8_t*)addr); + mem_read_base_set(2, i, (uint8_t*)addr); + mem_read_base_set(3, i, (uint8_t*)addr); + mem_read_base_set(9, i, (uint8_t*)addr); + mem_read_base_set(10, i, (uint8_t*)addr); + mem_read_base_set(11, i, (uint8_t*)addr); + mem_read_base_set(26, i, (uint8_t*)addr); + mem_read_base_set(27, i, (uint8_t*)addr); + + mem_read_addr_set(1, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(2, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(3, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(9, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(10, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(11, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(26, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(27, i, (uintptr_t)mem_chargen_rom); +#endif } c64meminit(0); Modified: trunk/vice/src/c64/c64mem.h =================================================================== --- trunk/vice/src/c64/c64mem.h 2025-05-10 17:30:53 UTC (rev 45666) +++ trunk/vice/src/c64/c64mem.h 2025-05-10 23:46:26 UTC (rev 45667) @@ -65,6 +65,7 @@ void mem_set_write_hook(int config, int page, store_func_t *f); void mem_read_tab_set(unsigned int base, unsigned int index, read_func_ptr_t read_func); void mem_read_base_set(unsigned int base, unsigned int index, uint8_t *mem_ptr); +void mem_read_addr_set(unsigned int base, unsigned int index, uintptr_t addr); void mem_read_limit_set(unsigned int base, unsigned int index, uint32_t limit); void mem_store_without_ultimax(uint16_t addr, uint8_t value); Modified: trunk/vice/src/c64/c64meminit.c =================================================================== --- trunk/vice/src/c64/c64meminit.c 2025-05-10 17:30:53 UTC (rev 45666) +++ trunk/vice/src/c64/c64meminit.c 2025-05-10 23:46:26 UTC (rev 45667) @@ -138,14 +138,28 @@ if (board != BOARD_MAX) { /* Setup BASIC ROM at $A000-$BFFF (memory configs 3, 7, 11, 15). */ for (i = 0xa0; i <= 0xbf; i++) { + uintptr_t addr = 0 - 0xa000; + mem_read_tab_set(base + 3, i, c64memrom_basic64_read); mem_read_tab_set(base + 7, i, c64memrom_basic64_read); mem_read_tab_set(base + 11, i, c64memrom_basic64_read); mem_read_tab_set(base + 15, i, c64memrom_basic64_read); +#if 0 mem_read_base_set(base + 3, i, c64memrom_basic64_rom - 0xa000); mem_read_base_set(base + 7, i, c64memrom_basic64_rom - 0xa000); mem_read_base_set(base + 11, i, c64memrom_basic64_rom - 0xa000); mem_read_base_set(base + 15, i, c64memrom_basic64_rom - 0xa000); +#else + mem_read_base_set(base + 3, i, (uint8_t*)addr); + mem_read_base_set(base + 7, i, (uint8_t*)addr); + mem_read_base_set(base + 11, i, (uint8_t*)addr); + mem_read_base_set(base + 15, i, (uint8_t*)addr); + + mem_read_addr_set(base + 3, i, (uintptr_t)c64memrom_basic64_rom); + mem_read_addr_set(base + 7, i, (uintptr_t)c64memrom_basic64_rom); + mem_read_addr_set(base + 11, i, (uintptr_t)c64memrom_basic64_rom); + mem_read_addr_set(base + 15, i, (uintptr_t)c64memrom_basic64_rom); +#endif } } @@ -201,6 +215,7 @@ /* Setup Kernal ROM at $E000-$FFFF (memory configs 2, 3, 6, 7, 10, 11, 14, 15, 26, 27, 30, 31). */ for (i = 0xe0; i <= 0xff; i++) { + uintptr_t addr = 0 - 0xe000; mem_read_tab_set(base + 2, i, c64memrom_kernal64_read); mem_read_tab_set(base + 3, i, c64memrom_kernal64_read); mem_read_tab_set(base + 6, i, c64memrom_kernal64_read); @@ -213,6 +228,7 @@ mem_read_tab_set(base + 27, i, c64memrom_kernal64_read); mem_read_tab_set(base + 30, i, c64memrom_kernal64_read); mem_read_tab_set(base + 31, i, c64memrom_kernal64_read); +#if 0 mem_read_base_set(base + 2, i, c64memrom_kernal64_trap_rom - 0xe000); mem_read_base_set(base + 3, i, c64memrom_kernal64_trap_rom - 0xe000); mem_read_base_set(base + 6, i, c64memrom_kernal64_trap_rom - 0xe000); @@ -225,6 +241,33 @@ mem_read_base_set(base + 27, i, c64memrom_kernal64_trap_rom - 0xe000); mem_read_base_set(base + 30, i, c64memrom_kernal64_trap_rom - 0xe000); mem_read_base_set(base + 31, i, c64memrom_kernal64_trap_rom - 0xe000); +#else + mem_read_base_set(base + 2, i, (uint8_t*)addr); + mem_read_base_set(base + 3, i, (uint8_t*)addr); + mem_read_base_set(base + 6, i, (uint8_t*)addr); + mem_read_base_set(base + 7, i, (uint8_t*)addr); + mem_read_base_set(base + 10, i, (uint8_t*)addr); + mem_read_base_set(base + 11, i, (uint8_t*)addr); + mem_read_base_set(base + 14, i, (uint8_t*)addr); + mem_read_base_set(base + 15, i, (uint8_t*)addr); + mem_read_base_set(base + 26, i, (uint8_t*)addr); + mem_read_base_set(base + 27, i, (uint8_t*)addr); + mem_read_base_set(base + 30, i, (uint8_t*)addr); + mem_read_base_set(base + 31, i, (uint8_t*)addr); + + mem_read_addr_set(base + 2, i, (uintptr_t)c64memrom_kernal64_trap_rom); + mem_read_addr_set(base + 3, i, (uintptr_t)c64memrom_kernal64_trap_rom); + mem_read_addr_set(base + 6, i, (uintptr_t)c64memrom_kernal64_trap_rom); + mem_read_addr_set(base + 7, i, (uintptr_t)c64memrom_kernal64_trap_rom); + mem_read_addr_set(base + 10, i, (uintptr_t)c64memrom_kernal64_trap_rom); + mem_read_addr_set(base + 11, i, (uintptr_t)c64memrom_kernal64_trap_rom); + mem_read_addr_set(base + 14, i, (uintptr_t)c64memrom_kernal64_trap_rom); + mem_read_addr_set(base + 15, i, (uintptr_t)c64memrom_kernal64_trap_rom); + mem_read_addr_set(base + 26, i, (uintptr_t)c64memrom_kernal64_trap_rom); + mem_read_addr_set(base + 27, i, (uintptr_t)c64memrom_kernal64_trap_rom); + mem_read_addr_set(base + 30, i, (uintptr_t)c64memrom_kernal64_trap_rom); + mem_read_addr_set(base + 31, i, (uintptr_t)c64memrom_kernal64_trap_rom); +#endif } } Modified: trunk/vice/src/c64/c64memsc.c =================================================================== --- trunk/vice/src/c64/c64memsc.c 2025-05-10 17:30:53 UTC (rev 45666) +++ trunk/vice/src/c64/c64memsc.c 2025-05-10 23:46:26 UTC (rev 45667) @@ -753,11 +753,19 @@ mem_read_tab[base][index] = read_func; } +/* set c64 base */ void mem_read_base_set(unsigned int base, unsigned int index, uint8_t *mem_ptr) { mem_read_base_tab[base][index] = mem_ptr; } +/* add actual pointer */ +void mem_read_addr_set(unsigned int base, unsigned int index, uintptr_t addr) +{ + mem_read_base_tab[base][index] += addr; +} + + void mem_read_limit_set(unsigned int base, unsigned int index, uint32_t limit) { mem_read_limit_tab[base][index] = limit; @@ -822,8 +830,11 @@ } } + uintptr_t addr = 0 - 0xd000; + /* Setup character generator ROM at $D000-$DFFF (memory configs 1, 2, 3, 9, 10, 11, 26, 27). */ for (i = 0xd0; i <= 0xdf; i++) { +#if 0 mem_read_tab[1][i] = chargen_read; mem_read_tab[2][i] = chargen_read; mem_read_tab[3][i] = chargen_read; @@ -840,6 +851,52 @@ mem_read_base_tab[11][i] = (uint8_t *)(mem_chargen_rom - (uint8_t *)0xd000); mem_read_base_tab[26][i] = (uint8_t *)(mem_chargen_rom - (uint8_t *)0xd000); mem_read_base_tab[27][i] = (uint8_t *)(mem_chargen_rom - (uint8_t *)0xd000); +#endif + mem_read_tab_set(1, i, chargen_read); + mem_read_tab_set(2, i, chargen_read); + mem_read_tab_set(3, i, chargen_read); + mem_read_tab_set(9, i, chargen_read); + mem_read_tab_set(10, i, chargen_read); + mem_read_tab_set(11, i, chargen_read); + mem_read_tab_set(26, i, chargen_read); + mem_read_tab_set(27, i, chargen_read); +#if 0 + mem_read_base_set(1, i, mem_chargen_rom); + mem_read_base_set(2, i, mem_chargen_rom); + mem_read_base_set(3, i, mem_chargen_rom); + mem_read_base_set(9, i, mem_chargen_rom); + mem_read_base_set(10, i, mem_chargen_rom); + mem_read_base_set(11, i, mem_chargen_rom); + mem_read_base_set(26, i, mem_chargen_rom); + mem_read_base_set(27, i, mem_chargen_rom); + + mem_read_addr_set(1, i, addr); + mem_read_addr_set(2, i, addr); + mem_read_addr_set(3, i, addr); + mem_read_addr_set(9, i, addr); + mem_read_addr_set(10, i, addr); + mem_read_addr_set(11, i, addr); + mem_read_addr_set(26, i, addr); + mem_read_addr_set(27, i, addr); +#else + mem_read_base_set(1, i, (uint8_t*)addr); + mem_read_base_set(2, i, (uint8_t*)addr); + mem_read_base_set(3, i, (uint8_t*)addr); + mem_read_base_set(9, i, (uint8_t*)addr); + mem_read_base_set(10, i, (uint8_t*)addr); + mem_read_base_set(11, i, (uint8_t*)addr); + mem_read_base_set(26, i, (uint8_t*)addr); + mem_read_base_set(27, i, (uint8_t*)addr); + + mem_read_addr_set(1, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(2, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(3, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(9, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(10, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(11, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(26, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(27, i, (uintptr_t)mem_chargen_rom); +#endif } c64meminit(0); Modified: trunk/vice/src/c64/cart/ltkernal.c =================================================================== --- trunk/vice/src/c64/cart/ltkernal.c 2025-05-10 17:30:53 UTC (rev 45666) +++ trunk/vice/src/c64/cart/ltkernal.c 2025-05-10 23:46:26 UTC (rev 45667) @@ -988,7 +988,12 @@ if ((ltk_ramh && (p & 2)) || (ltk_ramh && ltk_freeze )) { *base = export_ram0 + 0x2000 - 0xe000; } else if (p & 2) { +#if 0 *base = c64memrom_kernal64_trap_rom - 0xe000; +#else + *base = (uint8_t*)(0 - 0xe000); + *base += (uintptr_t)c64memrom_kernal64_trap_rom; +#endif } else { /* include RAM to speed things up */ *base = mem_ram; Modified: trunk/vice/src/c64/cart/magicvoice.c =================================================================== --- trunk/vice/src/c64/cart/magicvoice.c 2025-05-10 17:30:53 UTC (rev 45666) +++ trunk/vice/src/c64/cart/magicvoice.c 2025-05-10 23:46:26 UTC (rev 45667) @@ -1286,7 +1286,9 @@ return CART_READ_THROUGH; /* "passthrough" */ } else { if (mv_romE000_enabled) { - *base = (uint8_t *)(mv_rom - (uint8_t *)0xc000); + /* *base = (uint8_t *)(mv_rom - (uint8_t *)0xc000); */ + *base = (uint8_t *)(0 - 0xc000); + *base += (uintptr_t)(mv_rom); *start = 0xe000; *limit = 0xfffd; return CART_READ_VALID; @@ -1306,7 +1308,9 @@ return CART_READ_THROUGH_NO_ULTIMAX; /* "passthrough" */ } else { if (mv_romA000_enabled) { - *base = (uint8_t *)(mv_rom - (uint8_t *)0xa000); + /* *base = (uint8_t *)(mv_rom - (uint8_t *)0xa000); */ + *base = (uint8_t *)(0 - 0xa000); + *base += (uintptr_t)(mv_rom); *start = 0xa000; *limit = 0xbffd; return CART_READ_VALID; Modified: trunk/vice/src/c64/vsidmem.c =================================================================== --- trunk/vice/src/c64/vsidmem.c 2025-05-10 17:30:53 UTC (rev 45666) +++ trunk/vice/src/c64/vsidmem.c 2025-05-10 23:46:26 UTC (rev 45667) @@ -439,11 +439,20 @@ mem_read_tab[base][index] = read_func; } + +/* set c64 base */ void mem_read_base_set(unsigned int base, unsigned int index, uint8_t *mem_ptr) { mem_read_base_tab[base][index] = mem_ptr; } +/* add actual pointer */ +void mem_read_addr_set(unsigned int base, unsigned int index, uintptr_t addr) +{ + mem_read_base_tab[base][index] += addr; +} + + void mem_read_limit_set(unsigned int base, unsigned int index, uint32_t limit) { mem_read_limit_tab[base][index] = limit; @@ -501,6 +510,8 @@ /* Setup character generator ROM at $D000-$DFFF (memory configs 1, 2, 3, 9, 10, 11, 25, 26, 27). */ for (i = 0xd0; i <= 0xdf; i++) { + uintptr_t addr = 0 - 0xd000; + mem_read_tab[1][i] = chargen_read; mem_read_tab[2][i] = chargen_read; mem_read_tab[3][i] = chargen_read; @@ -510,6 +521,7 @@ mem_read_tab[25][i] = chargen_read; mem_read_tab[26][i] = chargen_read; mem_read_tab[27][i] = chargen_read; +#if 0 mem_read_base_tab[1][i] = (uint8_t *)(mem_chargen_rom - (uint8_t *)0xd000); mem_read_base_tab[2][i] = (uint8_t *)(mem_chargen_rom - (uint8_t *)0xd000); mem_read_base_tab[3][i] = (uint8_t *)(mem_chargen_rom - (uint8_t *)0xd000); @@ -519,6 +531,25 @@ mem_read_base_tab[25][i] = (uint8_t *)(mem_chargen_rom - (uint8_t *)0xd000); mem_read_base_tab[26][i] = (uint8_t *)(mem_chargen_rom - (uint8_t *)0xd000); mem_read_base_tab[27][i] = (uint8_t *)(mem_chargen_rom - (uint8_t *)0xd000); +#else + mem_read_base_set(1, i, (uint8_t*)addr); + mem_read_base_set(2, i, (uint8_t*)addr); + mem_read_base_set(3, i, (uint8_t*)addr); + mem_read_base_set(9, i, (uint8_t*)addr); + mem_read_base_set(10, i, (uint8_t*)addr); + mem_read_base_set(11, i, (uint8_t*)addr); + mem_read_base_set(26, i, (uint8_t*)addr); + mem_read_base_set(27, i, (uint8_t*)addr); + + mem_read_addr_set(1, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(2, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(3, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(9, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(10, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(11, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(26, i, (uintptr_t)mem_chargen_rom); + mem_read_addr_set(27, i, (uintptr_t)mem_chargen_rom); +#endif } c64meminit(0); Modified: trunk/vice/src/c64/vsidmeminit.c =================================================================== --- trunk/vice/src/c64/vsidmeminit.c 2025-05-10 17:30:53 UTC (rev 45666) +++ trunk/vice/src/c64/vsidmeminit.c 2025-05-10 23:46:26 UTC (rev 45667) @@ -116,10 +116,19 @@ /* Setup BASIC ROM at $A000-$BFFF (memory configs 3 and 7). */ for (i = 0xa0; i <= 0xbf; i++) { + uintptr_t addr = 0 - 0xa000; mem_read_tab_set(base + 3, i, c64memrom_basic64_read); mem_read_tab_set(base + 7, i, c64memrom_basic64_read); +#if 0 mem_read_base_set(base + 3, i, c64memrom_basic64_rom - 0xa000); mem_read_base_set(base + 7, i, c64memrom_basic64_rom - 0xa000); +#else + mem_read_base_set(base + 3, i, (uint8_t*)addr); + mem_read_base_set(base + 7, i, (uint8_t*)addr); + + mem_read_addr_set(base + 3, i, (uintptr_t)c64memrom_basic64_rom); + mem_read_addr_set(base + 7, i, (uintptr_t)c64memrom_basic64_rom); +#endif } /* Setup I/O at $D000-$DFFF (memory configs 5, 6, 7). */ @@ -164,13 +173,27 @@ /* Setup Kernal ROM at $E000-$FFFF (memory configs 2, 3, 6, 7). */ for (i = 0xe0; i <= 0xff; i++) { + uintptr_t addr = 0 - 0xe000; + mem_read_tab_set(base + 2, i, c64memrom_kernal64_read); mem_read_tab_set(base + 3, i, c64memrom_kernal64_read); mem_read_tab_set(base + 6, i, c64memrom_kernal64_read); mem_read_tab_set(base + 7, i, c64memrom_kernal64_read); +#if 0 mem_read_base_set(base + 2, i, c64memrom_kernal64_rom - 0xe000); mem_read_base_set(base + 3, i, c64memrom_kernal64_rom - 0xe000); mem_read_base_set(base + 6, i, c64memrom_kernal64_rom - 0xe000); mem_read_base_set(base + 7, i, c64memrom_kernal64_rom - 0xe000); +#else + mem_read_base_set(base + 2, i, (uint8_t*)addr); + mem_read_base_set(base + 3, i, (uint8_t*)addr); + mem_read_base_set(base + 6, i, (uint8_t*)addr); + mem_read_base_set(base + 7, i, (uint8_t*)addr); + + mem_read_addr_set(base + 2, i, (uintptr_t)c64memrom_kernal64_rom); + mem_read_addr_set(base + 3, i, (uintptr_t)c64memrom_kernal64_rom); + mem_read_addr_set(base + 6, i, (uintptr_t)c64memrom_kernal64_rom); + mem_read_addr_set(base + 7, i, (uintptr_t)c64memrom_kernal64_rom); +#endif } } Modified: trunk/vice/src/scpu64/scpu64mem.c =================================================================== --- trunk/vice/src/scpu64/scpu64mem.c 2025-05-10 17:30:53 UTC (rev 45666) +++ trunk/vice/src/scpu64/scpu64mem.c 2025-05-10 23:46:26 UTC (rev 45667) @@ -1280,11 +1280,18 @@ mem_read_tab[base][index] = read_func; } +/* set c64 base */ void mem_read_base_set(unsigned int base, unsigned int index, uint8_t *mem_ptr) { mem_read_base_tab[base][index] = mem_ptr; } +/* add actual pointer */ +void mem_read_addr_set(unsigned int base, unsigned int index, uintptr_t addr) +{ + mem_read_base_tab[base][index] += addr; +} + void mem_initialize_memory(void) { int i, j, l; Modified: trunk/vice/src/scpu64/scpu64mem.h =================================================================== --- trunk/vice/src/scpu64/scpu64mem.h 2025-05-10 17:30:53 UTC (rev 45666) +++ trunk/vice/src/scpu64/scpu64mem.h 2025-05-10 23:46:26 UTC (rev 45667) @@ -125,6 +125,7 @@ void mem_set_write_hook(int config, int page, store_func_t *f); void mem_read_tab_set(unsigned int base, unsigned int index, read_func_ptr_t read_func); void mem_read_base_set(unsigned int base, unsigned int index, uint8_t *mem_ptr); +void mem_read_addr_set(unsigned int base, unsigned int index, uintptr_t addr); void mem_store_without_ultimax(uint16_t addr, uint8_t value); uint8_t mem_read_without_ultimax(uint16_t addr); Modified: trunk/vice/src/scpu64/scpu64meminit.c =================================================================== --- trunk/vice/src/scpu64/scpu64meminit.c 2025-05-10 17:30:53 UTC (rev 45666) +++ trunk/vice/src/scpu64/scpu64meminit.c 2025-05-10 23:46:26 UTC (rev 45667) @@ -277,7 +277,12 @@ break; case KT: mem_read_tab_set(k, j, ram1_read); +#if 0 mem_read_base_set(k, j, mem_trap_ram - 0xe000); +#else + mem_read_base_set(k, j, (uint8_t*)(0 - 0xe000)); + mem_read_addr_set(k, j, (uintptr_t)mem_trap_ram); +#endif /* write hook preset, ram */ break; case KS: @@ -413,7 +418,12 @@ break; case CR: mem_read_tab_set(k, j, chargen_read); +#if 0 mem_read_base_set(k, j, mem_chargen_rom - 0xd000); +#else + mem_read_base_set(k, j, (uint8_t*)(0 - 0xd000)); + mem_read_addr_set(k, j, (uintptr_t)mem_chargen_rom); +#endif /* write hook preset, ram */ break; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gp...@us...> - 2025-05-10 17:30:57
|
Revision: 45666 http://sourceforge.net/p/vice-emu/code/45666 Author: gpz Date: 2025-05-10 17:30:53 +0000 (Sat, 10 May 2025) Log Message: ----------- funky magic to silence warning Modified Paths: -------------- trunk/vice/src/core/ata.c Modified: trunk/vice/src/core/ata.c =================================================================== --- trunk/vice/src/core/ata.c 2025-05-10 17:14:22 UTC (rev 45665) +++ trunk/vice/src/core/ata.c 2025-05-10 17:30:53 UTC (rev 45666) @@ -105,24 +105,29 @@ }; static const uint8_t identify[128] = { + // 0x00 0x40, 0x00, 0x00, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x32, 0x31, 0x31, 0x38, 0x30, 0x30, 0x32, 0x20, 0x20, 0x20, 0x20, + // 0x20 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x36, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x49, 0x56, 0x45, 0x43, 0x48, 0x2d, 0x44, 0x44, 0x20, 0x20, + // 0x40 0x20, 0x20, 0x41, 0x4b, 0x54, 0x4a, 0x52, 0x41, 0x5a, 0x20, 0x4f, 0x53, 0x54, 0x4c, 0x28, 0x20, 0x4f, 0x53, 0x49, 0x43, 0x53, 0x2f, 0x4e, 0x49, 0x55, 0x47, 0x41, 0x4c, 0x29, 0x52, 0x01, 0x00, + // 0x60 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x04, 0x00, 0x10, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x01, + // 0x78 (120) 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; @@ -1277,7 +1282,12 @@ drv->geometry.heads = identify[6]; drv->geometry.sectors = identify[12]; drv->geometry.size = drv->geometry.cylinders * drv->geometry.heads * drv->geometry.sectors; - if ((identify[99] & 0x02) && (identify[120] || identify[121] || identify[122] || identify[123])) { + if ((identify[99] & 0x02) && + /* 0x78 (120): 0x00, 0x40, 0x00, 0x00 */ + ((identify[120] != /* DISABLES CODE */ (0) ) || + (identify[121] != 0) || + (identify[122] != 0) || + (identify[123] != 0))) { drv->geometry.size = identify[120]; drv->geometry.size |= identify[121] << 8; drv->geometry.size |= identify[122] << 16; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gp...@us...> - 2025-05-10 17:14:28
|
Revision: 45665 http://sourceforge.net/p/vice-emu/code/45665 Author: gpz Date: 2025-05-10 17:14:22 +0000 (Sat, 10 May 2025) Log Message: ----------- implement 'slot 0' cartridge (with pass through) for xvic (loosely modelled after mmc64), add support for the 'Minimon' cartridge (crt id 10) Modified Paths: -------------- trunk/vice/data/hotkeys/hotkeys-cartridge.vhk trunk/vice/doc/vice.texi trunk/vice/src/arch/gtk3/uimachinemenu.c trunk/vice/src/arch/gtk3/uisettings.c trunk/vice/src/arch/gtk3/widgets/Makefile.am trunk/vice/src/arch/sdl/actions-cartridge.c trunk/vice/src/arch/sdl/menu_vic20cart.c trunk/vice/src/arch/shared/uiactions.c trunk/vice/src/arch/shared/uiactions.h trunk/vice/src/cartridge.h trunk/vice/src/drive/iec/memiec.c trunk/vice/src/tools/cartconv/vic20-cartridges.c trunk/vice/src/vic20/cart/Makefile.am trunk/vice/src/vic20/cart/vic20cart.c trunk/vice/src/vic20/cart/vic20cartmem.c trunk/vice/src/vic20/cart/vic20cartmem.h trunk/vice/src/vic20/cart/writenow.c Added Paths: ----------- trunk/vice/src/arch/gtk3/widgets/settings_minimon.c trunk/vice/src/arch/gtk3/widgets/settings_minimon.h trunk/vice/src/vic20/cart/minimon.c trunk/vice/src/vic20/cart/minimon.h Modified: trunk/vice/data/hotkeys/hotkeys-cartridge.vhk =================================================================== --- trunk/vice/data/hotkeys/hotkeys-cartridge.vhk 2025-05-08 06:21:00 UTC (rev 45664) +++ trunk/vice/data/hotkeys/hotkeys-cartridge.vhk 2025-05-10 17:14:22 UTC (rev 45665) @@ -6,13 +6,13 @@ !if !MACOS cart-attach <Alt>c cart-detach <Alt><Shift>c - !if C64 || C64SC || SCPU64 || C128 + !if C64 || C64SC || SCPU64 || C128 || VIC20 cart-freeze <Alt>z !endif !else cart-attach <Command>c cart-detach <Command><Shift>c - !if C64 || C64SC || SCPU64 || C128 + !if C64 || C64SC || SCPU64 || C128 || VIC20 cart-freeze <Command>z !endif !endif Modified: trunk/vice/doc/vice.texi =================================================================== --- trunk/vice/doc/vice.texi 2025-05-08 06:21:00 UTC (rev 45664) +++ trunk/vice/doc/vice.texi 2025-05-10 17:14:22 UTC (rev 45665) @@ -14378,10 +14378,221 @@ @end itemize @node VIC20 cartridges, VIC20 memory expansions, VIC20-specific, VIC20-specific -@subsection Using cartridge images +@subsection Using cartridges + +Generally a cartridge can be enabled by attaching its respective cartridge +image, or using the respective menu option for cartridges that do not +require an image. + +@dfn{Cartridge images} are like disk images, but contain the contents of +cartridge ROM and/or RAM images instead of disk images. Two kinds of cartridge +images are supported: + +@itemize @bullet +@item +@file{.crt} images, as originally used by the CCS64 emulator by Per H\xE5kan Sundell +@item +raw @file{.bin} images, without load address +@item +raw @file{.prg} images, with load address +@end itemize + +Use cartconv to convert .bin or .prg images to .crt format. + +To attach cartridges, use the ``Attach a cartridge image'' submenu. When using +@file{.crt} images, this will work for every cartridge which is supported. For +raw @file{.bin} or @file{.prg} images you will have to select the correct type +of cartridge first, or use command line options. + +When you have successfully attached a cartridge image, +you should then reset the machine to make sure the cartridge initializes +itself. (Or enable the "reset on cartridge change" option). + +Of course, it is also possible to detach a currently attached +cartridge image (``Detach cartridge image''). + +The cartridge system is organized in "Slots" to allow more than one cartridge +connected at a time, like it can be done using an expansion port expander on +a real VIC20 (see below). + +The imaginary expansion port expander is organized in 4 slots, the +cartridges are associated with them like this: + +@c @node FIXME +@subsubsection Slot 0 + +All carts that have a passthrough connector go here. Once a "Slot 0" +cartridge is enabled all further cartridges are connected to its respective +passthrough port. + +Only one cartridge of this type can be active at a time. + +"Slot 0" carts have individual "enable" switches, enabling means enabling permanently. + +The following cartridges are emulated in this slot: + +@itemize @bullet +@item +Minimon +@end itemize + + +@c @node FIXME +@subsubsection Slot 1 + +Mostly RAM based cartridges which for one reason or the other might make sense +to be enabled together with one of the "Main Slot" cartridges go here. + +Only one cartridge of this type can be active at a time. + +"Slot 1" carts have individual "enable" switches, enabling means enabling permanently + +Currently no cartridges use this slot + + +@c @node FIXME +@subsubsection Main Slot + +All other cartridges which are not pure i/o extensions go here. + +Only one cartridge of this type can be active at a time. + +Cartridges in the "Main Slot" must be explicitly set as default to enable them permanently. + +The following cartridges are emulated in this slot: + +@itemize @bullet +@item +generic 4KiB, 8KiB and 16KiB cartridges located at $2000, $4000, $6000, $a000, $b000 (see below) +@item +Behrbonz +@item +Final Expansion +@item +Megacart +@item +Mikro Assembler +@item +Rabbit tape turbo +@item +Super Expander +@item +Ultimem +@item +VIC Flash Plugin +@item +Write Now +@end itemize + + +@c @node FIXME +@subsubsection I/O Slot + +All carts that are pure I/O extensions go here. + +Any number of "I/O Slot" Carts may be active at a time. + +"I/O Slot" carts have individual "enable" switches, enabling means enabling permanently. + +The following cartridges are emulated in this slot: + +@itemize @bullet +@item +ACIA (Swiftlink, Turbo232) +@item +MIDI (Passport/Syntech, Datel/Siel/JMS/C-Lab, Maplin, Namesoft, Sequential) +@item +RAM Expansion Module (REU) +@item +SID Cartridge +@item +VIC1112 IEEE-488 Interface +@end itemize + +On top of that, xvic emulates the "Masquerade" IO expander, which make it possible +to use (some) C64 cartridges at the VIC20: + +@itemize @bullet +@item +ACIA (Swiftlink, Turbo232) +@item +DigiMAX +@item +DS12C887 RTC +@item +Ethernet (The Final Ethernet, RR-Net) +@item +GEO-RAM +@item +SFX Sound Expander +@item +SFX Sound Sampler +@end itemize + + +@c @node FIXME +@subsubsection Expected behaviour + +When the emulator is run without arguments, all settings from the config file +should be applied and arguments override settings from the config file. + +When saving the settings to the config file it is expected that on the next run +of the emulator all settings will be in the same state as they were when saved. + +There is an exception to this rule: the cartridge in the "Main Slot" must be +explicitly set as default before it gets saved to the config file. + +@code{+cart} should disable ALL cartridges, including eventually activated REU, +Swiftlink and all similar expansionport devices. + +@code{-cartXYZ} options should generally attach AND activate a cart of type XYZ. +As a consequence, attaching carts this way which are NOT in the "Main Slot" will +also enable the cart permanently. + +@c @node FIXME +@subsubsection Common problems + +If attaching a cartridge does not work as expected, this may be because of various +reasons: + +@itemize @bullet + +@item Not seldomly VIC20 related files with @code{.crt} extension found "in the wild" are +plain binaries, and not in actual @code{.crt} format - if in doubt use @code{cartconv} +to verify and/or fix). + +@item You may have unintentionally enabled more than one cartridge at once, for +example by saving the settings with GEORAM enabled, and then later attaching a game +cartridge from the command-line. The cartridge system will allow certain combinations, +but (as on the real thing) not all do (can) actually work. To make sure this is +not the case, either detach all cartridges from the menus, or use @code{+cart} +on the command-line. + +@item The cartridge image might be broken. Try one from a different source. If you +are sure the dump is ok (for example because you dumped it yourself) then make sure +it is in proper linear order (on some cartridges, for example "capture", address and/or +data lines at the eprom are shuffled around so a dump made with an eprom burner can not +be used as is). + +@item Last not least you might have encountered a bug in the emulation. If you +suspect this is the case, and you can still reproduce the bug after checking the +things above, please file a bug report including the following information: + +@itemize @bullet +@item attach your vicerc and a reference to the cartridge binaries +@item if you can, comment in the respective DEBUGXYZ macros prominently defined at the +top of these files: src/vic20/cart/vic20cart.c src/vic20/cart/vic20cartmem.c src/vic20/vic20io.c +src/vic20/vic20export.c and then recompile. this will add debug output that might make +it much easier to locate certain problems. +@end itemize + +@end itemize + +@subsubsection Using cartridge images + As with the C64 (@pxref{C64 cartridges}), it is possible to attach -several types of cartridge images: +several types of generic cartridge images: @itemize @bullet @item @@ -14465,6 +14676,10 @@ @item 8: Mikro Assembler @item + 9: Write Now +@item + 10: Minimon +@item - 10: SID Cartridge @item - 11: IEEE-4888 @@ -14651,11 +14866,27 @@ @item IEEE488 Boolean specifying whether the IEEE488 interface should be emulated or not. -@vindex MachineVideoStandard -@item MachineVideoStandard -Integer that specifies the video standard of the emulated machine -(1: PAL, 2: NTSC). +@vindex MinimonFilename +@item MinimonFilename +String specifying the filename of the Minimon ROM image. +@vindex MinimonEnabled +@item MinimonEnabled +Boolean specifying whether Minimon emulation is enabled. + +@vindex MinimonPgmSwitch +@item MinimonPgmSwitch +Boolean specifying whether the Minimon ROM is writeable. + +@vindex MinimonIoSwitch +@item MinimonIoSwitch +Boolean specifying whether the Minimon ROM is active in IO2/3 (default: enabled) + +@vindex MinimonImageWrite +@item MinimonImageWrite +Boolean specifying whether changes to the Minimon ROM will be written back to the +ROM image file. + @end table @c @node FIXME @@ -14936,22 +15167,34 @@ (@code{GEORAMsize}). (512, 1024, 2048, 4096) -@findex -model -@item -model <model> -Specify the VIC20 model you want to emulate -(@code{MachineVideoStandard}, @code{RamBlock0}, @code{RamBlock1}, @code{RamBlock2}, @code{RamBlock3} and @code{RamBlock5}). -(vic20/vic20pal/vic20ntsc, vic21) +@findex -minimon, +minimon +@item -minimon +@itemx +minimon +Enable/Disable the Minimon expansion +(@code{MinimonEnabled=1}, @code{MinimonEnabled=0}). -@findex -pal -@item -pal -Use PAL sync factor -(@code{MachineVideoStandard=1}). +@findex -minimonrom +@item -minimonrom <name> +Specify name of Minimon ROM image (@code{MinimonFilename}). -@findex -ntsc -@item -ntsc -Use NTSC sync factor -(@code{MachineVideoStandard=2}). +@findex -minimonrw, -minimonro +@item -minimonrw +@itemx -minimonro +Save/Do not save the Minimon ROM when changed +(@code{MinimonImageWrite=1}, @code{MinimonImageWrite=0}). +@findex -minimonpgm, +minimonpgm +@item -minimonpgm +@itemx +minimonpgm +Set/Remove the Minimon PGM switch +(@code{MinimonPgmSwitch=1}, @code{MinimonPgmSwitch=0}). + +@findex -minimonio, +minimonio +@item -minimonio +@itemx +minimonio +Set/Remove the Minimon IO switch +(@code{MinimonIoSwitch=1}, @code{MinimonIoSwitch=0}). + @end table @c @node FIXME @@ -14962,6 +15205,11 @@ @table @code +@vindex MachineVideoStandard +@item MachineVideoStandard +Integer that specifies the video standard of the emulated machine +(1: PAL, 2: NTSC). + @vindex VICVideoCache @item VICVideoCache Boolean specifying whether the video cache is turned on. @@ -15101,6 +15349,22 @@ @table @code +@findex -model +@item -model <model> +Specify the VIC20 model you want to emulate +(@code{MachineVideoStandard}, @code{RamBlock0}, @code{RamBlock1}, @code{RamBlock2}, @code{RamBlock3} and @code{RamBlock5}). +(vic20/vic20pal/vic20ntsc, vic21) + +@findex -pal +@item -pal +Use PAL sync factor +(@code{MachineVideoStandard=1}). + +@findex -ntsc +@item -ntsc +Use NTSC sync factor +(@code{MachineVideoStandard=2}). + @findex -VICvcache, +VICvcache @item -VICvcache @itemx +VICvcache @@ -23618,6 +23882,8 @@ Final Expansion @item mega Mega-Cart +@item mini +Minimon @item ma Mikro Assembler @item rabbit @@ -35277,6 +35543,50 @@ @c FIXME: cartridge details @c @node FIXME +@subsubsection 10 - Minimon + +@multitable @columnfractions .3 .7 +@item Size +@tab 2KiB (ROM) +@end multitable + +@example + 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F ASCII + ----------------------------------------------- ---------------- + 0000: 56 49 43 32 30 20 43 41 52 54 52 49 44 47 45 20 VIC20 CARTRIDGE + 0010: 00 00 00 40 02 00 00 0a 00 00 00 00 00 00 00 00 ...@............ + 0020: 4d 69 6e 69 6d 6f 6e 00 00 00 00 00 00 00 00 00 Minimon......... + 0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 0040: 43 48 49 50 00 00 08 10 00 00 00 00 98 00 08 00 CHIP............ + 0050: 20 a2 9f a2 00 8e 12 01 20 e2 9f 0d 4d 4f 4e 49 ....... ...MONI + 0060: 54 4f 52 0d 00 90 14 d8 a2 05 68 9d 10 01 ca 10 TOR.......h..... + 0070: f9 20 e2 9f 0d 42 52 45 41 4b 00 a9 c0 85 9d ba . ...BREAK...... + 0080: 8e 16 01 a9 00 85 c1 85 c2 58 20 e2 9f 0d 20 20 .........X ... + 0090: 50 43 20 20 53 52 20 41 43 20 58 52 20 59 52 20 PC SR AC XR YR + +@dots{} + 0830: ff ff 68 85 22 68 85 23 e6 22 d0 02 e6 23 a0 00 ..h."h.#."...#.. + 0840: b1 22 f0 05 20 d2 ff 90 ef a5 23 48 a5 22 48 60 .".. .....#H."H` +@end example + +This cartridge maps 2KiB ROM into the IO2 and IO3 area ($9800 - $9fff). It (the +monitor) can be started by SYS38912. + +The cartridge has two switches: + +@itemize @bullet +@item PGM: when enabled, the memory in the socket can be written to (when it is SRAM + or EEPROM) +@item CART/MON: when in MON position, the ROM is mapped into IO. in CART position + the IO is mapped transparent to the pass through port. +@end itemize + +"Freeze" (a long press on the reset button on the original cartridge) will +trigger a reset, and inhibit reads to BLK5 for ~300ms, to prevent a CBMA0 cart +from starting. + + +@c @node FIXME @subsection PLUS4 Cartridge Specifics @multitable @columnfractions .1 .9 Modified: trunk/vice/src/arch/gtk3/uimachinemenu.c =================================================================== --- trunk/vice/src/arch/gtk3/uimachinemenu.c 2025-05-08 06:21:00 UTC (rev 45664) +++ trunk/vice/src/arch/gtk3/uimachinemenu.c 2025-05-10 17:14:22 UTC (rev 45665) @@ -387,7 +387,7 @@ /* {{{ file_menu_cart_freeze */ /** \brief 'File' menu - cartridge section for C64/C128 * - * C64, SCPU64 and C128, containing "Cartridge freeze". + * VIC20, C64, SCPU64 and C128, containing "Cartridge freeze". */ static const ui_menu_item_t file_menu_cart_freeze[] = { { .label = "Attach cartridge image...", @@ -1093,7 +1093,7 @@ case VICE_MACHINE_VIC20: file_menu_tape_section = file_menu_tape; - file_menu_cart_section = file_menu_cart_no_freeze; + file_menu_cart_section = file_menu_cart_freeze; file_menu_printer_section = file_menu_printer; break; Modified: trunk/vice/src/arch/gtk3/uisettings.c =================================================================== --- trunk/vice/src/arch/gtk3/uisettings.c 2025-05-08 06:21:00 UTC (rev 45664) +++ trunk/vice/src/arch/gtk3/uisettings.c 2025-05-10 17:14:22 UTC (rev 45665) @@ -114,6 +114,7 @@ # include "settings_midi.h" #endif #include "settings_misc.h" +#include "settings_minimon.h" #include "settings_megacart.h" #include "settings_mmc64.h" #include "settings_mmcr.h" @@ -687,6 +688,12 @@ UI_SETTINGS_SEPARATOR, + { CARTRIDGE_VIC20_NAME_MINIMON, + "Minimon", + settings_minimon_widget_create, NULL }, + + UI_SETTINGS_SEPARATOR, + /* Flash+EPROM Cartridges */ { CARTRIDGE_VIC20_NAME_FINAL_EXPANSION, Modified: trunk/vice/src/arch/gtk3/widgets/Makefile.am =================================================================== --- trunk/vice/src/arch/gtk3/widgets/Makefile.am 2025-05-08 06:21:00 UTC (rev 45664) +++ trunk/vice/src/arch/gtk3/widgets/Makefile.am 2025-05-10 17:14:22 UTC (rev 45665) @@ -147,6 +147,7 @@ settings_megacart.c \ settings_midi.c \ settings_misc.c \ + settings_minimon.c \ settings_mixer.c \ settings_mmc64.c \ settings_mmcr.c \ @@ -318,6 +319,7 @@ settings_megacart.h \ settings_midi.h \ settings_misc.h \ + settings_minimon.h \ settings_mixer.h \ settings_mmc64.h \ settings_mmcr.h \ Added: trunk/vice/src/arch/gtk3/widgets/settings_minimon.c =================================================================== --- trunk/vice/src/arch/gtk3/widgets/settings_minimon.c (rev 0) +++ trunk/vice/src/arch/gtk3/widgets/settings_minimon.c 2025-05-10 17:14:22 UTC (rev 45665) @@ -0,0 +1,148 @@ +/** \file settings_minimon.c + * \brief Settings widget to control MINIMON resources + * + * \author Bas Wassink <b.w...@zi...> + * \author Groepaz + */ + +/* + * $VICERES MinimonEnabled xvic + * $VICERES MinimonFilename xvic + * $VICERES MinimonPgmSwitch xvic + * $VICERES MinimonIoSwitch xvic + * $VICERES MinimonImageWrite xvic + */ + +/* + * 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_minimon.h" + + +/** \brief Create MINIMON switch button + * + * \return GtkCheckButton + */ +static GtkWidget *create_minimon_switch_widget(void) +{ + GtkWidget *grid; + GtkWidget *label; + GtkWidget *button; + + grid = gtk_grid_new(); + gtk_grid_set_column_spacing(GTK_GRID(grid), 16); + + label = gtk_label_new(" RO/PGM"); + gtk_grid_attach(GTK_GRID(grid), label, 0, 0, 1, 1); + + button = vice_gtk3_resource_switch_new("MinimonPgmSwitch"); + gtk_grid_attach(GTK_GRID(grid), button, 1, 0, 1, 1); + gtk_widget_show_all(grid); + + return grid; +} + +/** \brief Create MINIMON switch button + * + * \return GtkCheckButton + */ +static GtkWidget *create_minimon_ioswitch_widget(void) +{ + GtkWidget *grid; + GtkWidget *label; + GtkWidget *button; + + grid = gtk_grid_new(); + gtk_grid_set_column_spacing(GTK_GRID(grid), 16); + + label = gtk_label_new(" CART/MON"); + gtk_grid_attach(GTK_GRID(grid), label, 0, 0, 1, 1); + + button = vice_gtk3_resource_switch_new("MinimonIoSwitch"); + gtk_grid_attach(GTK_GRID(grid), button, 1, 0, 1, 1); + gtk_widget_show_all(grid); + + return grid; +} + + +/** \brief Create widget to load/save MINIMON image file + * + * \return GtkGrid + */ +static GtkWidget *create_minimon_image_widget(void) +{ + GtkWidget *image; + + image = cart_image_widget_new(CARTRIDGE_VIC20_MINIMON, + CARTRIDGE_VIC20_NAME_MINIMON, + CART_IMAGE_PRIMARY, + "ROM", + "MinimonFilename", + TRUE, + TRUE); + cart_image_widget_append_check(image, + "MinimonImageWrite", + "Write image on detach/emulator exit"); + return image; +} + + +/** \brief Create widget to control MINIMON resources + * + * \param[in] parent parent widget (unused) + * + * \return GtkGrid + */ +GtkWidget *settings_minimon_widget_create(GtkWidget *parent) +{ + GtkWidget *grid; + GtkWidget *enable; + GtkWidget *image; + GtkWidget *toggle; + GtkWidget *toggle2; + + grid = gtk_grid_new(); + gtk_grid_set_row_spacing(GTK_GRID(grid), 32); + + enable = carthelpers_create_enable_check_button(CARTRIDGE_VIC20_NAME_MINIMON, + CARTRIDGE_VIC20_MINIMON); + toggle = create_minimon_switch_widget(); + toggle2 = create_minimon_ioswitch_widget(); + image = create_minimon_image_widget(); + gtk_widget_set_hexpand(toggle, TRUE); + gtk_widget_set_halign(toggle, GTK_ALIGN_END); + + gtk_grid_attach(GTK_GRID(grid), enable, 0, 0, 1, 1); + gtk_grid_attach(GTK_GRID(grid), toggle, 1, 0, 1, 1); + gtk_grid_attach(GTK_GRID(grid), toggle2, 2, 0, 1, 1); + + gtk_grid_attach(GTK_GRID(grid), image, 0, 1, 3, 1); + + gtk_widget_show_all(grid); + return grid; +} Added: trunk/vice/src/arch/gtk3/widgets/settings_minimon.h =================================================================== --- trunk/vice/src/arch/gtk3/widgets/settings_minimon.h (rev 0) +++ trunk/vice/src/arch/gtk3/widgets/settings_minimon.h 2025-05-10 17:14:22 UTC (rev 45665) @@ -0,0 +1,35 @@ +/** \file settings_minimon.h + * \brief Settings widget to control MINIMON 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_MINIMON_H +#define VICE_SETTINGS_MINIMON_H + +#include <gtk/gtk.h> + +GtkWidget *settings_minimon_widget_create(GtkWidget *parent); + +#endif Modified: trunk/vice/src/arch/sdl/actions-cartridge.c =================================================================== --- trunk/vice/src/arch/sdl/actions-cartridge.c 2025-05-08 06:21:00 UTC (rev 45664) +++ trunk/vice/src/arch/sdl/actions-cartridge.c 2025-05-10 17:14:22 UTC (rev 45665) @@ -125,6 +125,10 @@ .handler = sdl_ui_activate_item_action, .dialog = true }, + { .action = ACTION_CART_ATTACH_RAW_MINIMON, + .handler = sdl_ui_activate_item_action, + .dialog = true + }, { .action = ACTION_CART_ATTACH_RAW_ULTIMEM, .handler = sdl_ui_activate_item_action, .dialog = true @@ -136,6 +140,9 @@ { .action = ACTION_CART_DETACH, .handler = cart_detach_action }, + { .action = ACTION_CART_FREEZE, + .handler = cart_freeze_action + }, UI_ACTION_MAP_TERMINATOR }; Modified: trunk/vice/src/arch/sdl/menu_vic20cart.c =================================================================== --- trunk/vice/src/arch/sdl/menu_vic20cart.c 2025-05-08 06:21:00 UTC (rev 45664) +++ trunk/vice/src/arch/sdl/menu_vic20cart.c 2025-05-10 17:14:22 UTC (rev 45665) @@ -55,6 +55,7 @@ { CARTRIDGE_VIC20_FP, "VicFlashPluginWriteBack", NULL }, { CARTRIDGE_VIC20_UM, "UltiMemWriteBack", NULL }, { CARTRIDGE_VIC20_FINAL_EXPANSION, "FinalExpansionWriteBack", NULL }, + { CARTRIDGE_VIC20_MINIMON, "MinimonImageWrite", "MinimonFilename" }, { 0, NULL, NULL } }; @@ -233,6 +234,10 @@ title = "Select " CARTRIDGE_VIC20_NAME_MEGACART " image"; action = ACTION_CART_ATTACH_RAW_MEGACART; break; + case CARTRIDGE_VIC20_MINIMON: + title = "Select " CARTRIDGE_VIC20_NAME_MINIMON " image"; + action = ACTION_CART_ATTACH_RAW_MINIMON; + break; case CARTRIDGE_VIC20_FINAL_EXPANSION: title = "Select " CARTRIDGE_VIC20_NAME_FINAL_EXPANSION " image"; action = ACTION_CART_ATTACH_RAW_FINAL; @@ -434,16 +439,64 @@ UI_MENU_DEFINE_TOGGLE(MegaCartNvRAMWriteBack) UI_MENU_DEFINE_FILE_STRING(MegaCartNvRAMfilename) +UI_MENU_DEFINE_TOGGLE(MinimonEnabled) +UI_MENU_DEFINE_TOGGLE(MinimonImageWrite) +UI_MENU_DEFINE_FILE_STRING(MinimonFilename) +UI_MENU_DEFINE_TOGGLE(MinimonIoSwitch) +UI_MENU_DEFINE_TOGGLE(MinimonPgmSwitch) + +#define OFFS_FLUSH_MINI 8 #define OFFS_FLUSH_FE 2 #define OFFS_FLUSH_UM 2 #define OFFS_FLUSH_FP 2 #define OFFS_FLUSH_MEGACART 3 +#define OFFS_SAVE_MINI 9 #define OFFS_SAVE_FE 3 #define OFFS_SAVE_UM 3 #define OFFS_SAVE_FP 3 #define OFFS_SAVE_MEGACART 4 +static ui_menu_entry_t minimon_cart_menu[] = { + { .string = "Enable " CARTRIDGE_VIC20_NAME_MINIMON, /* 0 */ + .type = MENU_ENTRY_RESOURCE_TOGGLE, + .callback = toggle_MinimonEnabled_callback + }, + SDL_MENU_ITEM_SEPARATOR, /* 1 */ + + { .string = "enable ROM in IO2/3", /* 2 */ + .type = MENU_ENTRY_RESOURCE_TOGGLE, + .callback = toggle_MinimonIoSwitch_callback + }, + { .string = "enable PGM switch", /* 3 */ + .type = MENU_ENTRY_RESOURCE_TOGGLE, + .callback = toggle_MinimonPgmSwitch_callback + }, + SDL_MENU_ITEM_SEPARATOR, /* 4 */ + + SDL_MENU_ITEM_TITLE(CARTRIDGE_VIC20_NAME_MINIMON " image"), /* 5 */ + { .string = "Image file", /* 6 */ + .type = MENU_ENTRY_DIALOG, + .callback = file_string_MinimonFilename_callback, + .data = (ui_callback_data_t)"Select " CARTRIDGE_VIC20_NAME_MINIMON " ROM image" + }, + { .string = "Save image on detach.", /* 7 */ + .type = MENU_ENTRY_RESOURCE_TOGGLE, + .callback = toggle_MinimonImageWrite_callback + }, + { .string = "Save image now", /* 8 */ + .type = MENU_ENTRY_OTHER, + .callback = vic20_cart_flush_callback, + .data = (ui_callback_data_t)CARTRIDGE_VIC20_MINIMON + }, + { .string = "Save image as", /* 9 */ + .type = MENU_ENTRY_OTHER, + .callback = vic20_cart_save_callback, + .data = (ui_callback_data_t)CARTRIDGE_VIC20_MINIMON + }, + SDL_MENU_LIST_END +}; + static ui_menu_entry_t finalexpansion_cart_menu[] = { SDL_MENU_ITEM_TITLE(CARTRIDGE_VIC20_NAME_FINAL_EXPANSION " settings"), { .string = "Save image on detach.", @@ -816,20 +869,28 @@ static void cartmenu_update_flush(void) { - georam_menu[12].status = cartridge_can_flush_image(CARTRIDGE_VIC20_GEORAM) ? MENU_STATUS_ACTIVE : MENU_STATUS_INACTIVE; + /* slot 0 */ + minimon_cart_menu[OFFS_FLUSH_MINI].status = cartridge_can_flush_image(CARTRIDGE_VIC20_MINIMON) ? MENU_STATUS_ACTIVE : MENU_STATUS_INACTIVE; + /* main slot */ megacart_cart_menu[OFFS_FLUSH_MEGACART].status = cartridge_can_flush_secondary_image(CARTRIDGE_VIC20_MEGACART) ? MENU_STATUS_ACTIVE : MENU_STATUS_INACTIVE; vic_um_cart_menu[OFFS_FLUSH_UM].status = cartridge_can_flush_image(CARTRIDGE_VIC20_UM) ? MENU_STATUS_ACTIVE : MENU_STATUS_INACTIVE; vic_fp_cart_menu[OFFS_FLUSH_FP].status = cartridge_can_flush_image(CARTRIDGE_VIC20_FP) ? MENU_STATUS_ACTIVE : MENU_STATUS_INACTIVE; finalexpansion_cart_menu[OFFS_FLUSH_FE].status = cartridge_can_flush_image(CARTRIDGE_VIC20_FINAL_EXPANSION) ? MENU_STATUS_ACTIVE : MENU_STATUS_INACTIVE; + /* io slot */ + georam_menu[12].status = cartridge_can_flush_image(CARTRIDGE_VIC20_GEORAM) ? MENU_STATUS_ACTIVE : MENU_STATUS_INACTIVE; } static void cartmenu_update_save(void) { - georam_menu[13].status = cartridge_can_save_image(CARTRIDGE_VIC20_GEORAM) ? MENU_STATUS_ACTIVE : MENU_STATUS_INACTIVE; + /* slot 0 */ + minimon_cart_menu[OFFS_SAVE_MINI].status = cartridge_can_save_image(CARTRIDGE_VIC20_MINIMON) ? MENU_STATUS_ACTIVE : MENU_STATUS_INACTIVE; + /* main slot */ megacart_cart_menu[OFFS_SAVE_FE].status = cartridge_can_save_secondary_image(CARTRIDGE_VIC20_MEGACART) ? MENU_STATUS_ACTIVE : MENU_STATUS_INACTIVE; vic_um_cart_menu[OFFS_SAVE_UM].status = cartridge_can_save_image(CARTRIDGE_VIC20_UM) ? MENU_STATUS_ACTIVE : MENU_STATUS_INACTIVE; vic_fp_cart_menu[OFFS_SAVE_FP].status = cartridge_can_save_image(CARTRIDGE_VIC20_FP) ? MENU_STATUS_ACTIVE : MENU_STATUS_INACTIVE; finalexpansion_cart_menu[OFFS_SAVE_FE].status = cartridge_can_save_image(CARTRIDGE_VIC20_FINAL_EXPANSION) ? MENU_STATUS_ACTIVE : MENU_STATUS_INACTIVE; + /* io slot */ + georam_menu[13].status = cartridge_can_save_image(CARTRIDGE_VIC20_GEORAM) ? MENU_STATUS_ACTIVE : MENU_STATUS_INACTIVE; } /* Cartridge menu */ @@ -864,6 +925,12 @@ .callback = attach_cart_callback, .data = (ui_callback_data_t)CARTRIDGE_VIC20_MEGACART }, + { .action = ACTION_CART_ATTACH_RAW_MINIMON, + .string = "Attach " CARTRIDGE_VIC20_NAME_MINIMON " image", + .type = MENU_ENTRY_DIALOG, + .callback = attach_cart_callback, + .data = (ui_callback_data_t)CARTRIDGE_VIC20_MINIMON + }, { .action = ACTION_CART_ATTACH_RAW_FINAL, .string = "Attach " CARTRIDGE_VIC20_NAME_FINAL_EXPANSION " image", .type = MENU_ENTRY_DIALOG, @@ -934,6 +1001,11 @@ .callback = submenu_callback, .data = (ui_callback_data_t)megacart_cart_menu }, + { .string = CARTRIDGE_VIC20_NAME_MINIMON, + .type = MENU_ENTRY_SUBMENU, + .callback = submenu_callback, + .data = (ui_callback_data_t)minimon_cart_menu + }, { .string = "I/O-2 RAM", .type = MENU_ENTRY_RESOURCE_TOGGLE, .callback = toggle_IO2RAM_callback Modified: trunk/vice/src/arch/shared/uiactions.c =================================================================== --- trunk/vice/src/arch/shared/uiactions.c 2025-05-08 06:21:00 UTC (rev 45664) +++ trunk/vice/src/arch/shared/uiactions.c 2025-05-10 17:14:22 UTC (rev 45665) @@ -212,7 +212,7 @@ { ACTION_CART_ATTACH_RAW_C2_HIGH, "cart-attach-raw-c2-high", "Attach high C2 cartridge image", VICE_MACHINE_PLUS4 }, { ACTION_CART_DETACH, "cart-detach", "Detach cartridge", (VICE_MACHINE_C64|VICE_MACHINE_C64SC|VICE_MACHINE_SCPU64|VICE_MACHINE_C128| VICE_MACHINE_VIC20|VICE_MACHINE_PLUS4|VICE_MACHINE_CBM6x0) }, - { ACTION_CART_FREEZE, "cart-freeze", "Press cartridge freeze button", (VICE_MACHINE_C64|VICE_MACHINE_C64SC|VICE_MACHINE_SCPU64|VICE_MACHINE_C128) }, + { ACTION_CART_FREEZE, "cart-freeze", "Press cartridge freeze button", (VICE_MACHINE_C64|VICE_MACHINE_C64SC|VICE_MACHINE_SCPU64|VICE_MACHINE_C128|VICE_MACHINE_VIC20) }, { ACTION_CART_DETACH_1000, "cart-detach-1000", "Detach cartridge image at $1000", VICE_MACHINE_CBM6x0 }, { ACTION_CART_DETACH_2000, "cart-detach-2000", "Detach cartridge image at $2000", VICE_MACHINE_CBM6x0 }, { ACTION_CART_DETACH_4000, "cart-detach-4000", "Detach cartridge image at $4000", VICE_MACHINE_CBM6x0 }, Modified: trunk/vice/src/arch/shared/uiactions.h =================================================================== --- trunk/vice/src/arch/shared/uiactions.h 2025-05-08 06:21:00 UTC (rev 45664) +++ trunk/vice/src/arch/shared/uiactions.h 2025-05-10 17:14:22 UTC (rev 45665) @@ -120,8 +120,10 @@ ACTION_CART_ATTACH_RAW_BEHRBONZ, /* VIC-20 */ ACTION_CART_ATTACH_RAW_FINAL, /* VIC-20 */ ACTION_CART_ATTACH_RAW_MEGACART, /* VIC-20 */ + ACTION_CART_ATTACH_RAW_MINIMON, /* VIC-20 */ ACTION_CART_ATTACH_RAW_ULTIMEM, /* VIC-20 */ ACTION_CART_ATTACH_RAW_VICFP, /* VIC-20 */ + ACTION_CART_ATTACH_RAW_WRITENOW, /* VIC-20 */ ACTION_CART_ATTACH_RAW_JACINT1MB, /* Plus/4 */ ACTION_CART_ATTACH_RAW_MAGIC, /* Plus/4 */ ACTION_CART_ATTACH_RAW_MULTI, /* Plus/4 */ Modified: trunk/vice/src/cartridge.h =================================================================== --- trunk/vice/src/cartridge.h 2025-05-08 06:21:00 UTC (rev 45664) +++ trunk/vice/src/cartridge.h 2025-05-10 17:14:22 UTC (rev 45665) @@ -479,8 +479,9 @@ #define CARTRIDGE_VIC20_SUPEREXPANDER 7 /* superexpander.c */ #define CARTRIDGE_VIC20_MIKRO_ASSEMBLER 8 /* mikroassembler.c */ #define CARTRIDGE_VIC20_WRITE_NOW 9 /* writenow.c */ +#define CARTRIDGE_VIC20_MINIMON 10 /* minimon.c */ -#define CARTRIDGE_VIC20_LAST 9 /* cartconv: last cartridge in list */ +#define CARTRIDGE_VIC20_LAST 10 /* cartconv: last cartridge in list */ /* * VIC20 Generic cartridges @@ -545,6 +546,7 @@ #define CARTRIDGE_VIC20_NAME_IO3_RAM "I/O-3 RAM" #define CARTRIDGE_VIC20_NAME_IEEE488 "VIC-1112 IEEE-488 Interface" /*https://sleepingelephant.com/denial/wiki/index.php/File:Chipitos.be-VIC-1112.jpg */ #define CARTRIDGE_VIC20_NAME_MIDI "MIDI" +#define CARTRIDGE_VIC20_NAME_MINIMON "Minimon" #define CARTRIDGE_VIC20_NAME_SIDCART "SIDCART" #define CARTRIDGE_VIC20_NAME_RABBIT "Rabbit Tape" #define CARTRIDGE_VIC20_NAME_SUPEREXPANDER "Super Expander" @@ -639,8 +641,10 @@ #define CARTRIDGE_SIZE_8MB CARTRIDGE_SIZE_8192KB #define CARTRIDGE_SIZE_16MB CARTRIDGE_SIZE_16384KB -#define CARTRIDGE_FILETYPE_BIN 1 -#define CARTRIDGE_FILETYPE_CRT 2 +#define CARTRIDGE_FILETYPE_NONE 0 /* implies "no file" */ +#define CARTRIDGE_FILETYPE_BIN 1 +#define CARTRIDGE_FILETYPE_CRT 2 +#define CARTRIDGE_FILETYPE_SNAPSHOT 3 /* file is embedded into a snapshot */ /* FIXME: merge the cartridge list with the one used by cartconv */ Modified: trunk/vice/src/drive/iec/memiec.c =================================================================== --- trunk/vice/src/drive/iec/memiec.c 2025-05-08 06:21:00 UTC (rev 45664) +++ trunk/vice/src/drive/iec/memiec.c 2025-05-10 17:14:22 UTC (rev 45665) @@ -43,7 +43,7 @@ #include "cmdhd.h" -#define DEBUG_MEMIEC +/* #define DEBUG_MEMIEC */ #ifdef DEBUG_MEMIEC #define LOG(x) log_printf x Modified: trunk/vice/src/tools/cartconv/vic20-cartridges.c =================================================================== --- trunk/vice/src/tools/cartconv/vic20-cartridges.c 2025-05-08 06:21:00 UTC (rev 45664) +++ trunk/vice/src/tools/cartconv/vic20-cartridges.c 2025-05-10 17:14:22 UTC (rev 45665) @@ -32,6 +32,7 @@ /* FIXME: second bank should go to a000 */ {0, 0, CARTRIDGE_SIZE_8KB, 0x1000, 0x6000, 2, CRT_CHIP_ROM, CARTRIDGE_VIC20_NAME_MIKRO_ASSEMBLER, "ma", save_regular_crt}, {0, 0, CARTRIDGE_SIZE_8KB, 0x2000, 0xA000, 1, CRT_CHIP_ROM, CARTRIDGE_VIC20_NAME_WRITE_NOW, "wn", save_regular_crt}, + {0, 0, CARTRIDGE_SIZE_2KB, 0x0800, 0x9800, 1, CRT_CHIP_ROM, CARTRIDGE_VIC20_NAME_MINIMON, "mini", save_regular_crt}, {0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL} }; Modified: trunk/vice/src/vic20/cart/Makefile.am =================================================================== --- trunk/vice/src/vic20/cart/Makefile.am 2025-05-08 06:21:00 UTC (rev 45664) +++ trunk/vice/src/vic20/cart/Makefile.am 2025-05-10 17:14:22 UTC (rev 45665) @@ -31,6 +31,8 @@ megacart.h \ mikroassembler.c \ mikroassembler.h \ + minimon.c \ + minimon.h \ rabbit.c \ rabbit.h \ superexpander.c \ Added: trunk/vice/src/vic20/cart/minimon.c =================================================================== --- trunk/vice/src/vic20/cart/minimon.c (rev 0) +++ trunk/vice/src/vic20/cart/minimon.c 2025-05-10 17:14:22 UTC (rev 45665) @@ -0,0 +1,853 @@ +/* + * minimon.c -- VIC20 "Minimon" Cartridge emulation. + * + * Written by + * 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 <stdlib.h> +#include <string.h> + +#include "archdep.h" +#include "alarm.h" +#include "minimon.h" +#include "cartio.h" +#include "cartridge.h" +#include "cmdline.h" +#include "crt.h" +#include "export.h" +#include "lib.h" +#include "log.h" +#include "machine.h" +#include "maincpu.h" +#include "mem.h" +#include "monitor.h" +#include "ram.h" +#include "resources.h" +#include "snapshot.h" +#include "types.h" +#include "util.h" +#include "vic20cart.h" +#include "vic20cartmem.h" +#include "vic20mem.h" +#include "zfile.h" + +/* #define DEBUGMINIMON */ + +#ifdef DEBUGMINIMON +#define DBG(x) log_printf x +#else +#define DBG(x) +#endif + +/* + + "Minimon" + + - 2KiB ROM mapped into IO2/IO3 ($9800-$9BFF, $9C00-9FFF) + + The Cartridge has two switches and one button: + + - the MON/CART switch essentially enables/disables the cartridge, it either + routes IO2/3 accesses to the cartridge ROM or to the pass-through port. + + - the PGM switch enables writing to the cartridge (which obviously only + works if there is static RAM or EEPROM in the socket, which again is + completely optional) + + - the reset button performs two functions: + - Reset (short) is just that, a regular reset + - Reset (long) resets and briefly "disables" a BLK5 cartridge on the pass- + through port to prevent it from starting. The pass through port will + also not "see" reset. + The reset logic is available all the time. + + test: + + xvic -debug -cartA Poker-a000.prg -cartmini monitor.bin + +*/ + +/* ------------------------------------------------------------------------- */ +static const char STRING_MINIMON[] = CARTRIDGE_VIC20_NAME_MINIMON; + +#define CART_ROM_SIZE (0x400 * 2) +static uint8_t *minimon_rom = NULL; +static int minimon_bios_type = 0; /* flag: type of loaded file */ + +static int minimon_enabled = 0; /* resource, is minimon cartridge attached? */ +static int minimon_io_enabled = 0; /* resource, is minimon ROM in IO enabled? (MON/CART) */ +static int minimon_pgm_enabled = 0; /* resource, is minimon ROM writeable? (PGM) */ + +static int minimon_bios_write = 0; /* resource: write back the ROM when it was changed? */ + +static char *minimon_image_filename = NULL; /* resource: ROM filename */ +static int minimon_bios_changed = 0; /* flag: was the ROM written to? */ + +static int minimon_io23_temp = 0; + +/* ------------------------------------------------------------------------- */ + +static int freeze_triggered = 0; /* if not 0, a "freeze reset" was just triggered */ + +struct alarm_s *minimon_alarm; +static CLOCK freeze_timeout = 0; +static int freeze_bkl5_temp = 0; + +/* this should be ~300ms */ +#define FREEZE_DELAY (1000000UL / 3UL) + +#define ALARM_FREQ (1000000UL / 100UL) + +static void minimon_trigger_alarm(void) +{ + freeze_timeout = CLOCK_MAX; + alarm_unset(minimon_alarm); + + /* HACK: mem_cart_blocks is reserved for main slot */ + /* remember blk5 config */ + freeze_bkl5_temp |= (mem_cart_blocks & VIC_CART_BLK5); + /* "unmap" blk5, so our blk5 hook gets called instead */ + mem_cart_blocks &= ~(VIC_CART_BLK5); + mem_initialize_memory(); + + freeze_timeout = maincpu_clk + FREEZE_DELAY; /* ~ 300ms */ + alarm_set(minimon_alarm, maincpu_clk + ALARM_FREQ); + freeze_triggered = 1; + + DBG(("minimon_trigger_alarm %"PRIu64" (start freeze, timeout: %"PRIu64")", maincpu_clk, freeze_timeout)); +} + +static void minimon_alarm_handler(CLOCK offset, void *data) +{ + if (maincpu_clk < freeze_timeout) { + alarm_set(minimon_alarm, maincpu_clk + ALARM_FREQ); + /* DBG(("minimon_alarm_handler %"PRIu64"", maincpu_clk)); */ + return; + } + freeze_timeout = CLOCK_MAX; + alarm_unset(minimon_alarm); + + DBG(("minimon_alarm_handler %"PRIu64" (end freeze)", maincpu_clk)); + freeze_triggered = 0; + + /* HACK: mem_cart_blocks is reserved for main slot */ + /* restore blk5 config */ + mem_cart_blocks |= freeze_bkl5_temp; + mem_initialize_memory(); + freeze_bkl5_temp = 0; +} + +static void minimon_alarm_install(void) +{ + DBG(("minimon_alarm_install")); + if (minimon_alarm == NULL) { + minimon_alarm = alarm_new(maincpu_alarm_context, "MinimonAlarm", minimon_alarm_handler, NULL); + } + freeze_timeout = CLOCK_MAX; +} + +static void minimon_alarm_deinstall(void) +{ + DBG(("minimon_alarm_deinstall")); + alarm_destroy(minimon_alarm); + minimon_alarm = NULL; + freeze_triggered = 0; +} + +/* ------------------------------------------------------------------------- */ + +/* Some prototypes are needed */ +static uint8_t minimon_io2_read(uint16_t addr); +static uint8_t minimon_io3_read(uint16_t addr); +static void minimon_io2_write(uint16_t addr, uint8_t value); +static void minimon_io3_write(uint16_t addr, uint8_t value); +static int minimon_mon_dump(void); + +static io_source_t minimon_io2_device = { + CARTRIDGE_VIC20_NAME_MINIMON, /* 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 */ + 0x9800, 0x9bff, 0x3ff, /* range for the device */ + 1, /* read is always valid */ + minimon_io2_write, /* store function */ + NULL, /* poke function */ + minimon_io2_read, /* read function */ + NULL, /* NO peek function */ + minimon_mon_dump, /* device state information dump function */ + CARTRIDGE_VIC20_MINIMON, /* cartridge ID */ + IO_PRIO_NORMAL, /* 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 io_source_list_t *minimon_io2_list_item = NULL; + +static io_source_t minimon_io3_device = { + CARTRIDGE_VIC20_NAME_MINIMON, /* 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 */ + 0x9c00, 0x9fff, 0x3ff, /* range for the device, address is ignored, reg:$9c00, mirrors:$9c01-$9fff */ + 1, /* read is always valid */ + minimon_io3_write, /* store function */ + NULL, /* poke function */ + minimon_io3_read, /* read function */ + NULL, /* NO peek function */ + minimon_mon_dump, /* device state information dump function */ + CARTRIDGE_VIC20_MINIMON, /* cartridge ID */ + IO_PRIO_NORMAL, /* 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 io_source_list_t *minimon_io3_list_item = NULL; + +static const export_resource_t export_res23 = { + CARTRIDGE_VIC20_NAME_MINIMON, 0, 0, &minimon_io2_device, &minimon_io3_device, CARTRIDGE_VIC20_MINIMON +}; + +/* (only) register the io devices */ +static int io_register(void) +{ + /* HACK: mem_cart_blocks is reserved for main slot */ + minimon_io23_temp = mem_cart_blocks & (VIC_CART_IO2 | VIC_CART_IO3); + mem_cart_blocks |= (VIC_CART_IO2 | VIC_CART_IO3); + mem_initialize_memory(); + + if (minimon_io2_list_item != NULL) { + io_source_unregister(minimon_io2_list_item); + } + if (minimon_io3_list_item != NULL) { + io_source_unregister(minimon_io3_list_item); + } + minimon_io2_list_item = io_source_register(&minimon_io2_device); + minimon_io3_list_item = io_source_register(&minimon_io3_device); + + return 0; +} + +/* (only) un-register the io devices */ +static int io_unregister(void) +{ + if (minimon_io2_list_item != NULL) { + io_source_unregister(minimon_io2_list_item); + minimon_io2_list_item = NULL; + } + if (minimon_io3_list_item != NULL) { + io_source_unregister(minimon_io3_list_item); + minimon_io3_list_item = NULL; + } + /* HACK: mem_cart_blocks is reserved for main slot */ + mem_cart_blocks &= ~(VIC_CART_IO2 | VIC_CART_IO3); + mem_cart_blocks |= minimon_io23_temp; + mem_initialize_memory(); + + return 0; +} + +/* ------------------------------------------------------------------------- */ + +static uint8_t minimon_io2_read(uint16_t addr) +{ + return minimon_rom[0x000 + (addr & 0x3ff)]; +} + +static uint8_t minimon_io3_read(uint16_t addr) +{ + 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; + } +} + +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; + } +} + +static int minimon_mon_dump(void) +{ + mon_out("PGM is %s.\n", minimon_pgm_enabled ? "enabled" : "disabled"); + mon_out("ROM in IO2/3 is %s.\n", minimon_io_enabled ? "enabled" : "disabled"); + return 0; +} + +/* ------------------------------------------------------------------------- */ + +/* read 0xa000-0xbfff */ +int minimon_blk5_read(uint16_t addr, uint8_t *value) +{ + if (freeze_triggered) { + /* inhibit reads for ~300ms */ + DBG(("minimon_blk5_read 0x%04x (ignored)", addr)); + *value = 0xff; + return CART_READ_VALID; + } + /* read from secondary cartridge */ + /*DBG(("minimon_blk5_read 0x%04x", addr));*/ + return CART_READ_THROUGH; +} + +/* ------------------------------------------------------------------------- */ + + +/* FIXME: this still needs to be tweaked to match the hardware */ +static RAMINITPARAM ramparam = { + .start_value = 255, + .value_invert = 2, + .value_offset = 1, + + .pattern_invert = 0x100, + .pattern_invert_value = 255, + + .random_start = 0, + .random_repeat = 0, + .random_chance = 0, +}; + +static void allocate_rom(void) +{ + if (!minimon_rom) { + DBG(("allocate_rom: allocate buffer")); + minimon_rom = lib_malloc(CART_ROM_SIZE); + } + DBG(("allocate_rom: clear buffer with pattern")); + ram_init_with_pattern(minimon_rom, CART_ROM_SIZE, &ramparam); +} + +void minimon_freeze(void) +{ + DBG(("minimon_freeze")); + /* trigger reset first (resets cycle count) */ + machine_trigger_reset(MACHINE_RESET_MODE_RESET_CPU); + minimon_trigger_alarm(); + +} + +void minimon_reset(void) +{ + if (freeze_triggered) { + DBG(("minimon_reset (freeze)")); + /* retrigger the alarm, else the cycle count is off */ + minimon_trigger_alarm(); + } else { + DBG(("minimon_reset (regular)")); + } +} + +void minimon_powerup(void) +{ + DBG(("minimon_powerup")); + freeze_triggered = 0; + allocate_rom(); + /* FIXME: no ROM loaded yet */ +} + +/* ------------------------------------------------------------------------- */ + +static const cmdline_option_t cmdline_options[] = +{ + { "-minimon", SET_RESOURCE, CMDLINE_ATTRIB_NONE, + NULL, NULL, "MinimonEnabled", (resource_value_t)1, + NULL, "Enable the Minimon expansion" }, + { "+minimon", SET_RESOURCE, CMDLINE_ATTRIB_NONE, + NULL, NULL, "MinimonEnabled", (resource_value_t)0, + NULL, "Disable the Minimon expansion" }, + { "-minimonrom", SET_RESOURCE, CMDLINE_ATTRIB_NEED_ARGS, + NULL, NULL, "MinimonFilename", NULL, + "<Name>", "Specify name of Minimon ROM image" }, + { "-minimonrw", SET_RESOURCE, CMDLINE_ATTRIB_NONE, + NULL, NULL, "MinimonImageWrite", (resource_value_t)1, + NULL, "Save the Minimon ROM when changed" }, + { "-minimonro", SET_RESOURCE, CMDLINE_ATTRIB_NONE, + NULL, NULL, "MinimonImageWrite", (resource_value_t)0, + NULL, "Do not save the Minimon ROM when changed" }, + { "-minimonpgm", SET_RESOURCE, CMDLINE_ATTRIB_NONE, + NULL, NULL, "MinimonPgmSwitch", (resource_value_t)1, + NULL, "Set the Minimon PGM switch" }, + { "+minimonpgm", SET_RESOURCE, CMDLINE_ATTRIB_NONE, + NULL, NULL, "MinimonPgmSwitch", (resource_value_t)0, + NULL, "Remove the Minimon PGM switch" }, + { "-minimonio", SET_RESOURCE, CMDLINE_ATTRIB_NONE, + NULL, NULL, "MinimonIoSwitch", (resource_value_t)1, + NULL, "Set the Minimon IO switch" }, + { "+minimonio", SET_RESOURCE, CMDLINE_ATTRIB_NONE, + NULL, NULL, "MinimonIoSwitch", (resource_value_t)0, + NULL, "Remove the Minimon IO switch" }, + CMDLINE_LIST_END +}; + +int minimon_cmdline_options_init(void) +{ + if (cmdline_register_options(cmdline_options) < 0) { + return -1; + } + return 0; +} + +/* ------------------------------------------------------------------------- */ +/* get the MinimonFilename resource */ +const char *minimon_get_file_name(void) +{ + return minimon_image_filename; +} + +/* set the MinimonFilename resource */ +static int set_minimon_image_filename(const char *name, void *param) +{ + if (minimon_image_filename != NULL && name != NULL && strcmp(name, minimon_image_filename) == 0) { + return 0; + } + + if (name != NULL && *name != '\0') { + if (util_check_filename_access(name) < 0) { + return -1; + } + } + + if (minimon_enabled) { + minimon_flush_image(); + util_string_set(&minimon_image_filename, name); + } else { + util_string_set(&minimon_image_filename, name); + } + + return 0; +} + +/* get the MinimonEnabled resource */ +int minimon_cart_enabled(void) +{ + return minimon_enabled; +} + +/* 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) { + /* enable cartridge */ + if (export_add(&export_res23) < 0) { + return -1; + } + if (minimon_io_enabled) { + io_register(); + } + minimon_alarm_install(); + } else { + /* disable cartridge */ + io_unregister(); + minimon_alarm_deinstall(); + export_remove(&export_res23); + } + minimon_enabled = val; /* resource */ + + return 0; +} + +/* set the resource for the PGM switch */ +static int set_minimon_pgm_enabled(int value, void *param) +{ + minimon_pgm_enabled = (value == 0) ? 0 : 1; + DBG(("set_minimon_pgm_enabled: %d", minimon_pgm_enabled)); + return 0; +} + +/* set the resource for the IO aka CART/MON switch */ +static int set_minimon_io_enabled(int value, void *param) +{ + int new = (value == 0) ? 0 : 1; + DBG(("set_minimon_io_enabled: %d->%d", minimon_io_enabled, new)); + if (minimon_io_enabled != new) { + minimon_io_enabled = new; + minimon_alarm_deinstall(); + if (minimon_enabled) { + if (minimon_io_enabled) { + io_register(); + } else { + io_unregister(); + } + minimon_alarm_install(); + } + } + return 0; +} + +/* set "MinimonImageWrite" resource */ +static int set_minimon_bios_write(int value, void *param) +{ + minimon_bios_write = (value == 0) ? 0 : 1; + DBG(("set_minimon_bios_write: %d", minimon_bios_write)); + return 0; +} + +static const resource_string_t resources_string[] = { + { "MinimonFilename", "", RES_EVENT_NO, NULL, + &minimon_image_filename, set_minimon_image_filename, NULL }, + RESOURCE_STRING_LIST_END +}; + +static const resource_int_t resources_int[] = { + { "MinimonEnabled", 0, RES_EVENT_STRICT, (resource_value_t)0, + &minimon_enabled, set_minimon_enabled, (void *)1 }, + { "MinimonPgmSwitch", 0, RES_EVENT_NO, NULL, + &minimon_pgm_enabled, set_minimon_pgm_enabled, NULL }, + { "MinimonIoSwitch", 1, RES_EVENT_NO, NULL, + &minimon_io_enabled, set_minimon_io_enabled, NULL }, + { "MinimonImageWrite", 0, RES_EVENT_NO, NULL, + &minimon_bios_write, set_minimon_bios_write, NULL }, + RESOURCE_INT_LIST_END +}; + +int minimon_resources_init(void) +{ + if (resources_register_string(resources_string) < 0) { + return -1; + } + + return resources_register_int(resources_int); +} + +void minimon_resources_shutdown(void) +{ + if (minimon_image_filename) { + lib_free(minimon_image_filename); + } + minimon_image_filename = NULL; +} + +/* ------------------------------------------------------------------------- */ + + +static int zfile_load(const char *filename, uint8_t *dest, size_t size) +{ + FILE *fd; + off_t len; + + fd = zfile_fopen(filename, MODE_READ); + if (!fd) { + return -1; + } + len = archdep_file_size(fd); + if (len < 0 || (size_t)len != size) { + zfile_fclose(fd); + return -1; + } + if (fread(dest, size, 1, fd) < 1) { + zfile_fclose(fd); + return -1; + } + zfile_fclose(fd); + return 0; +} + +int minimon_crt_attach(FILE *fd, uint8_t *rawcart) +{ + crt_chip_header_t chip; + + allocate_rom(); + + if (crt_read_chip_header(&chip, fd)) { + goto exiterror; + } + + DBG(("chip at %02x len %02x\n", chip.start, chip.size)); + if (chip.size != CART_ROM_SIZE) { + goto exiterror; + } + + if (crt_read_chip(&minimon_rom[0], 0, &chip, fd)) { + goto exiterror; + } + + if (export_add(&export_res23) < 0) { + goto exiterror; + } + + io_register(); + + minimon_enabled = 1; /* resource */ + minimon_io_enabled = 1; /* resource */ + + minimon_alarm_install(); + + return CARTRIDGE_VIC20_MINIMON; + +exiterror: + minimon_detach(); + return -1; +} + +int minimon_bin_attach(const char *filename, uint8_t *rawcart) +{ + allocate_rom(); + + if (zfile_load(filename, minimon_rom, (size_t)CART_ROM_SIZE) < 0) { + minimon_detach(); + return -1; + } + + if (export_add(&export_res23) < 0) { + return -1; + } + + io_register(); + + minimon_enabled = 1; /* resource */ + minimon_io_enabled = 1; /* resource */ + + minimon_bios_type = CARTRIDGE_FILETYPE_BIN; + set_minimon_image_filename(filename, NULL); /* set the resource */ + + minimon_alarm_install(); + + return 0; +} + +int minimon_bin_save(const char *filename) +{ + /* FIXME */ + FILE *fd; + size_t ret; + + if (filename == NULL) { + return -1; + } + + if (minimon_rom == NULL) { + return -1; + } + + fd = fopen(filename, MODE_WRITE); + if (fd == NULL) { + return -1; + } + + ret = fwrite(minimon_rom, 1, CART_ROM_SIZE, fd); + fclose(fd); + if (ret != (CART_ROM_SIZE)) { + return -1; + } + minimon_bios_changed = 0; + return -1; +} + +int minimon_crt_save(const char *filename) +{ + /* FIXME */ + FILE *fd; + crt_chip_header_t chip; + + if (minimon_rom == NULL) { + return -1; + } + + fd = crt_create(filename, CARTRIDGE_VIC20_MINIMON, 0, 0, STRING_MINIMON); + + if (fd == NULL) { + return -1; + } + + chip.type = 2; + chip.size = CART_ROM_SIZE; + chip.start = 0x9800; + chip.bank = 0; + + if (crt_write_chip(minimon_rom, &chip, fd)) { + fclose(fd); + return -1; + } + + fclose(fd); + return -1; +} + +#if 0 +static int minimon_activate(void) +{ + minimon_bios_changed = 0; + /* mmc64_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_bios_filename); + } else { + ret = minimon_bin_save(minimon_bios_filename); + } + if (ret <= 0) { + return 0; /* FIXME */ + } + } + return 0; +} +#endif + +int minimon_flush_image(void) +{ + /* FIXME */ + int ret = -1; + 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; + return ret; +} + +void minimon_detach(void) +{ + minimon_alarm_deinstall(); + + io_unregister(); + + export_remove(&export_res23); + + lib_free(minimon_rom); + minimon_rom = NULL; + + minimon_enabled = 0; /* resource */ +} + + +int minimon_enable(void) +{ + return set_minimon_enabled(1, (void*)1); /* setup the resource */ +} + +int minimon_disable(void) +{ + return set_minimon_enabled(0, (void*)1); /* setup the resource */ +} + +/* ------------------------------------------------------------------------- */ + +/* MINIMON snapshot module format: + + type | name | description + --------------------------------------- + BYTE | active | cartridge active flag + BYTE | io rom | cartridge rom in io + BYTE | bios write | bios writable flag + BYTE | image readonly | image read-only flag + BYTE | bios changed | bios changed flag + ARRAY | BIOS | 2048 bytes of BIOS data ($9800-$9FFF) + + */ + +#define VIC20CART_DUMP_VER_MAJOR 0 +#define VIC20CART_DUMP_VER_MINOR 1 +#define SNAP_MODULE_NAME "MINIMON" + +int minimon_snapshot_write_module(snapshot_t *s) +{ + snapshot_module_t *m; + + m = snapshot_module_create(s, SNAP_MODULE_NAME, VIC20CART_DUMP_VER_MAJOR, VIC20CART_DUMP_VER_MINOR); + if (m == NULL) { + return -1; + } + + if (0 + || (SMW_B(m, (uint8_t)minimon_enabled) < 0) + || (SMW_B(m, (uint8_t)minimon_io_enabled) < 0) + || (SMW_B(m, (uint8_t)minimon_pgm_enabled) < 0) + || (SMW_B(m, (uint8_t)minimon_bios_write) < 0) + || (SMW_B(m, (uint8_t)minimon_bios_changed) < 0) + || (SMW_BA(m, minimon_rom,... [truncated message content] |
From: <co...@us...> - 2025-05-08 06:21:03
|
Revision: 45664 http://sourceforge.net/p/vice-emu/code/45664 Author: compyx Date: 2025-05-08 06:21:00 +0000 (Thu, 08 May 2025) Log Message: ----------- Joystick: split axis and button interpretation/calibration into separate functions Use seperate functions `joystick_axis_direction()` and `joystick_button_pressed()` to interpret raw values and apply calibration so the UI can also use these functions if required for mapping/calibration. Modified Paths: -------------- branches/compyx/joymap-003/vice/src/joyport/joystick.c branches/compyx/joymap-003/vice/src/joyport/joystick.h Modified: branches/compyx/joymap-003/vice/src/joyport/joystick.c =================================================================== --- branches/compyx/joymap-003/vice/src/joyport/joystick.c 2025-05-06 14:40:09 UTC (rev 45663) +++ branches/compyx/joymap-003/vice/src/joyport/joystick.c 2025-05-08 06:21:00 UTC (rev 45664) @@ -3039,33 +3039,30 @@ } -/** \brief Handle joystick axis event +/** \brief Interpret raw axis value as direction * + * Apply calibration and transform raw \a value into a direction for an + * emulated device. + * + * Determine if we need to invert the raw value and then apply thresholds from + * the calibration data to calculate the direction for an emulated joystick. + * * \param[in] axis joystick axis - * \param[in] value raw value for \a axis + * \param[in] value raw value of \a axis + * + * \return emulated joystick direction */ -void joy_axis_event(joystick_axis_t *axis, int32_t value) +joystick_axis_value_t joystick_axis_direction(joystick_axis_t *axis, int32_t value) { - joystick_axis_value_t direction = JOY_AXIS_MIDDLE; - joystick_axis_value_t prev = axis->prev; - int joyport = axis->device->joyport; + joystick_axis_value_t direction = JOY_AXIS_MIDDLE; -#if !(defined(USE_SDLUI) || defined(USE_SDL2UI) || defined(USE_HEADLESSUI)) - unsigned int poll_state = axis->device->status & JOY_POLL_MASK; - - if (poll_state == JOY_POLL_NONE) { - return; - } else if (poll_state == JOY_POLL_UI) { - joystick_ui_event(axis, JOY_INPUT_AXIS, value); - return; - } -#endif - /* digital axes don't require calibration: */ + /* digital axis? */ if (axis->digital) { /* calibration: invert value? */ if (axis->calibration.invert) { value *= -1; } + /* no thresholds for digital axes */ if (value < 0) { direction = JOY_AXIS_NEGATIVE; } else if (value > 0) { @@ -3086,11 +3083,7 @@ } center = axis->maximum - (range / 2); -#if 0 - printf("%s(): inverting %d: [%d-%d] -> %d\n", - __func__, value, axis->minimum, axis->maximum, center - value); -#endif - value = center - value; + value = center - value; } if (value <= axis->calibration.threshold.negative) { direction = JOY_AXIS_NEGATIVE; @@ -3099,6 +3092,33 @@ } } + return direction; +} + + +/** \brief Handle joystick axis event + * + * \param[in] axis joystick axis + * \param[in] value raw value for \a axis + */ +void joy_axis_event(joystick_axis_t *axis, int32_t value) +{ + joystick_axis_value_t direction; + joystick_axis_value_t prev = axis->prev; + int joyport = axis->device->joyport; + +#if !(defined(USE_SDLUI) || defined(USE_SDL2UI) || defined(USE_HEADLESSUI)) + unsigned int poll_state = axis->device->status & JOY_POLL_MASK; + + if (poll_state == JOY_POLL_NONE) { + return; + } else if (poll_state == JOY_POLL_UI) { + joystick_ui_event(axis, JOY_INPUT_AXIS, value); + return; + } +#endif + + direction = joystick_axis_direction(axis, value); if (direction == prev) { return; } @@ -3126,6 +3146,28 @@ } +/** \brief Interpret raw button value + * + * Determine pressed state of \a button by interpreting \a value and applying + * calibration (just invert if required). + * + * \param[in] button joystick button + * \param[in] value raw value of \a button + * + * \return \c 1 if pressed, \c 0 if released + */ +int32_t joystick_button_pressed(joystick_button_t *button, int32_t value) +{ + int32_t pressed = value ? 1 : 0; + + if (button->calibration.invert) { + pressed = !pressed; + } + return pressed; +} + + + /** \brief Handle joystick button event * * \param[in] button joystick button @@ -3133,7 +3175,7 @@ */ void joy_button_event(joystick_button_t *button, int32_t value) { - int32_t pressed = value ? 1 : 0; + /* TODO: reinstate this: */ #if 0 int num_buttons = joystick_devices[joynum].num_buttons; int joy_pin = joystick_devices[joynum].button_mapping[button].value.joy_pin; @@ -3160,6 +3202,8 @@ #endif if (value != button->prev) { + int32_t pressed = joystick_button_pressed(button, value); + DBG(("joy_button_event: joy: %s, button: %d (%s) pressed: %d\n", button->device->name, button->index, button->name, pressed)); joy_perform_event(&button->mapping, button->device->joyport, pressed); @@ -3803,6 +3847,23 @@ } +/** \brief Get index of device in registered devices list + * + * \param[in] joydev joystick device + * + * \return index in devices list or -1 if not found + */ +int joystick_device_index(joystick_device_t *joydev) +{ + for (size_t index = 0; index < num_joystick_devices; index++) { + if (joystick_devices[index] == joydev) { + return (int)index; + } + } + return -1; +} + + /** \brief Set joystick device name * * Set name of \a joydev to \a name, deallocating the old name if present. Modified: branches/compyx/joymap-003/vice/src/joyport/joystick.h =================================================================== --- branches/compyx/joymap-003/vice/src/joyport/joystick.h 2025-05-06 14:40:09 UTC (rev 45663) +++ branches/compyx/joymap-003/vice/src/joyport/joystick.h 2025-05-08 06:21:00 UTC (rev 45664) @@ -486,6 +486,7 @@ bool joystick_device_open (joystick_device_t *joydev, unsigned int mode); void joystick_device_close (joystick_device_t *joydev); +int joystick_device_index (joystick_device_t *joydev); joystick_device_t *joystick_device_by_index (int index); int joystick_device_count (void); @@ -508,19 +509,23 @@ joystick_axis_t *joystick_axis_new (const char *name); joystick_axis_t *joystick_axis_from_code (joystick_device_t *joydev, - uint32_t code); + uint32_t code); void joystick_axis_free (joystick_axis_t *axis); void joystick_axis_clear_mappings(joystick_axis_t *axis); +joystick_axis_value_t joystick_axis_direction(joystick_axis_t *axis, + int32_t value); joystick_button_t *joystick_button_new (const char *name); joystick_button_t *joystick_button_from_code (joystick_device_t *joydev, - uint32_t code); + uint32_t code); void joystick_button_free (joystick_button_t *button); void joystick_button_clear_mappings(joystick_button_t *button); +int32_t joystick_button_pressed (joystick_button_t *button, + int32_t value); joystick_hat_t *joystick_hat_new (const char *name); joystick_hat_t *joystick_hat_from_code (joystick_device_t *joydev, - uint32_t code); + uint32_t code); void joystick_hat_free (joystick_hat_t *hat); void joystick_hat_clear_mappings(joystick_hat_t *hat); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <co...@us...> - 2025-05-06 14:40:26
|
Revision: 45663 http://sourceforge.net/p/vice-emu/code/45663 Author: compyx Date: 2025-05-06 14:40:09 +0000 (Tue, 06 May 2025) Log Message: ----------- Joystick: add docs on UI-based polling code Add Doyxgen comment blocks for the UI-specific polling functions and a small explaination of how to use those functions to poll from the UI. Modified Paths: -------------- branches/compyx/joymap-003/vice/src/arch/gtk3/widgets/settings_joymap.c branches/compyx/joymap-003/vice/src/joyport/joystick.c branches/compyx/joymap-003/vice/src/joyport/joystick.h Modified: branches/compyx/joymap-003/vice/src/arch/gtk3/widgets/settings_joymap.c =================================================================== --- branches/compyx/joymap-003/vice/src/arch/gtk3/widgets/settings_joymap.c 2025-05-05 20:05:53 UTC (rev 45662) +++ branches/compyx/joymap-003/vice/src/arch/gtk3/widgets/settings_joymap.c 2025-05-06 14:40:09 UTC (rev 45663) @@ -260,7 +260,6 @@ joystick_button_t *button; GtkWidget *led; GtkWidget *scale; - const char *name; mainlock_assert_is_not_vice_thread(); @@ -267,7 +266,6 @@ switch (type) { case JOY_INPUT_AXIS: axis = input; - name = axis->name; if (event_widget != NULL) { grid = gtk_grid_get_child_at(GTK_GRID(event_widget), 0, 1); if (grid != NULL && GTK_IS_GRID(grid)) { @@ -280,7 +278,6 @@ break; case JOY_INPUT_BUTTON: button = input; - name = button->name; //debug_gtk3("Button %s, Index %d, Value %d", button->name, button->index, value); if (event_widget != NULL) { /* button grid */ @@ -298,12 +295,8 @@ } break; case JOY_INPUT_HAT: - name = ((joystick_hat_t *)input)->name; break; default: - name = "<unknown input>"; break; } - -// debug_gtk3("event: %s: type %u, value %d", name, type, value); } Modified: branches/compyx/joymap-003/vice/src/joyport/joystick.c =================================================================== --- branches/compyx/joymap-003/vice/src/joyport/joystick.c 2025-05-05 20:05:53 UTC (rev 45662) +++ branches/compyx/joymap-003/vice/src/joyport/joystick.c 2025-05-06 14:40:09 UTC (rev 45663) @@ -4314,14 +4314,36 @@ /* * UI joystick polling + * + * Basic operation: + * + * Call joystick_ui_poll_setup() to start polling + * Call joystick_ui_poll() at certain intervals to poll the device and trigger + * callbacks to joystick_ui_event() to pass events to the UI. + * Stop polling with a call to joystick_ui_poll_teardown(). + * + * The UI is expected to implement joystick_ui_event() to receive events. */ +/** \brief Host joystick device polled by the UI + * + * Only a single device can be polled at a time. + */ static joystick_device_t *ui_joydev = NULL; +/** \brief Set up polling from the UI + * + * \param[in] joydev joystick device + * + * \return \c true on success + */ bool joystick_ui_poll_setup(joystick_device_t *joydev) { printf("%s(): starting polling of %s\n", __func__, joydev->name); + if (joydev == NULL) { + return false; + } if (ui_joydev != NULL) { joystick_ui_poll_teardown(); } @@ -4330,6 +4352,10 @@ } +/** \brief Stop polling from the UI + * + * Stop polling of currently opened device, if any. + */ void joystick_ui_poll_teardown(void) { if (ui_joydev != NULL) { @@ -4340,6 +4366,11 @@ } +/** \brief Poll current joystick device + * + * Process pending events of current joystick device and pass events to the UI + * through #joystick_ui_event(). + */ void joystick_ui_poll(void) { if (ui_joydev != NULL && joy_driver.poll != NULL) { Modified: branches/compyx/joymap-003/vice/src/joyport/joystick.h =================================================================== --- branches/compyx/joymap-003/vice/src/joyport/joystick.h 2025-05-05 20:05:53 UTC (rev 45662) +++ branches/compyx/joymap-003/vice/src/joyport/joystick.h 2025-05-06 14:40:09 UTC (rev 45663) @@ -529,6 +529,13 @@ void joystick_ui_poll_teardown(void); /* To be implemented by UIs other than SDL or HEADLESS */ + +/** \brief Callback for the UI to receive joystick events + * + * \param[in] input event source (#joystick_axis_t, #joystick_button_t or #joystick_hat_t) + * \param[in] type type of \a input + * \param[in] value raw value for \a input + */ void joystick_ui_event(void *input, joystick_input_t type, int32_t value); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <co...@us...> - 2025-05-05 20:06:11
|
Revision: 45662 http://sourceforge.net/p/vice-emu/code/45662 Author: compyx Date: 2025-05-05 20:05:53 +0000 (Mon, 05 May 2025) Log Message: ----------- Joystick: implement host joystick polling from UI Add basic setup for polling host joysticks from the UI thread. Functions `joystick_ui_poll_setup()`, `joystick_ui_poll_teardown()` and `joystick_ui_poll()` can be used to request host joystick events to be passed to the UI thread. The function `joystick_ui_event()` is expected to be implemented by the UIs (non-SDL/non-headless) to receive said events. Only a single callback is used for axes, buttons and hats, so the UI logic for "move input to assign to something" can be kept simple (hopefully). Currently only a basic "playground" is added to the Gtk3 UI that shows axis and buttons events using sliders and LEDs. Modified Paths: -------------- branches/compyx/joymap-003/vice/src/arch/gtk3/uisettings.c branches/compyx/joymap-003/vice/src/arch/gtk3/widgets/Makefile.am branches/compyx/joymap-003/vice/src/joyport/joystick.c branches/compyx/joymap-003/vice/src/joyport/joystick.h Added Paths: ----------- branches/compyx/joymap-003/vice/src/arch/gtk3/widgets/settings_joymap.c branches/compyx/joymap-003/vice/src/arch/gtk3/widgets/settings_joymap.h Modified: branches/compyx/joymap-003/vice/src/arch/gtk3/uisettings.c =================================================================== --- branches/compyx/joymap-003/vice/src/arch/gtk3/uisettings.c 2025-05-04 13:18:20 UTC (rev 45661) +++ branches/compyx/joymap-003/vice/src/arch/gtk3/uisettings.c 2025-05-05 20:05:53 UTC (rev 45662) @@ -106,6 +106,7 @@ #include "settings_io.h" #include "settings_isepic.h" #include "settings_jam.h" +#include "settings_joymap.h" #include "settings_joystick.h" #include "settings_keyboard.h" #include "settings_ltkernal.h" @@ -951,6 +952,9 @@ { "Joystick", "joystick", settings_joystick_widget_create, NULL }, + { "Joystick mappings", + "joystick-mappings", + settings_joymap_widget_create, NULL }, { "Control port", "control-port", settings_controlport_widget_create, NULL }, Modified: branches/compyx/joymap-003/vice/src/arch/gtk3/widgets/Makefile.am =================================================================== --- branches/compyx/joymap-003/vice/src/arch/gtk3/widgets/Makefile.am 2025-05-04 13:18:20 UTC (rev 45661) +++ branches/compyx/joymap-003/vice/src/arch/gtk3/widgets/Makefile.am 2025-05-05 20:05:53 UTC (rev 45662) @@ -140,6 +140,7 @@ settings_io.c \ settings_isepic.c \ settings_jam.c \ + settings_joymap.c \ settings_joystick.c \ settings_keyboard.c \ settings_ltkernal.c \ @@ -311,6 +312,7 @@ settings_io.h \ settings_isepic.h \ settings_jam.h \ + settings_joymap.h \ settings_joystick.h \ settings_keyboard.h \ settings_ltkernal.h \ Added: branches/compyx/joymap-003/vice/src/arch/gtk3/widgets/settings_joymap.c =================================================================== --- branches/compyx/joymap-003/vice/src/arch/gtk3/widgets/settings_joymap.c (rev 0) +++ branches/compyx/joymap-003/vice/src/arch/gtk3/widgets/settings_joymap.c 2025-05-05 20:05:53 UTC (rev 45662) @@ -0,0 +1,309 @@ +/** \file settings_joymap.c + * \brief Widget to edit joystick mappings + * + * \author Bas Wassink <b.w...@zi...> + */ + +#include "vice.h" +#include <gtk/gtk.h> +#include <stdbool.h> +#include <stdint.h> + +#include "mainlock.h" +#include "joyport.h" +#include "joystick.h" +#include "resources.h" +#include "statusbarledwidget.h" +#include "vice_gtk3.h" + +#include "settings_joymap.h" + + +static GtkWidget *event_widget_new(joystick_device_t *joydev); + +static GtkWidget *layout; +static GtkWidget *device_combo; +static GtkWidget *event_widget; + +static guint poll_timeout_id; + + +static gboolean poll_callback(gpointer joydev) +{ + mainlock_assert_is_not_vice_thread(); + joystick_ui_poll(); + return G_SOURCE_CONTINUE; +} + +static void start_polling(joystick_device_t *joydev) +{ + mainlock_assert_is_not_vice_thread(); + if (joystick_ui_poll_setup(joydev)) { + poll_timeout_id = g_timeout_add(50, poll_callback, (gpointer)joydev); + } +} + +static void stop_polling(void) +{ + if (poll_timeout_id > 0) { + g_source_remove(poll_timeout_id); + poll_timeout_id = 0; + } +} + + +/** \brief Create left-aligned label + * + * \param[in] markup label text using Pango markup + * + * \return new GtkLabel + */ +static GtkWidget *label_helper(const char *markup) +{ + GtkWidget *label = gtk_label_new(NULL); + gtk_widget_set_halign(label, GTK_ALIGN_START); + gtk_label_set_markup(GTK_LABEL(label), markup); + return label; +} + +static GtkWidget *grid_helper(const char *markup, int colspacing, int rowspacing, int colspan) +{ + GtkWidget *grid = gtk_grid_new(); + GtkWidget *label = label_helper(markup); + + gtk_grid_set_column_spacing(GTK_GRID(grid), colspacing); + gtk_grid_set_row_spacing(GTK_GRID(grid), rowspacing); + gtk_grid_attach(GTK_GRID(grid), label, 0, 0, colspan, 1); + + return grid; +} + + +static void on_device_changed(GtkComboBox *self, gpointer data) +{ + GtkTreeIter iter; + + stop_polling(); + if (gtk_combo_box_get_active_iter(self, &iter)) { + GtkTreeModel *model = gtk_combo_box_get_model(self); + int index = -1; + + gtk_tree_model_get(model, &iter, 0, &index, -1); + debug_gtk3("Got index %d for device", index); + + if (event_widget != NULL) { + gtk_widget_destroy(event_widget); + } + event_widget = event_widget_new(joystick_device_by_index(index)); + gtk_grid_attach(GTK_GRID(layout), event_widget, 0, 2, 2, 1); + gtk_widget_show_all(event_widget); + start_polling(joystick_device_by_index(index)); + } +} + +static GtkListStore *device_combo_model_new(void) +{ + GtkListStore *model; + int index; + + model = gtk_list_store_new(2, G_TYPE_INT, G_TYPE_STRING); + for (index = 0; index < joystick_device_count(); index++) { + GtkTreeIter iter; + joystick_device_t *joydev = joystick_device_by_index(index); + char buffer[256]; + + g_snprintf(buffer, sizeof buffer, "%s (%d %s, %d %s, %d %s)", + joydev->name, + joydev->num_axes, joydev->num_axes == 1 ? "axis" : "axes", + joydev->num_buttons, joydev->num_buttons == 1 ? "button" : "buttons", + joydev->num_hats, joydev->num_hats == 1 ? "hat" : "hats"); + + gtk_list_store_append(model, &iter); + gtk_list_store_set(model, &iter, 0, index, 1, buffer, -1); + } + return model; +} + + +static GtkWidget *device_combo_new(void) +{ + GtkWidget *combo; + GtkListStore *model; + GtkCellRenderer *renderer; + + combo = gtk_combo_box_new(); + model = device_combo_model_new(); + renderer = gtk_cell_renderer_text_new(); + + gtk_combo_box_set_model(GTK_COMBO_BOX(combo), GTK_TREE_MODEL(model)); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, TRUE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "text", 1, NULL); + g_signal_connect(G_OBJECT(combo), + "changed", + G_CALLBACK(on_device_changed), + NULL); + return combo; +} + + +/* TODO: Repaint widgets once after all events have been processed, with + * Gtk fram tick or so? + */ +static GtkWidget *event_widget_new(joystick_device_t *joydev) +{ + GtkWidget *grid; + GtkWidget *label; + GtkWidget *agrid; + GtkWidget *bgrid; + GtkWidget *hgrid; + int i; + + grid = grid_helper("<b>Device events</b>", 16, 8, 3); + + agrid = grid_helper("<b>Axes</b>", 8, 8, 2); + bgrid = grid_helper("<b>Buttons</b>", 8, 8, 2); + hgrid = grid_helper("<b>Hatss</b>", 8, 8, 2); + gtk_grid_attach(GTK_GRID(grid), agrid, 0, 1, 1, 1); + gtk_grid_attach(GTK_GRID(grid), bgrid, 1, 1, 1, 1); + gtk_grid_attach(GTK_GRID(grid), hgrid, 2, 1, 1, 1); + + for (i = 0; i < joydev->num_axes; i++) { + joystick_axis_t *axis = joydev->axes[i]; + GtkWidget *scale; + + label = gtk_label_new(axis->name); + gtk_widget_set_halign(label, GTK_ALIGN_START); + + scale = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, + (gdouble)(axis->minimum), + (gdouble)(axis->maximum), + 1.0); + gtk_scale_set_digits(GTK_SCALE(scale), 0); + gtk_scale_set_value_pos(GTK_SCALE(scale), GTK_POS_RIGHT); + gtk_range_set_value(GTK_RANGE(scale), axis->minimum + ((axis->maximum - axis->minimum) / 2)); + gtk_widget_set_size_request(scale, 200, -1); + + gtk_grid_attach(GTK_GRID(agrid), label, 0, i + 1, 1, 1); + gtk_grid_attach(GTK_GRID(agrid), scale, 1, i + 1, 1, 1); + + } + + for (i = 0; i < joydev->num_buttons; i++) { + joystick_button_t *button = joydev->buttons[i]; + GtkWidget *led; + + label = gtk_label_new(button->name); + gtk_widget_set_halign(label, GTK_ALIGN_START); + + led = statusbar_led_widget_create(NULL, "#00ff00", "#000000"); + statusbar_led_widget_set_active(led, FALSE); + + gtk_grid_attach(GTK_GRID(bgrid), label, 0, i + 1, 1 ,1); + gtk_grid_attach(GTK_GRID(bgrid), led, 1, i + 1, 1 ,1); + } + + return grid; +} + + +static void on_joymap_widget_destroy(GtkWidget *self, gpointer unused) +{ + stop_polling(); + /* TODO: reopen previously closed host devices */ +} + + +GtkWidget *settings_joymap_widget_create(GtkWidget *parent) +{ + GtkWidget *label; + int row = 0; + + + /* TODO: Remember all opened host devices + * Close all host devices + * Reopen host devices on widget destruction + */ + + poll_timeout_id = 0; + event_widget = NULL; + + layout = gtk_grid_new(); + gtk_grid_set_column_spacing(GTK_GRID(layout), 16); + gtk_grid_set_row_spacing(GTK_GRID(layout), 8); + + label = label_helper("<b>Joystick mappings playground</b>"); + gtk_widget_set_margin_bottom(label, 8); + gtk_grid_attach(GTK_GRID(layout), label, 0, row, 2, 1); + row++; + + device_combo = device_combo_new(); + gtk_widget_set_hexpand(device_combo, TRUE); + label = gtk_label_new("Device"); + gtk_widget_set_halign(label, GTK_ALIGN_START); + gtk_grid_attach(GTK_GRID(layout), label, 0, row, 1, 1); + gtk_grid_attach(GTK_GRID(layout), device_combo, 1, row, 1, 1); + + g_signal_connect(G_OBJECT(layout), + "destroy", + G_CALLBACK(on_joymap_widget_destroy), + NULL); + + gtk_widget_show_all(layout); + return layout; +} + + +void joystick_ui_event(void *input, joystick_input_t type, int32_t value) +{ + GtkWidget *grid; + joystick_axis_t *axis; + joystick_button_t *button; + GtkWidget *led; + GtkWidget *scale; + const char *name; + + mainlock_assert_is_not_vice_thread(); + + switch (type) { + case JOY_INPUT_AXIS: + axis = input; + name = axis->name; + if (event_widget != NULL) { + grid = gtk_grid_get_child_at(GTK_GRID(event_widget), 0, 1); + if (grid != NULL && GTK_IS_GRID(grid)) { + scale = gtk_grid_get_child_at(GTK_GRID(grid), 1, 1 + axis->index); + if (scale != NULL) { + gtk_range_set_value(GTK_RANGE(scale), (gdouble)value); + } + } + } + break; + case JOY_INPUT_BUTTON: + button = input; + name = button->name; + //debug_gtk3("Button %s, Index %d, Value %d", button->name, button->index, value); + if (event_widget != NULL) { + /* button grid */ + grid = gtk_grid_get_child_at(GTK_GRID(event_widget), 1, 1); + if (grid != NULL && GTK_IS_GRID(grid)) { + led = gtk_grid_get_child_at(GTK_GRID(grid), 1, 1 + button->index); + if (led != NULL) { + gboolean pressed = value ? TRUE: FALSE; + + if (statusbar_led_widget_get_active(led) != pressed) { + statusbar_led_widget_set_active(led, value ? TRUE : FALSE); + } + } + } + } + break; + case JOY_INPUT_HAT: + name = ((joystick_hat_t *)input)->name; + break; + default: + name = "<unknown input>"; + break; + } + +// debug_gtk3("event: %s: type %u, value %d", name, type, value); +} Added: branches/compyx/joymap-003/vice/src/arch/gtk3/widgets/settings_joymap.h =================================================================== --- branches/compyx/joymap-003/vice/src/arch/gtk3/widgets/settings_joymap.h (rev 0) +++ branches/compyx/joymap-003/vice/src/arch/gtk3/widgets/settings_joymap.h 2025-05-05 20:05:53 UTC (rev 45662) @@ -0,0 +1,14 @@ +/** \file settings_joymap.h + * \brief Widget to edit joystick mappings - header + * + * \author Bas Wassink <b.w...@zi...> + */ + +#ifndef VICE_SETTINGS_JOYMAP_H +#define VICE_SETTINGS_JOYMAP_H + +#include <gtk/gtk.h> + +GtkWidget *settings_joymap_widget_create(GtkWidget *parent); + +#endif Modified: branches/compyx/joymap-003/vice/src/joyport/joystick.c =================================================================== --- branches/compyx/joymap-003/vice/src/joyport/joystick.c 2025-05-04 13:18:20 UTC (rev 45661) +++ branches/compyx/joymap-003/vice/src/joyport/joystick.c 2025-05-05 20:05:53 UTC (rev 45662) @@ -3046,15 +3046,20 @@ */ void joy_axis_event(joystick_axis_t *axis, int32_t value) { - joystick_axis_value_t direction = JOY_AXIS_MIDDLE; - joystick_axis_value_t prev = axis->prev; - int joyport = axis->device->joyport; + joystick_axis_value_t direction = JOY_AXIS_MIDDLE; + joystick_axis_value_t prev = axis->prev; + int joyport = axis->device->joyport; +#if !(defined(USE_SDLUI) || defined(USE_SDL2UI) || defined(USE_HEADLESSUI)) + unsigned int poll_state = axis->device->status & JOY_POLL_MASK; - if ((axis->device->status & JOY_POLL_MASK) == JOY_POLL_NONE) { + if (poll_state == JOY_POLL_NONE) { return; + } else if (poll_state == JOY_POLL_UI) { + joystick_ui_event(axis, JOY_INPUT_AXIS, value); + return; } - +#endif /* digital axes don't require calibration: */ if (axis->digital) { /* calibration: invert value? */ @@ -3143,9 +3148,16 @@ } #endif - if ((button->device->status & JOY_POLL_MASK) == JOY_POLL_NONE) { +#if !(defined(USE_SDLUI) || defined(USE_SDL2UI) || defined(USE_HEADLESSUI)) + unsigned int poll_state = button->device->status & JOY_POLL_MASK; + + if (poll_state == JOY_POLL_NONE) { return; + } else if (poll_state == JOY_POLL_UI) { + joystick_ui_event(button, JOY_INPUT_BUTTON, value); + return; } +#endif if (value != button->prev) { DBG(("joy_button_event: joy: %s, button: %d (%s) pressed: %d\n", @@ -3166,9 +3178,16 @@ int joyport = hat->device->joyport; int32_t prev = hat->prev; - if ((hat->device->status & JOY_POLL_MASK) == JOY_POLL_NONE) { +#if !(defined(USE_SDLUI) || defined(USE_SDL2UI) || defined(USE_HEADLESSUI)) + unsigned int poll_state = hat->device->status & JOY_POLL_MASK; + + if (poll_state == JOY_POLL_NONE) { return; + } else if (poll_state == JOY_POLL_UI) { + joystick_ui_event(hat, JOY_INPUT_HAT, value); + return; } +#endif if (value == prev) { return; @@ -3323,7 +3342,7 @@ for (i = 0; i < num_joystick_devices; i++) { joystick_device_t *joydev = joystick_devices[i]; - if ((joydev->status & JOY_POLL_MASK) != JOY_POLL_NONE) { + if ((joydev->status & JOY_POLL_MASK) == JOY_POLL_MAIN) { joy_driver.poll(joydev); } } @@ -4291,3 +4310,39 @@ joy_driver.close(joydev); } } + + +/* + * UI joystick polling + */ + +static joystick_device_t *ui_joydev = NULL; + + +bool joystick_ui_poll_setup(joystick_device_t *joydev) +{ + printf("%s(): starting polling of %s\n", __func__, joydev->name); + if (ui_joydev != NULL) { + joystick_ui_poll_teardown(); + } + ui_joydev = joydev; + return joystick_device_open(ui_joydev, JOY_POLL_UI); +} + + +void joystick_ui_poll_teardown(void) +{ + if (ui_joydev != NULL) { + printf("%s(): stopping polling of %s\n", __func__, ui_joydev->name); + joystick_device_close(ui_joydev); + ui_joydev = NULL; + } +} + + +void joystick_ui_poll(void) +{ + if (ui_joydev != NULL && joy_driver.poll != NULL) { + joy_driver.poll(ui_joydev); + } +} Modified: branches/compyx/joymap-003/vice/src/joyport/joystick.h =================================================================== --- branches/compyx/joymap-003/vice/src/joyport/joystick.h 2025-05-04 13:18:20 UTC (rev 45661) +++ branches/compyx/joymap-003/vice/src/joyport/joystick.h 2025-05-05 20:05:53 UTC (rev 45662) @@ -524,4 +524,11 @@ void joystick_hat_free (joystick_hat_t *hat); void joystick_hat_clear_mappings(joystick_hat_t *hat); +bool joystick_ui_poll_setup(joystick_device_t *joydev); +void joystick_ui_poll(void); +void joystick_ui_poll_teardown(void); + +/* To be implemented by UIs other than SDL or HEADLESS */ +void joystick_ui_event(void *input, joystick_input_t type, int32_t value); + #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gp...@us...> - 2025-05-04 13:18:38
|
Revision: 45661 http://sourceforge.net/p/vice-emu/code/45661 Author: gpz Date: 2025-05-04 13:18:20 +0000 (Sun, 04 May 2025) Log Message: ----------- fix monitor help (bug #2139), add missing commands to manual Modified Paths: -------------- trunk/vice/doc/vice.texi trunk/vice/src/monitor/mon_command.c Modified: trunk/vice/doc/vice.texi =================================================================== --- trunk/vice/doc/vice.texi 2025-05-01 16:11:23 UTC (rev 45660) +++ trunk/vice/doc/vice.texi 2025-05-04 13:18:20 UTC (rev 45661) @@ -20639,7 +20639,7 @@ @itemx exp Print out list of attached expansion port devices. -@item keybuf "<string>" +@item keybuf <string> Put the specified string into the keyboard buffer. Note that you can specify specific keycodes by using C-style escaped hexcodes ("\x0a"). @@ -20886,9 +20886,15 @@ @item rmdir <directory> Remove directory. -@item attach <filename> <device> +@item attach "<filename>" <device> Attach file to device. (device 32 = cart) +@item autostart "<filename>" [file_index] +Autostart a given disk/tape image or program. + +@item autoload "<filename>" [file_index] +Autoload given disk/tape image or program. + @item block_read <track> <sector> [<address>] @itemx br <track> <sector> [<address>] Read the block at the specified track and sector. If an address is @@ -20910,7 +20916,7 @@ drive implementation. As a consequence, all limitations of the virtual drives apply. Use the regular monitor commands to eg execute code in the drive. -@item list [<directory>] +@item list [<device>] List disk contents. @item load "<filename>" <device> [<address>] Modified: trunk/vice/src/monitor/mon_command.c =================================================================== --- trunk/vice/src/monitor/mon_command.c 2025-05-01 16:11:23 UTC (rev 45660) +++ trunk/vice/src/monitor/mon_command.c 2025-05-04 13:18:20 UTC (rev 45661) @@ -296,7 +296,7 @@ }, { "keybuf", "", - "\"<string>\"", + "<string>", "Put the specified string into the keyboard buffer.", NO_FILENAME_ARG }, @@ -661,19 +661,19 @@ }, { "attach", "", - "<filename> <device>", + "\"<filename>\" <device>", "Attach file to device. (device 32 = cart)", FILENAME_ARG }, { "autostart", "", - "<filename> [file_index]", + "\"<filename>\" [file_index]", "Autostart a given disk/tape image or program.", FILENAME_ARG }, { "autoload", "", - "<filename> [file_index]", + "\"<filename>\" [file_index]", "Autoload given disk/tape image or program.", FILENAME_ARG }, @@ -727,7 +727,7 @@ }, { "list", "", - "[<Directory>]", + "[<device>]", "List disk contents.", NO_FILENAME_ARG }, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <co...@us...> - 2025-05-01 16:11:42
|
Revision: 45660 http://sourceforge.net/p/vice-emu/code/45660 Author: compyx Date: 2025-05-01 16:11:23 +0000 (Thu, 01 May 2025) Log Message: ----------- Joystick: add device status bits Use device `status` member to determine polling mode: JOY_POLL_NONE, JOY_POLL_MAIN (host device events go to emulated devices) and JOY_POLL_UI (UI thread should receive host device events). Modified Paths: -------------- branches/compyx/joymap-003/vice/src/arch/gtk3/joystickdrv/joystick_linux_evdev.c branches/compyx/joymap-003/vice/src/joyport/joystick.c branches/compyx/joymap-003/vice/src/joyport/joystick.h Modified: branches/compyx/joymap-003/vice/src/arch/gtk3/joystickdrv/joystick_linux_evdev.c =================================================================== --- branches/compyx/joymap-003/vice/src/arch/gtk3/joystickdrv/joystick_linux_evdev.c 2025-05-01 11:07:56 UTC (rev 45659) +++ branches/compyx/joymap-003/vice/src/arch/gtk3/joystickdrv/joystick_linux_evdev.c 2025-05-01 16:11:23 UTC (rev 45660) @@ -216,10 +216,11 @@ int rc; unsigned int flags = LIBEVDEV_READ_FLAG_NORMAL; - priv = joydev->priv; - if (priv == NULL || priv->fd < 0 || priv->evdev == NULL) { + if ((joydev->status & JOY_POLL_MASK) == JOY_POLL_NONE) { return; } + + priv = joydev->priv; evdev = priv->evdev; while (libevdev_has_event_pending(evdev)) { Modified: branches/compyx/joymap-003/vice/src/joyport/joystick.c =================================================================== --- branches/compyx/joymap-003/vice/src/joyport/joystick.c 2025-05-01 11:07:56 UTC (rev 45659) +++ branches/compyx/joymap-003/vice/src/joyport/joystick.c 2025-05-01 16:11:23 UTC (rev 45660) @@ -879,7 +879,7 @@ "resource JoyDevice%d: opening device %d (%s)", port_idx, newdev, joydev->name); #endif - if (!joystick_device_open(joydev)) { + if (!joystick_device_open(joydev, JOY_POLL_MAIN)) { return -1; } } @@ -2779,7 +2779,7 @@ log_message(joy_log, "joystick_init(): resource JoyDevice%d: opening device %d (%s)", i + 1, devnum - JOYDEV_REALJOYSTICK_MIN, joydev->name); - joystick_device_open(joydev); + joystick_device_open(joydev, JOY_POLL_MAIN); } else { joystick_port_map[i] = JOYDEV_NONE; } @@ -3051,6 +3051,10 @@ int joyport = axis->device->joyport; + if ((axis->device->status & JOY_POLL_MASK) == JOY_POLL_NONE) { + return; + } + /* digital axes don't require calibration: */ if (axis->digital) { /* calibration: invert value? */ @@ -3138,6 +3142,11 @@ } } #endif + + if ((button->device->status & JOY_POLL_MASK) == JOY_POLL_NONE) { + return; + } + if (value != button->prev) { DBG(("joy_button_event: joy: %s, button: %d (%s) pressed: %d\n", button->device->name, button->index, button->name, pressed)); @@ -3157,6 +3166,10 @@ int joyport = hat->device->joyport; int32_t prev = hat->prev; + if ((hat->device->status & JOY_POLL_MASK) == JOY_POLL_NONE) { + return; + } + if (value == prev) { return; } @@ -3308,7 +3321,11 @@ int i; for (i = 0; i < num_joystick_devices; i++) { - joy_driver.poll(joystick_devices[i]); + joystick_device_t *joydev = joystick_devices[i]; + + if ((joydev->status & JOY_POLL_MASK) != JOY_POLL_NONE) { + joy_driver.poll(joydev); + } } } } @@ -3401,6 +3418,7 @@ joydev->name = NULL; joydev->node = NULL; + joydev->status = JOY_POLL_NONE; joydev->vendor = 0; joydev->product = 0; joydev->axes = lib_calloc(NUM_AXES_INITIAL, sizeof *joydev->axes); @@ -4234,10 +4252,32 @@ } -bool joystick_device_open(joystick_device_t *joydev) +/** \brief Open host joystick device for polling + * + * The polling \a mode can be either #JOY_POLL_MAIN, which passed events to + * the emulated devices, or #JOY_POLL_UI, which passes the events to the UI + * thread for joystick configuration (mapping and calibration). + * + * \param[in] joydev joystick device + * \param[in] mode polling mode + * + * \return \c true on success + * + * \see #JOY_POLL_MAIN + * \see #JOY_POLL_UI + * + * \note At a later point \a mode could be used to further control devices, + * such as blocking/non-blocking/exclusive-access, should that be + * required. + */ +bool joystick_device_open(joystick_device_t *joydev, unsigned int mode) { if (joydev != NULL && joy_driver.open != NULL) { - return joy_driver.open(joydev); + joydev->status = mode; + if (joy_driver.open(joydev)) { + return true; + } + joydev->status &= ~JOY_POLL_MASK; } return false; } @@ -4246,6 +4286,8 @@ void joystick_device_close(joystick_device_t *joydev) { if (joydev != NULL && joy_driver.close != NULL) { + /* set polling to none */ + joydev->status &= ~JOY_POLL_MASK; joy_driver.close(joydev); } } Modified: branches/compyx/joymap-003/vice/src/joyport/joystick.h =================================================================== --- branches/compyx/joymap-003/vice/src/joyport/joystick.h 2025-05-01 11:07:56 UTC (rev 45659) +++ branches/compyx/joymap-003/vice/src/joyport/joystick.h 2025-05-01 16:11:23 UTC (rev 45660) @@ -247,6 +247,28 @@ } joystick_hat_t; +/** \brief No polling, device is closed */ +#define JOY_POLL_NONE 0x00 + +/** \brief Polled events should pass to the main loop + * + * Any host joystick events should be passed to the main loop to be used for + * emulated joysticks/paddles etc. + */ +#define JOY_POLL_MAIN 0x01 + +/** \brief Polled events should pass to the UI thread + * + * Any host joystick events should be passed to the UI thread to be used for + * joystick mapping and calibration. + */ +#define JOY_POLL_UI 0x02 + +/** \brief Bitmask to mask out poll mode from device status + */ +#define JOY_POLL_MASK 0x03 + + /** \brief Joystick device object * * Contains all information on a host joystick device. @@ -264,6 +286,16 @@ */ char *node; + /** \brief Status bits + * + * For now just poll state, might add more later, if required. + * + * \see #JOY_POLL_NONE + * \see #JOY_POLL_MAIN + * \see #JOY_POLL_UI + */ + unsigned int status; + /** \brief HID vendor ID */ uint16_t vendor; @@ -451,7 +483,8 @@ joystick_device_t *joystick_device_new (void); void joystick_device_free (joystick_device_t *joydev); bool joystick_device_register (joystick_device_t *joydev); -bool joystick_device_open (joystick_device_t *joydev); +bool joystick_device_open (joystick_device_t *joydev, + unsigned int mode); void joystick_device_close (joystick_device_t *joydev); joystick_device_t *joystick_device_by_index (int index); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rh...@us...> - 2025-05-01 11:08:16
|
Revision: 45659 http://sourceforge.net/p/vice-emu/code/45659 Author: rhialto Date: 2025-05-01 11:07:56 +0000 (Thu, 01 May 2025) Log Message: ----------- And another one... Modified Paths: -------------- trunk/vice/src/pet/petdatasette.c Modified: trunk/vice/src/pet/petdatasette.c =================================================================== --- trunk/vice/src/pet/petdatasette.c 2025-05-01 10:46:35 UTC (rev 45658) +++ trunk/vice/src/pet/petdatasette.c 2025-05-01 11:07:56 UTC (rev 45659) @@ -43,6 +43,16 @@ } } +void machine_set_tape_read_in(int port, unsigned int on) +{ + if (port == TAPEPORT_PORT_1) { + pia1_signal(PIA_SIG_CA1, on ? PIA_SIG_RISE: PIA_SIG_FALL, 0); /* TODO: offset */ + } else { + viacore_signal(machine_context.via, VIA_SIG_CB1, + on ? VIA_SIG_RISE : VIA_SIG_FALL); + } +} + void machine_set_tape_sense(int port, int sense) { if (port == TAPEPORT_PORT_1) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rh...@us...> - 2025-05-01 10:46:53
|
Revision: 45658 http://sourceforge.net/p/vice-emu/code/45658 Author: rhialto Date: 2025-05-01 10:46:35 +0000 (Thu, 01 May 2025) Log Message: ----------- Forgot to include in commit... Modified Paths: -------------- trunk/vice/src/vic20/vic20datasette.c Modified: trunk/vice/src/vic20/vic20datasette.c =================================================================== --- trunk/vice/src/vic20/vic20datasette.c 2025-05-01 10:36:48 UTC (rev 45657) +++ trunk/vice/src/vic20/vic20datasette.c 2025-05-01 10:46:35 UTC (rev 45658) @@ -41,6 +41,14 @@ } } +void machine_set_tape_read_in(int port, unsigned int on) +{ + if (port == TAPEPORT_PORT_1) { + viacore_signal(machine_context.via2, VIA_SIG_CA1, + on ? VIA_SIG_RISE : VIA_SIG_FALL); + } +} + void machine_set_tape_sense(int port, int sense) { if (port == TAPEPORT_PORT_1) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rh...@us...> - 2025-05-01 10:37:06
|
Revision: 45657 http://sourceforge.net/p/vice-emu/code/45657 Author: rhialto Date: 2025-05-01 10:36:48 +0000 (Thu, 01 May 2025) Log Message: ----------- Some TABs crept in... Modified Paths: -------------- trunk/vice/src/tapeport/tapeport.c Modified: trunk/vice/src/tapeport/tapeport.c =================================================================== --- trunk/vice/src/tapeport/tapeport.c 2025-05-01 10:26:52 UTC (rev 45656) +++ trunk/vice/src/tapeport/tapeport.c 2025-05-01 10:36:48 UTC (rev 45657) @@ -356,9 +356,9 @@ /* The WordCraft dongle is only for PETs */ if (machine_class == VICE_MACHINE_PET) { - if (wordcraft_dongle_resources_init(amount) < 0) { - return -1; - } + if (wordcraft_dongle_resources_init(amount) < 0) { + return -1; + } } /* Only use tapecart device and dtl basic dongle on c64/c128 */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rh...@us...> - 2025-05-01 10:27:12
|
Revision: 45656 http://sourceforge.net/p/vice-emu/code/45656 Author: rhialto Date: 2025-05-01 10:26:52 +0000 (Thu, 01 May 2025) Log Message: ----------- Add tape port dongle to help WordCraft (PET) work. Modified Paths: -------------- trunk/vice/doc/vice.texi trunk/vice/src/c64/c64datasette.c trunk/vice/src/c64dtv/c64dtv-stubs.c trunk/vice/src/cbm2/cbm2datasette.c trunk/vice/src/datasette/datasette.h trunk/vice/src/plus4/plus4datasette.c trunk/vice/src/scpu64/scpu64-stubs.c trunk/vice/src/tapeport/Makefile.am trunk/vice/src/tapeport/tapeport.c trunk/vice/src/tapeport/tapeport.h Added Paths: ----------- trunk/vice/src/tapeport/wordcraft-dongle.c trunk/vice/src/tapeport/wordcraft-dongle.h Modified: trunk/vice/doc/vice.texi =================================================================== --- trunk/vice/doc/vice.texi 2025-04-29 15:51:59 UTC (rev 45655) +++ trunk/vice/doc/vice.texi 2025-05-01 10:26:52 UTC (rev 45656) @@ -8566,6 +8566,9 @@ @item 6 @tab tapecart @tab x64, x64sc, x128 +@item 7 +@tab WordCraft dongle +@tab xpet @end multitable @table @code @@ -16915,7 +16918,7 @@ @node Colour PET @subsection Colour PET The Colour PET is a simple extension by Steve Gray -@uref{http://www.6502.org/users/sjgray/projects/colourpet/}. It exploits +@uref{http://cbmsteve.ca/colourpet/index.html}. It exploits the similarities and differences between the 4032 and 8032 models, to use memory at $8800 as colour RAM. @@ -36167,12 +36170,14 @@ @b{Olaf Seibert} Contributed some PET, including PET DWW hires, Xaw, lightpen, hardware scaling, and disk drive patches. Added proper SuperPET -support, including 6809/6309 CPU emulation. Maintained the Xaw UI. +support, including 6809/6309 CPU emulation and 6702 'dongle' chip. +Maintained the Xaw UI. Added PET HRE (High Res Emulator) board emulation. Added the 2-chip colour board for the Universal PET mainboard. Added support for 'printer/plotter' Commodore 1520. Overhauled internals of VIA and CIA code. Corrected pre-CRTC PET display timing. REL-file support for the filesystem device and c1541. +Added WordCraft dongle. @item @b{Marcus Sutton} Modified: trunk/vice/src/c64/c64datasette.c =================================================================== --- trunk/vice/src/c64/c64datasette.c 2025-04-29 15:51:59 UTC (rev 45655) +++ trunk/vice/src/c64/c64datasette.c 2025-05-01 10:26:52 UTC (rev 45656) @@ -40,6 +40,15 @@ } } +void machine_set_tape_read_in(int port, unsigned int on) +{ + if (port == TAPEPORT_PORT_1) { + if (on) { + ciacore_set_flag(machine_context.cia1); + } + } +} + void machine_set_tape_sense(int port, int sense) { if (port == TAPEPORT_PORT_1) { Modified: trunk/vice/src/c64dtv/c64dtv-stubs.c =================================================================== --- trunk/vice/src/c64dtv/c64dtv-stubs.c 2025-04-29 15:51:59 UTC (rev 45655) +++ trunk/vice/src/c64dtv/c64dtv-stubs.c 2025-05-01 10:26:52 UTC (rev 45656) @@ -108,6 +108,9 @@ void machine_trigger_flux_change(int port, unsigned int on) { } +void machine_set_tape_read_in(int port, unsigned int on) +{ +} void machine_set_tape_sense(int port, int sense) { } Modified: trunk/vice/src/cbm2/cbm2datasette.c =================================================================== --- trunk/vice/src/cbm2/cbm2datasette.c 2025-04-29 15:51:59 UTC (rev 45655) +++ trunk/vice/src/cbm2/cbm2datasette.c 2025-05-01 10:26:52 UTC (rev 45656) @@ -69,6 +69,16 @@ } } +void machine_set_tape_read_in(int port, unsigned int on) +{ + if (port == TAPEPORT_PORT_1) { + logit(0, on); + if (on) { + ciacore_set_flag(machine_context.cia1); + } + } +} + void machine_set_tape_sense(int port, int sense) { if (port == TAPEPORT_PORT_1) { Modified: trunk/vice/src/datasette/datasette.h =================================================================== --- trunk/vice/src/datasette/datasette.h 2025-04-29 15:51:59 UTC (rev 45655) +++ trunk/vice/src/datasette/datasette.h 2025-05-01 10:26:52 UTC (rev 45656) @@ -90,8 +90,14 @@ void datasette_event_playback_port1(CLOCK offset, void *data); void datasette_event_playback_port2(CLOCK offset, void *data); -/* Emulator specific functions. */ +/* + * Emulator specific functions. + * Note that machine_set_tape_read_in() is implemented on a best-effort basis. + * In many machines, the tape read signal is connected to an edge-triggered + * input which does not store its level. + */ void machine_trigger_flux_change(int port, unsigned int on); +void machine_set_tape_read_in(int port, unsigned int on); void machine_set_tape_sense(int port, int sense); void machine_set_tape_write_in(int port, int val); void machine_set_tape_motor_in(int port, int val); Modified: trunk/vice/src/plus4/plus4datasette.c =================================================================== --- trunk/vice/src/plus4/plus4datasette.c 2025-04-29 15:51:59 UTC (rev 45655) +++ trunk/vice/src/plus4/plus4datasette.c 2025-05-01 10:26:52 UTC (rev 45656) @@ -38,6 +38,13 @@ } } +void machine_set_tape_read_in(int port, unsigned int on) +{ + if (port == TAPEPORT_PORT_1) { + mem_proc_port_trigger_flux_change(on); + } +} + void machine_set_tape_sense(int port, int sense) { if (port == TAPEPORT_PORT_1) { Modified: trunk/vice/src/scpu64/scpu64-stubs.c =================================================================== --- trunk/vice/src/scpu64/scpu64-stubs.c 2025-04-29 15:51:59 UTC (rev 45655) +++ trunk/vice/src/scpu64/scpu64-stubs.c 2025-05-01 10:26:52 UTC (rev 45656) @@ -221,6 +221,9 @@ void machine_trigger_flux_change(int port, unsigned int on) { } +void machine_set_tape_read_in(int port, unsigned int on) +{ +} void machine_set_tape_sense(int port, int sense) { } Modified: trunk/vice/src/tapeport/Makefile.am =================================================================== --- trunk/vice/src/tapeport/Makefile.am 2025-04-29 15:51:59 UTC (rev 45655) +++ trunk/vice/src/tapeport/Makefile.am 2025-05-01 10:26:52 UTC (rev 45656) @@ -23,6 +23,8 @@ dtl-basic-dongle.h \ sense-dongle.c \ sense-dongle.h \ + wordcraft-dongle.c \ + wordcraft-dongle.h \ tape_diag_586220_harness.c \ tape_diag_586220_harness.h \ tapecart.c \ Modified: trunk/vice/src/tapeport/tapeport.c =================================================================== --- trunk/vice/src/tapeport/tapeport.c 2025-04-29 15:51:59 UTC (rev 45655) +++ trunk/vice/src/tapeport/tapeport.c 2025-05-01 10:26:52 UTC (rev 45656) @@ -47,6 +47,7 @@ #endif #include "uiapi.h" #include "util.h" +#include "wordcraft-dongle.h" /* flag indicating if the tapeport exists on the current emulated model */ static int tapeport_active = 1; @@ -300,6 +301,11 @@ machine_trigger_flux_change(port, on); } +void tapeport_set_read_in(unsigned int on, int port) +{ + machine_set_tape_read_in(port, on); +} + void tapeport_set_tape_sense(int sense, int port) { machine_set_tape_sense(port, sense); @@ -348,6 +354,13 @@ return -1; } + /* The WordCraft dongle is only for PETs */ + if (machine_class == VICE_MACHINE_PET) { + if (wordcraft_dongle_resources_init(amount) < 0) { + return -1; + } + } + /* Only use tapecart device and dtl basic dongle on c64/c128 */ if (machine_class == VICE_MACHINE_C64 || machine_class == VICE_MACHINE_C128 || machine_class == VICE_MACHINE_C64SC) { #ifdef TAPEPORT_EXPERIMENTAL_DEVICES Modified: trunk/vice/src/tapeport/tapeport.h =================================================================== --- trunk/vice/src/tapeport/tapeport.h 2025-04-29 15:51:59 UTC (rev 45655) +++ trunk/vice/src/tapeport/tapeport.h 2025-05-01 10:26:52 UTC (rev 45656) @@ -44,6 +44,7 @@ TAPEPORT_DEVICE_SENSE_DONGLE, TAPEPORT_DEVICE_TAPE_DIAG_586220_HARNESS, TAPEPORT_DEVICE_TAPECART, + TAPEPORT_DEVICE_WORDCRAFT_DONGLE, /* This item always needs to be at the end */ TAPEPORT_MAX_DEVICES @@ -130,6 +131,7 @@ int tapeport_valid_port(int port); void tapeport_trigger_flux_change(unsigned int on, int port); +void tapeport_set_read_in(unsigned int on, int port); void tapeport_set_tape_sense(int sense, int port); void tapeport_set_write_in(int val, int port); void tapeport_set_motor_in(int val, int port); Added: trunk/vice/src/tapeport/wordcraft-dongle.c =================================================================== --- trunk/vice/src/tapeport/wordcraft-dongle.c (rev 0) +++ trunk/vice/src/tapeport/wordcraft-dongle.c 2025-05-01 10:26:52 UTC (rev 45656) @@ -0,0 +1,283 @@ +/* + * wordcraft-dongle.c - tape port dongle that helps WordCraft work. + * + * Written by + * Olaf 'Rhialto' Seibert <rh...@fa...> + * based on public information from http://bitbarn.co.uk/trusley/early_days.htm + * http://bitbarn.co.uk/dryfire/dcpe.php#pets + * + * 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 <stdlib.h> +#include <string.h> + +#include "cmdline.h" +#include "log.h" +#include "maincpu.h" +#include "machine.h" +#include "mem.h" +#include "resources.h" +#include "tapeport.h" + +#include "wordcraft-dongle.h" + + +static int wordcraft_dongle_enabled[TAPEPORT_MAX_PORTS] = { 0 }; + +static log_t wclog = LOG_DEFAULT; + +/* ------------------------------------------------------------------------- */ + +/* Some prototypes are needed */ +static void wordcraft_dongle_powerup(int port); +static int wordcraft_dongle_enable(int port, int val); +static void wordcraft_dongle_set_motor_line(int port, int value); +static void wordcraft_dongle_toggle_write_line(int port, int value); +static void wordcraft_dongle_set_sense_line(int port, int value); +static void wordcraft_dongle_set_read_line(int port, int value); + +static tapeport_device_t wordcraft_dongle_device = { + "Wordcraft dongle", /* device name */ + TAPEPORT_DEVICE_TYPE_DONGLE, /* device is a 'dongle' type device */ + VICE_MACHINE_PET, /* device works on PETs only */ + TAPEPORT_PORT_ALL_MASK, /* device works on all ports */ + wordcraft_dongle_enable, /* device enable function */ + wordcraft_dongle_powerup, /* device specific hard reset function */ + NULL, /* NO device shutdown function */ + wordcraft_dongle_set_motor_line, /* set motor line function */ + wordcraft_dongle_toggle_write_line, /* set write line function */ + wordcraft_dongle_set_sense_line, /* set sense line function */ + wordcraft_dongle_set_read_line, /* set read line function */ + NULL, /* NO device snapshot write function */ + NULL /* NO device snapshot read function */ +}; + +/* ------------------------------------------------------------------------- */ + +struct dongle_data { + bool load_line; + bool clock_in_line; + bool data_in_line; + bool clock_enable_line; + bool value_detected; + int shift_count; + unsigned int dongle_value; +} dongle_data[TAPEPORT_MAX_PORTS]; + +static unsigned int reverse16(unsigned int bits) +{ + unsigned int v = bits; + + /* swap odd and even bits */ + v = ((v >> 1) & 0x5555) | ((v & 0x5555) << 1); + /* swap consecutive pairs */ + v = ((v >> 2) & 0x3333) | ((v & 0x3333) << 2); + /* swap nibbles ... */ + v = ((v >> 4) & 0x0F0F) | ((v & 0x0F0F) << 4); + /* swap bytes */ + v = ((v >> 8) & 0x00FF) | ((v & 0x00FF) << 8); + + return v; +} + +static int wordcraft_dongle_enable(int port, int value) +{ + int val = value ? 1 : 0; + + if (wordcraft_dongle_enabled[port] == val) { + return 0; + } + + wordcraft_dongle_enabled[port] = val; + if (!val) { + dongle_data[port].value_detected = false; + } + + dongle_data[port].dongle_value = reverse16(0xD210); /* $084B or 2123. Most common value */ + /* dongle_data[port].dongle_value = reverse16(0x4800); / * 7 bits used */ + /* dongle_data[port].dongle_value = reverse16(0x2C00); / * 7 bits used */ + /* dongle_data[port].dongle_value = reverse16(0x0200); / * 7 bits used */ + /* + * Working values: + * Wordcraft + * E10 reverse(0x0200) (7 bits used) + * /F10 reverse(0x9000) some copies crash later + * 80me /F32 reverse(0xD210) + * 80e /G21 reverse(0x4800) s/n D25210 (7 bits used) + * 80me /G25 reverse(0x2C00) (7 bits used) + * 80 /H12 reverse(0xD210) (15 bits used) doesn't set sense line? + * 96xxxx/H12 reverse(0xD210) (15 bits used) + * 80 /H17 reverse(0xD210) + * 96xxxx/H17 reverse(0xD210) (15 bits used) + * CBM 80F3 80ME distributor code D /F32: reverse(D210) (7 bits used) + * + * M=matrix, otherwise letter quality printers? + * E=english? + * FR=french AZ=azerty + * GB=english QW=qwerty + * NL=dutch + * 80 = 80 cols, 32 KB + * 96 = 80 cols, 96 KB + * + * Loading documents: g,filename,drivenr,chapternr + * for NL version: l,filename,drivenr,chapternr + * u,$ directory listing + */ + return 0; +} + +int wordcraft_dongle_resources_init(int amount) +{ + wclog = log_open("WordCraft"); + + return tapeport_device_register(TAPEPORT_DEVICE_WORDCRAFT_DONGLE, + &wordcraft_dongle_device); +} + +/* ---------------------------------------------------------------------*/ + +static void wordcraft_dongle_detect_values(int port) +{ + /* Try to detect the expected dongle value(s) by inspecting the code */ + if (!dongle_data[port].value_detected) { + /* Look at PC */ + uint16_t pc = reg_pc; /* unfortunately maincpu_get_pc(); returns 0 */ + unsigned int i; + uint8_t lo = 0, hi = 0; + bool lo_found = false; + uint8_t *mem = mem_ram; + log_message(wclog, "Detecting WordCraft dongle code from PC = $%04x", pc); + + if (pc >= 0x8000) { + log_error(wclog, "PC too high for WordCraft dongle code. Ignoring."); + return; + } + + /* Search for the sequence LDY $7D STY $xxxx TYA EOR #hi */ + for (i = 0; i < 128; i++) { + if (mem[pc + i + 0x00] == 0xA4 && /* LDY $7D */ + mem[pc + i + 0x01] == 0x7D && + mem[pc + i + 0x02] == 0x8C && /* STY $xxxx */ + mem[pc + i + 0x05] == 0x98 && /* TYA */ + mem[pc + i + 0x06] == 0x49) { /* EOR #hi */ + hi = mem[pc + i + 0x07]; + + if (mem[pc + i + 0x08] == 0xD0 && /* BNE */ + mem[pc + i + 0x0C] == 0x49) { /* EOR #lo */ + lo = mem[pc + i + 0x0D]; + lo_found = true; + } + + if (lo_found) { + log_message(wclog, "Found $%02x $%02x at $%04x +$%02x and +$%02x", hi, lo, pc, i+0x07, i+0x0D); + } else { + log_message(wclog, "Found $%02x at $%04x +$%02x", hi, pc, i+0x07); + } + + break; + } + } + + if (i >= 128) { + log_error(wclog, "Did NOT find expected dongle code/value near %04x", pc); + + /* Try for version /D3 */ + i = 0x7E; /* 0x2735 - 0x26b7 */ + + if (mem[pc + i + 0] == 0x98 && /* TYA */ + mem[pc + i + 1] == 0x49) { /* EOR $hi */ + hi = mem[pc + i + 2]; + log_message(wclog, "Found %02x 2nd try at %04x", hi, pc + i + 2); + } + } + + if (lo_found ? hi|lo : hi) { + dongle_data[port].value_detected = true; + dongle_data[port].dongle_value = reverse16((hi << 8) | lo); + } else { + /* The "WMAST?0ME/F32" program accepts any value except 0 */ + log_message(wclog, "Value zero found; not using that."); + } + } +} + +/* ---------------------------------------------------------------------*/ + +static void wordcraft_dongle_powerup(int port) +{ + dongle_data[port].shift_count = 0; +} + +static void wordcraft_dongle_set_motor_line(int port, int value) +{ + if (value != dongle_data[port].clock_enable_line) { + log_verbose(wclog, "wordcraft_dongle_set_motor_line: %d %d", port, value); + } + dongle_data[port].clock_enable_line = value; /* but apparently not used */ +} + +/* + * The tape input on the PET is strictly edge-triggered. To compensate for that, + * after every "active transition", the dongle checking code toggles the active + * direction. This way it can detect both 1 and 0 inputs. + * Because of this, we do not need to worry if we send duplicate "transitions" + * in the same direction into the PIA code. Those are implemented inaccurately. + */ +static void wordcraft_dongle_toggle_write_line(int port, int value) +{ + log_debug(wclog, "wordcraft_dongle_toggle_write_line: %d %d", port, value); + + if (!dongle_data[port].clock_in_line && value) { + /* + * Shift a bit on the RISING edge of the clock. The dongle checking + * code does both transitions right after each other, before reading + * input. So it doesn't really matter which edge is used. LSB first. + */ + bool bit = (dongle_data[port].dongle_value >> dongle_data[port].shift_count) & 1; + log_verbose(wclog, "wordcraft_dongle_toggle_write_line: send bit #%d %d", + dongle_data[port].shift_count, bit); + dongle_data[port].shift_count++; + + tapeport_set_read_in(bit, port); + dongle_data[port].data_in_line = bit; + } + dongle_data[port].clock_in_line = value; +} + +static void wordcraft_dongle_set_sense_line(int port, int value) +{ + if (!dongle_data[port].load_line && value) { + log_verbose(wclog, "wordcraft_dongle_sense_line: %d %d rise: restart shift sequence", port, value); + /* Restart the shifting sequence */ + dongle_data[port].shift_count = 0; + + wordcraft_dongle_detect_values(port); + } + dongle_data[port].load_line = value; +} + +static void wordcraft_dongle_set_read_line(int port, int value) +{ + log_debug(wclog, "wordcraft_dongle_set_read_line: %d %d", port, value); +} Added: trunk/vice/src/tapeport/wordcraft-dongle.h =================================================================== --- trunk/vice/src/tapeport/wordcraft-dongle.h (rev 0) +++ trunk/vice/src/tapeport/wordcraft-dongle.h 2025-05-01 10:26:52 UTC (rev 45656) @@ -0,0 +1,34 @@ +/* + * sense-dongle.h: tape port dongle that asserts the sense line emulation. + * + * Written by + * Olaf 'Rhialto' Seibert <rh...@fa...> + * + * 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_WORDCRAFTDONGLE_H +#define VICE_WORDCRAFTDONGLE_H + +#include "types.h" + +int wordcraft_dongle_resources_init(int amount); + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <co...@us...> - 2025-04-29 15:52:16
|
Revision: 45655 http://sourceforge.net/p/vice-emu/code/45655 Author: compyx Date: 2025-04-29 15:51:59 +0000 (Tue, 29 Apr 2025) Log Message: ----------- Create branch to allow host joystick events to be passed to the UI instead of the emulated joysticks Added Paths: ----------- branches/compyx/joymap-003/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <co...@us...> - 2025-04-29 15:35:23
|
Revision: 45654 http://sourceforge.net/p/vice-emu/code/45654 Author: compyx Date: 2025-04-29 15:35:06 +0000 (Tue, 29 Apr 2025) Log Message: ----------- Merge branch compyx/joymap-002 intro trunk Implement opening and closing host joystick devices via resources and manually. Host devices will now only be opened when a "JoyDevice{N}" resource is set, or when joystick_device_open() is called manually. When a "JoyDevice{N}" resource is changed the old host device (if any) is closed before opening the new one. This prepares the code for polling via the UI (for mapping and calibration). Modified Paths: -------------- trunk/vice/src/arch/gtk3/joystickdrv/joystick_bsd.c trunk/vice/src/arch/gtk3/joystickdrv/joystick_linux_evdev.c trunk/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c trunk/vice/src/arch/sdl/joy.c trunk/vice/src/joyport/joystick.c trunk/vice/src/joyport/joystick.h Added Paths: ----------- trunk/vice/src/vic20/cart/writenow.c trunk/vice/src/vic20/cart/writenow.h Removed Paths: ------------- trunk/vice/src/vic20/cart/writenow.c trunk/vice/src/vic20/cart/writenow.h Modified: trunk/vice/src/arch/gtk3/joystickdrv/joystick_bsd.c =================================================================== --- trunk/vice/src/arch/gtk3/joystickdrv/joystick_bsd.c 2025-04-29 15:24:36 UTC (rev 45653) +++ trunk/vice/src/arch/gtk3/joystickdrv/joystick_bsd.c 2025-04-29 15:35:06 UTC (rev 45654) @@ -110,11 +110,12 @@ /* Forward declarations */ -static bool bsd_joy_open (joystick_device_t *joydev); -static void bsd_joy_poll (joystick_device_t *joydev); -static void bsd_joy_close (joystick_device_t *joydev); -static void bsd_joy_customize(joystick_device_t *joydev); -static void joy_priv_free (void *priv); +static bool bsd_joy_open (joystick_device_t *joydev); +static void bsd_joy_poll (joystick_device_t *joydev); +static void bsd_joy_close (joystick_device_t *joydev); +static void bsd_joy_customize(joystick_device_t *joydev); +static joy_priv_t *joy_hid_open (const char *node); +static void joy_priv_free (void *priv); /** \brief Log for BSD joystick driver */ @@ -140,14 +141,14 @@ { joy_priv_t *priv = lib_malloc(sizeof *priv); - priv->buffer = NULL; - priv->rep_desc = NULL; - priv->rep_size = 0; - priv->fd = -1; - priv->rep_id = 0; - priv->prev_axes = NULL; + priv->buffer = NULL; + priv->rep_desc = NULL; + priv->rep_size = 0; + priv->fd = -1; + priv->rep_id = 0; + priv->prev_axes = NULL; priv->prev_buttons = NULL; - priv->prev_hats = NULL; + priv->prev_hats = NULL; return priv; } @@ -163,10 +164,7 @@ joy_priv_t *p = priv; if (p != NULL) { - if (p->fd >= 0) { - close(p->fd); - } - lib_free(p->buffer); + lib_free(p->buffer); if (p->rep_desc != NULL) { hid_dispose_report_desc(p->rep_desc); } @@ -173,6 +171,9 @@ lib_free(p->prev_axes); lib_free(p->prev_buttons); lib_free(p->prev_hats); + if (p->fd >= 0) { + close(p->fd); + } lib_free(p); } } @@ -183,7 +184,25 @@ */ static bool bsd_joy_open (joystick_device_t *joydev) { - return true; /* NOP */ + if (joydev != NULL) { + joy_priv_t *priv = joydev->priv; + + if (priv == NULL) { + log_error(bsd_joy_log, + "%s(): failed to open device %s", + __func__, joydev->node); + return false; /* error opening device, already reported */ + } + priv->fd = open(joydev->node, O_RDONLY|O_NONBLOCK); + if (priv->fd < 0) { + log_error(bsd_joy_log, + "%s(): failed to open device %s: %d: %s", + __func__, joydev->node, errno, strerror(errno)); + return false; + } + return true; + } + return false; } /** \brief Poll joystick device @@ -304,8 +323,12 @@ static void bsd_joy_close(joystick_device_t *joydev) { if (joydev != NULL && joydev->priv != NULL) { - joy_priv_free(joydev->priv); - joydev->priv = NULL; + joy_priv_t *priv = joydev->priv; + + if (priv->fd >= 0) { + close(priv->fd); + priv->fd = -1; + } } } @@ -352,9 +375,9 @@ * the report ID and size and allocates a \c joy_priv_t instance with all that * data. * - * \param[in] node path in <tt>/dev/</tt> to the device + * \param[in] node path in \c /dev/ to the device * - * \return new initialized \c joy_priv_t instance or <tt>NULL</tt> on error + * \return new initialized \c joy_priv_t instance or \c NULL on error */ static joy_priv_t *joy_hid_open(const char *node) { @@ -404,11 +427,11 @@ /* success: allocate private data object and store what we need for polling * and further querying */ priv = joy_priv_new(); - priv->buffer = lib_malloc((size_t)rep_size); - priv->rep_desc = rep_desc; - priv->rep_size = rep_size; - priv->rep_id = rep_id; - priv->fd = fd; + priv->buffer = lib_malloc((size_t)rep_size); + priv->rep_desc = rep_desc; + priv->rep_size = rep_size; + priv->rep_id = rep_id; + priv->fd = fd; return priv; } @@ -619,6 +642,8 @@ node = full_node_path(namelist[n]->d_name); joydev = scan_device(node); if (joydev != NULL) { + joy_priv_t *priv; + log_message(bsd_joy_log, "%s: %s", joydev->node, joydev->name); /* scan axes, buttons and hats */ @@ -631,14 +656,13 @@ joydev->node, joydev->name); joystick_device_free(joydev); } else { - /* allocate arrays for previous values of inputs */ - joy_priv_t *priv = joydev->priv; - - priv->prev_axes = lib_malloc((size_t)joydev->num_axes * + priv = joydev->priv; + /* allocate arrays for previous input states */ + priv->prev_axes = lib_calloc((size_t)joydev->num_axes, sizeof *priv->prev_axes); - priv->prev_buttons = lib_malloc((size_t)joydev->num_buttons * + priv->prev_buttons = lib_calloc((size_t)joydev->num_buttons, sizeof *priv->prev_buttons); - priv->prev_hats = lib_malloc((size_t)joydev->num_hats * + priv->prev_hats = lib_calloc((size_t)joydev->num_hats, sizeof *priv->prev_hats); } } else { @@ -648,6 +672,10 @@ joydev->node, joydev->name); joystick_device_free(joydev); } + + /* close device */ + priv = joydev->priv; + close(priv->fd); } lib_free(node); free(namelist[n]); Modified: trunk/vice/src/arch/gtk3/joystickdrv/joystick_linux_evdev.c =================================================================== --- trunk/vice/src/arch/gtk3/joystickdrv/joystick_linux_evdev.c 2025-04-29 15:24:36 UTC (rev 45653) +++ trunk/vice/src/arch/gtk3/joystickdrv/joystick_linux_evdev.c 2025-04-29 15:35:06 UTC (rev 45654) @@ -431,9 +431,11 @@ joydev = scan_device(namelist[i]->d_name); if (joydev != NULL) { joystick_device_register(joydev); +#if 0 /* open joystick: REMOVE once we have opening/closing via resource * and manually implemented properly */ linux_joystick_evdev_open(joydev); +#endif } } free(namelist); Modified: trunk/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c =================================================================== --- trunk/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c 2025-04-29 15:24:36 UTC (rev 45653) +++ trunk/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c 2025-04-29 15:35:06 UTC (rev 45654) @@ -26,7 +26,8 @@ */ #include "vice.h" - +#include <stdbool.h> +#include <stdint.h> #include "joyport.h" #include "joystick.h" #include "lib.h" @@ -54,8 +55,11 @@ * Contains arch-specific data of a joystick device. */ typedef struct joy_priv_s { - GUID guid; /**< GUID */ - LPDIRECTINPUTDEVICE8 didev; /**< DirectInput device instance */ + GUID guid; /**< GUID */ + LPDIRECTINPUTDEVICE8 didev; /**< DirectInput device instance */ + bool acquired; /**< device has been acquired (DirectInput + doesn't provide any method to determine + if a device is acquired) */ LONG prev_axes[DIJS2_MAX_AXES]; /**< prev state of axes */ BYTE prev_buttons[DIJS2_MAX_BUTTONS]; /**< prev state of buttons */ WORD prev_hats[DIJS2_MAX_HATS]; /**< prev state of POVs */ @@ -82,7 +86,8 @@ static joy_priv_t *joy_priv_new(void) { joy_priv_t *priv = lib_calloc(sizeof *priv, 1); - priv->didev = NULL; + priv->didev = NULL; + priv->acquired = false; /* set POV values to neutral (0xffff) */ memset(priv->prev_hats, 0xff, sizeof priv->prev_hats); return priv; @@ -124,11 +129,13 @@ result = IDirectInputDevice8_Acquire(priv->didev); if (SUCCEEDED(result)) { - return true; + priv->acquired = true; + } else { + log_error(winjoy_log, "failed to acquire device \"%s\": error 0x%08lx", + joydev->name, (unsigned long)result); + priv->acquired = false; } - log_error(winjoy_log, "failed to acquire device \"%s\": error 0x%08lx", - joydev->name, (unsigned long)result); - return false; + return priv->acquired; } /** \brief Joystick drive poll() method @@ -166,7 +173,11 @@ HRESULT result; /* poll device */ - priv = joydev->priv; + priv = joydev->priv; + if (!priv->acquired) { + /* not open, done */ + return; + } result = IDirectInputDevice8_Poll(priv->didev); if (result != DI_OK && result != DI_NOEFFECT) { return; @@ -225,9 +236,6 @@ * is reported as 0xffff. * Translate position on a circle to joystick directions, clockwise * from North through to Northwest */ -#if 0 - printf("HAT %d: %u\n", i, (unsigned int)value); -#endif if (value == 0xffff) { /* report neutral position */ direction = JOYSTICK_DIRECTION_NONE; @@ -238,33 +246,6 @@ WORD hidx = ((value + 2250) % 36000) / 4500; direction = hat_map[hidx]; } -#if 0 - } else if (value >= 33750 || value < 2250) { - /* North */ - direction = JOYSTICK_DIRECTION_UP; - } else if (value >= 2250 && value < 6750) { - /* Northeast */ - direction = JOYSTICK_DIRECTION_UP|JOYSTICK_DIRECTION_RIGHT; - } else if (value >= 6750 && value < 11250) { - /* East */ - direction = JOYSTICK_DIRECTION_RIGHT; - } else if (value >= 11250 && value < 15750) { - /* Southeast */ - direction = JOYSTICK_DIRECTION_DOWN|JOYSTICK_DIRECTION_RIGHT; - } else if (value >= 15750 && value < 20250) { - /* South */ - direction = JOYSTICK_DIRECTION_DOWN; - } else if (value >= 20250 && value < 24750) { - /* Southwest */ - direction = JOYSTICK_DIRECTION_DOWN|JOYSTICK_DIRECTION_LEFT; - } else if (value >= 24750 && value < 29250) { - /* West */ - direction = JOYSTICK_DIRECTION_LEFT; - } else if (value >= 29250 && value < 33750) { - /* Northwest */ - direction = JOYSTICK_DIRECTION_UP|JOYSTICK_DIRECTION_LEFT; - } -#endif joy_hat_event(hat, direction); } } @@ -278,6 +259,7 @@ joy_priv_t *priv = joydev->priv; IDirectInputDevice8_Unacquire(priv->didev); + priv->acquired = false; } @@ -465,12 +447,6 @@ (LPVOID)joydev, DIDFT_ABSAXIS|DIDFT_BUTTON|DIDFT_POV); - /* Open device manually for polling, until the driver's open() method has - * been properly implemented and tested (changing resource "JoyDeviceN" - * should close the old device and open the new one) - */ - win32_joy_open(joydev); - /* register device and continue */ joystick_device_register(joydev); return DIENUM_CONTINUE; Modified: trunk/vice/src/arch/sdl/joy.c =================================================================== --- trunk/vice/src/arch/sdl/joy.c 2025-04-29 15:24:36 UTC (rev 45653) +++ trunk/vice/src/arch/sdl/joy.c 2025-04-29 15:35:06 UTC (rev 45654) @@ -164,8 +164,16 @@ /* ------------------------------------------------------------------------- */ +/* + * Driver methods + */ + static bool sdl_joystick_open(joystick_device_t *joydev) { + /* NOP: SDL has its own mechanism for opening/closing devices and appears + * to just keep all host devices it found open. We return `true` here to + * avoid resource setters triggering an error. + */ return true; } @@ -176,18 +184,17 @@ static void sdl_joystick_close(joystick_device_t *joystick) { -#if 0 - SDL_JoystickClose(joystick); - lib_free(joy_ordinal_to_id); - joy_ordinal_to_id = NULL; -#endif + /* NOP: The actual call to SDL_JoystickClose() happens on emulator shutdown, + * not when closing via VICE's driver */ } +/** \brief SDL-specific host device data + */ typedef struct joy_priv_s { - SDL_Joystick *sdldev; - VICE_SDL_JoystickID id; - int joynum; + SDL_Joystick *sdldev; /**< SDL device reference */ + VICE_SDL_JoystickID id; /**< joystick ID used by VICE */ + int joynum; /**< joystick index according to SDL */ } joy_priv_t; Modified: trunk/vice/src/joyport/joystick.c =================================================================== --- trunk/vice/src/joyport/joystick.c 2025-04-29 15:24:36 UTC (rev 45653) +++ trunk/vice/src/joyport/joystick.c 2025-04-29 15:35:06 UTC (rev 45654) @@ -105,6 +105,17 @@ #define JOYPAD_NW (JOYPAD_N | JOYPAD_W) #define JOYPAD_NE (JOYPAD_N | JOYPAD_E) + +/** \brief Joystick system has been initialized + * + * Used to prevent the resource setters from trying to open host joystick + * devices that aren't yet available. + * The resource setters can only open devices *after* the joystick system has + * been fully initialized (and available host devices actually registered), + * which isn't the case when resources are initially set via command line. + */ +bool joystick_init_done = false; + static int joyport_joystick[JOYPORT_MAX_PORTS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* Global joystick value. */ @@ -823,12 +834,28 @@ static int set_joystick_device(int val, void *param) { - int port_idx = vice_ptr_to_int(param); + joystick_device_t *joydev; + int port_idx = vice_ptr_to_int(param); + if (val == joystick_port_map[port_idx]) { + /* same device, exit */ + return 0; + } + if (joystick_port_map[port_idx] >= JOYDEV_REALJOYSTICK_MIN) { int olddev = joystick_port_map[port_idx] - JOYDEV_REALJOYSTICK_MIN; if (olddev < num_joystick_devices) { joystick_devices[olddev]->joyport = -1; + /* close old device */ + if (joystick_init_done) { + joydev = joystick_device_by_index(olddev); +#if 0 + log_message(joy_log, + "resource JoyDevice%d: closing old device %d (%s)", + port_idx, olddev, joydev->name); +#endif + joystick_device_close(joydev); + } } } @@ -844,6 +871,18 @@ joystick_port_map[i] = JOYDEV_NONE; } } + /* open device for polling */ + if (joystick_init_done) { + joydev = joystick_device_by_index(newdev); +#if 0 + log_message(joy_log, + "resource JoyDevice%d: opening device %d (%s)", + port_idx, newdev, joydev->name); +#endif + if (!joystick_device_open(joydev)) { + return -1; + } + } } } @@ -2707,6 +2746,7 @@ int joystick_init(void) { int res = -1; + int i; joy_log = log_open("Joystick"); @@ -2728,11 +2768,18 @@ joystick_arch_init(); #endif - int i; for (i = 0; i < JOYPORT_MAX_PORTS; i++) { - if (joystick_port_map[i] >= JOYDEV_REALJOYSTICK_MIN) { - if (joystick_port_map[i] - JOYDEV_REALJOYSTICK_MIN < num_joystick_devices) { - joystick_devices[joystick_port_map[i] - JOYDEV_REALJOYSTICK_MIN]->joyport = i; + int devnum = joystick_port_map[i]; + + if (devnum >= JOYDEV_REALJOYSTICK_MIN) { + if (devnum - JOYDEV_REALJOYSTICK_MIN < num_joystick_devices) { + joystick_device_t *joydev = joystick_devices[devnum - JOYDEV_REALJOYSTICK_MIN]; + + joydev->joyport = i; + log_message(joy_log, + "joystick_init(): resource JoyDevice%d: opening device %d (%s)", + i + 1, devnum - JOYDEV_REALJOYSTICK_MIN, joydev->name); + joystick_device_open(joydev); } else { joystick_port_map[i] = JOYDEV_NONE; } @@ -2747,6 +2794,10 @@ log_warning(joy_log, "using minimal default mapping."); } + /* mark joystick init done so any future resource setter calls can open and + * close devices */ + joystick_init_done = true; + return 1; } @@ -4181,3 +4232,20 @@ } } + + +bool joystick_device_open(joystick_device_t *joydev) +{ + if (joydev != NULL && joy_driver.open != NULL) { + return joy_driver.open(joydev); + } + return false; +} + + +void joystick_device_close(joystick_device_t *joydev) +{ + if (joydev != NULL && joy_driver.close != NULL) { + joy_driver.close(joydev); + } +} Modified: trunk/vice/src/joyport/joystick.h =================================================================== --- trunk/vice/src/joyport/joystick.h 2025-04-29 15:24:36 UTC (rev 45653) +++ trunk/vice/src/joyport/joystick.h 2025-04-29 15:35:06 UTC (rev 45654) @@ -351,6 +351,9 @@ } joystick_driver_t; +extern bool joystick_init_done; + + int joystick_init(void); int joystick_resources_init(void); int joystick_cmdline_options_init(void); @@ -448,6 +451,8 @@ joystick_device_t *joystick_device_new (void); void joystick_device_free (joystick_device_t *joydev); bool joystick_device_register (joystick_device_t *joydev); +bool joystick_device_open (joystick_device_t *joydev); +void joystick_device_close (joystick_device_t *joydev); joystick_device_t *joystick_device_by_index (int index); int joystick_device_count (void); Deleted: trunk/vice/src/vic20/cart/writenow.c =================================================================== --- trunk/vice/src/vic20/cart/writenow.c 2025-04-29 15:24:36 UTC (rev 45653) +++ trunk/vice/src/vic20/cart/writenow.c 2025-04-29 15:35:06 UTC (rev 45654) @@ -1,285 +0,0 @@ -/* - * writenow.c -- VIC20 "Write NOW" Cartridge emulation. - * - * Written by - * 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 <stdlib.h> -#include <string.h> - -#include "archdep.h" -#include "writenow.h" -#include "cartio.h" -#include "cartridge.h" -#include "crt.h" -#include "export.h" -#include "lib.h" -#include "log.h" -#include "machine.h" -#include "mem.h" -#include "monitor.h" -#include "resources.h" -#include "snapshot.h" -#include "types.h" -#include "util.h" -#include "vic20cart.h" -#include "vic20cartmem.h" -#include "vic20mem.h" -#include "zfile.h" - -/* #define DEBUGWRITENOW */ - -#ifdef DEBUGWRITENOW -#define DBG(x) log_printf x -#else -#define DBG(x) -#endif - -/* - - "Write Now" - - - 8KiB ROM mapped to A000-BFFF - - - additionally the last 2KiB of the ROM are mapped to IO at 9800-9BFF - - start with SYS41000 -*/ - -/* ------------------------------------------------------------------------- */ - - -#define CART_ROM_SIZE (0x400 * 8) -static uint8_t *cart_rom = NULL; - -/* ------------------------------------------------------------------------- */ - -/* Some prototypes are needed */ -static uint8_t writenow_io2_read(uint16_t addr); -static int writenow_mon_dump(void); - -static io_source_t writenow_io2_device = { - CARTRIDGE_VIC20_NAME_WRITE_NOW, /* 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 */ - 0x9800, 0x9bff, 0x3ff, /* range for the device */ - 1, /* read is always valid */ - NULL, /* store function */ - NULL, /* NO poke function */ - writenow_io2_read, /* read function */ - NULL, /* NO peek function */ - writenow_mon_dump, /* device state information dump function */ - CARTRIDGE_VIC20_WRITE_NOW, /* cartridge ID */ - IO_PRIO_NORMAL, /* 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 io_source_list_t *writenow_io2_list_item = NULL; - -static const export_resource_t export_res23 = { - CARTRIDGE_VIC20_NAME_WRITE_NOW, 0, VIC_CART_BLK5, &writenow_io2_device, NULL, CARTRIDGE_VIC20_WRITE_NOW -}; - -/* ------------------------------------------------------------------------- */ - -static uint8_t writenow_io2_read(uint16_t addr) -{ - /* DBG(("writenow_io2_read 0x%04x", addr)); */ - return cart_rom[0x1800 + (addr & 0x3ff)]; -} - -/* read 0xa000-0xbfff */ -uint8_t writenow_blk5_read(uint16_t addr) -{ - /* DBG(("writenow_blk5_read 0x%04x", addr)); */ - return cart_rom[addr & 0x1fff]; -} - -/* ------------------------------------------------------------------------- */ - -static int zfile_load(const char *filename, uint8_t *dest, size_t size) -{ - FILE *fd; - off_t len; - - fd = zfile_fopen(filename, MODE_READ); - if (!fd) { - return -1; - } - len = archdep_file_size(fd); - if (len < 0 || (size_t)len != size) { - zfile_fclose(fd); - return -1; - } - if (fread(dest, size, 1, fd) < 1) { - zfile_fclose(fd); - return -1; - } - zfile_fclose(fd); - return 0; -} - -int writenow_crt_attach(FILE *fd, uint8_t *rawcart) -{ - crt_chip_header_t chip; - - if (!cart_rom) { - cart_rom = lib_malloc(CART_ROM_SIZE); - } - - if (crt_read_chip_header(&chip, fd)) { - goto exiterror; - } - - DBG(("chip at %02x len %02x\n", chip.start, chip.size)); - if (chip.size != CART_ROM_SIZE) { - goto exiterror; - } - - if (crt_read_chip(&cart_rom[0], 0, &chip, fd)) { - goto exiterror; - } - - if (export_add(&export_res23) < 0) { - goto exiterror; - } - - mem_cart_blocks = VIC_CART_IO2 | VIC_CART_BLK5; - mem_initialize_memory(); - - writenow_io2_list_item = io_source_register(&writenow_io2_device); - - return CARTRIDGE_VIC20_WRITE_NOW; - -exiterror: - writenow_detach(); - return -1; -} - -int writenow_bin_attach(const char *filename) -{ - if (!cart_rom) { - cart_rom = lib_malloc(CART_ROM_SIZE); - } - - if (zfile_load(filename, cart_rom, (size_t)CART_ROM_SIZE) < 0) { - writenow_detach(); - return -1; - } - - if (export_add(&export_res23) < 0) { - return -1; - } - - mem_cart_blocks = VIC_CART_IO2 | VIC_CART_BLK5; - mem_initialize_memory(); - - writenow_io2_list_item = io_source_register(&writenow_io2_device); - - return 0; -} - -void writenow_detach(void) -{ - mem_cart_blocks = 0; - mem_initialize_memory(); - lib_free(cart_rom); - cart_rom = NULL; - - export_remove(&export_res23); - if (writenow_io2_list_item != NULL) { - io_source_unregister(writenow_io2_list_item); - writenow_io2_list_item = NULL; - } -} - -/* ------------------------------------------------------------------------- */ - -#define VIC20CART_DUMP_VER_MAJOR 0 -#define VIC20CART_DUMP_VER_MINOR 1 -#define SNAP_MODULE_NAME "WRITENOW" - -int writenow_snapshot_write_module(snapshot_t *s) -{ - snapshot_module_t *m; - - m = snapshot_module_create(s, SNAP_MODULE_NAME, VIC20CART_DUMP_VER_MAJOR, VIC20CART_DUMP_VER_MINOR); - if (m == NULL) { - return -1; - } - - if (0 - || (SMW_BA(m, cart_rom, CART_ROM_SIZE) < 0)) { - snapshot_module_close(m); - return -1; - } - - snapshot_module_close(m); - return 0; -} - -int writenow_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; - } - - if (vmajor != VIC20CART_DUMP_VER_MAJOR) { - snapshot_module_close(m); - return -1; - } - - if (!cart_rom) { - cart_rom = lib_malloc(CART_ROM_SIZE); - } - - if (0 - || (SMR_BA(m, cart_rom, CART_ROM_SIZE) < 0)) { - snapshot_module_close(m); - lib_free(cart_rom); - cart_rom = NULL; - return -1; - } - - snapshot_module_close(m); - - mem_cart_blocks = VIC_CART_IO2 | VIC_CART_BLK5; - mem_initialize_memory(); - - return 0; -} - -/* ------------------------------------------------------------------------- */ - -static int writenow_mon_dump(void) -{ - return 0; -} Copied: trunk/vice/src/vic20/cart/writenow.c (from rev 45653, branches/compyx/joymap-002/vice/src/vic20/cart/writenow.c) =================================================================== --- trunk/vice/src/vic20/cart/writenow.c (rev 0) +++ trunk/vice/src/vic20/cart/writenow.c 2025-04-29 15:35:06 UTC (rev 45654) @@ -0,0 +1,285 @@ +/* + * writenow.c -- VIC20 "Write NOW" Cartridge emulation. + * + * Written by + * 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 <stdlib.h> +#include <string.h> + +#include "archdep.h" +#include "writenow.h" +#include "cartio.h" +#include "cartridge.h" +#include "crt.h" +#include "export.h" +#include "lib.h" +#include "log.h" +#include "machine.h" +#include "mem.h" +#include "monitor.h" +#include "resources.h" +#include "snapshot.h" +#include "types.h" +#include "util.h" +#include "vic20cart.h" +#include "vic20cartmem.h" +#include "vic20mem.h" +#include "zfile.h" + +/* #define DEBUGWRITENOW */ + +#ifdef DEBUGWRITENOW +#define DBG(x) log_printf x +#else +#define DBG(x) +#endif + +/* + + "Write Now" + + - 8KiB ROM mapped to A000-BFFF + + - additionally the last 2KiB of the ROM are mapped to IO at 9800-9BFF + + start with SYS41000 +*/ + +/* ------------------------------------------------------------------------- */ + + +#define CART_ROM_SIZE (0x400 * 8) +static uint8_t *cart_rom = NULL; + +/* ------------------------------------------------------------------------- */ + +/* Some prototypes are needed */ +static uint8_t writenow_io2_read(uint16_t addr); +static int writenow_mon_dump(void); + +static io_source_t writenow_io2_device = { + CARTRIDGE_VIC20_NAME_WRITE_NOW, /* 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 */ + 0x9800, 0x9bff, 0x3ff, /* range for the device */ + 1, /* read is always valid */ + NULL, /* store function */ + NULL, /* NO poke function */ + writenow_io2_read, /* read function */ + NULL, /* NO peek function */ + writenow_mon_dump, /* device state information dump function */ + CARTRIDGE_VIC20_WRITE_NOW, /* cartridge ID */ + IO_PRIO_NORMAL, /* 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 io_source_list_t *writenow_io2_list_item = NULL; + +static const export_resource_t export_res23 = { + CARTRIDGE_VIC20_NAME_WRITE_NOW, 0, VIC_CART_BLK5, &writenow_io2_device, NULL, CARTRIDGE_VIC20_WRITE_NOW +}; + +/* ------------------------------------------------------------------------- */ + +static uint8_t writenow_io2_read(uint16_t addr) +{ + /* DBG(("writenow_io2_read 0x%04x", addr)); */ + return cart_rom[0x1800 + (addr & 0x3ff)]; +} + +/* read 0xa000-0xbfff */ +uint8_t writenow_blk5_read(uint16_t addr) +{ + /* DBG(("writenow_blk5_read 0x%04x", addr)); */ + return cart_rom[addr & 0x1fff]; +} + +/* ------------------------------------------------------------------------- */ + +static int zfile_load(const char *filename, uint8_t *dest, size_t size) +{ + FILE *fd; + off_t len; + + fd = zfile_fopen(filename, MODE_READ); + if (!fd) { + return -1; + } + len = archdep_file_size(fd); + if (len < 0 || (size_t)len != size) { + zfile_fclose(fd); + return -1; + } + if (fread(dest, size, 1, fd) < 1) { + zfile_fclose(fd); + return -1; + } + zfile_fclose(fd); + return 0; +} + +int writenow_crt_attach(FILE *fd, uint8_t *rawcart) +{ + crt_chip_header_t chip; + + if (!cart_rom) { + cart_rom = lib_malloc(CART_ROM_SIZE); + } + + if (crt_read_chip_header(&chip, fd)) { + goto exiterror; + } + + DBG(("chip at %02x len %02x\n", chip.start, chip.size)); + if (chip.size != CART_ROM_SIZE) { + goto exiterror; + } + + if (crt_read_chip(&cart_rom[0], 0, &chip, fd)) { + goto exiterror; + } + + if (export_add(&export_res23) < 0) { + goto exiterror; + } + + mem_cart_blocks = VIC_CART_IO2 | VIC_CART_BLK5; + mem_initialize_memory(); + + writenow_io2_list_item = io_source_register(&writenow_io2_device); + + return CARTRIDGE_VIC20_WRITE_NOW; + +exiterror: + writenow_detach(); + return -1; +} + +int writenow_bin_attach(const char *filename) +{ + if (!cart_rom) { + cart_rom = lib_malloc(CART_ROM_SIZE); + } + + if (zfile_load(filename, cart_rom, (size_t)CART_ROM_SIZE) < 0) { + writenow_detach(); + return -1; + } + + if (export_add(&export_res23) < 0) { + return -1; + } + + mem_cart_blocks = VIC_CART_IO2 | VIC_CART_BLK5; + mem_initialize_memory(); + + writenow_io2_list_item = io_source_register(&writenow_io2_device); + + return 0; +} + +void writenow_detach(void) +{ + mem_cart_blocks = 0; + mem_initialize_memory(); + lib_free(cart_rom); + cart_rom = NULL; + + export_remove(&export_res23); + if (writenow_io2_list_item != NULL) { + io_source_unregister(writenow_io2_list_item); + writenow_io2_list_item = NULL; + } +} + +/* ------------------------------------------------------------------------- */ + +#define VIC20CART_DUMP_VER_MAJOR 0 +#define VIC20CART_DUMP_VER_MINOR 1 +#define SNAP_MODULE_NAME "WRITENOW" + +int writenow_snapshot_write_module(snapshot_t *s) +{ + snapshot_module_t *m; + + m = snapshot_module_create(s, SNAP_MODULE_NAME, VIC20CART_DUMP_VER_MAJOR, VIC20CART_DUMP_VER_MINOR); + if (m == NULL) { + return -1; + } + + if (0 + || (SMW_BA(m, cart_rom, CART_ROM_SIZE) < 0)) { + snapshot_module_close(m); + return -1; + } + + snapshot_module_close(m); + return 0; +} + +int writenow_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; + } + + if (vmajor != VIC20CART_DUMP_VER_MAJOR) { + snapshot_module_close(m); + return -1; + } + + if (!cart_rom) { + cart_rom = lib_malloc(CART_ROM_SIZE); + } + + if (0 + || (SMR_BA(m, cart_rom, CART_ROM_SIZE) < 0)) { + snapshot_module_close(m); + lib_free(cart_rom); + cart_rom = NULL; + return -1; + } + + snapshot_module_close(m); + + mem_cart_blocks = VIC_CART_IO2 | VIC_CART_BLK5; + mem_initialize_memory(); + + return 0; +} + +/* ------------------------------------------------------------------------- */ + +static int writenow_mon_dump(void) +{ + return 0; +} Deleted: trunk/vice/src/vic20/cart/writenow.h =================================================================== --- trunk/vice/src/vic20/cart/writenow.h 2025-04-29 15:24:36 UTC (rev 45653) +++ trunk/vice/src/vic20/cart/writenow.h 2025-04-29 15:35:06 UTC (rev 45654) @@ -1,49 +0,0 @@ -/* - * writenow.h -- VIC20 "Write NOW" Cartridge emulation. - * - * Written by - * 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_WRITENOW_H -#define VICE_WRITENOW_H - -#include <stdio.h> - -#include "types.h" - -void writenow_config_setup(uint8_t *rawcart); -int writenow_bin_attach(const char *filename); - -/* int writenow_bin_attach(const char *filename, uint8_t *rawcart); */ - -int writenow_crt_attach(FILE *fd, uint8_t *rawcart); -void writenow_detach(void); - -uint8_t writenow_blk5_read(uint16_t addr); - -struct snapshot_s; - -int writenow_snapshot_write_module(struct snapshot_s *s); -int writenow_snapshot_read_module(struct snapshot_s *s); - -#endif Copied: trunk/vice/src/vic20/cart/writenow.h (from rev 45653, branches/compyx/joymap-002/vice/src/vic20/cart/writenow.h) =================================================================== --- trunk/vice/src/vic20/cart/writenow.h (rev 0) +++ trunk/vice/src/vic20/cart/writenow.h 2025-04-29 15:35:06 UTC (rev 45654) @@ -0,0 +1,49 @@ +/* + * writenow.h -- VIC20 "Write NOW" Cartridge emulation. + * + * Written by + * 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_WRITENOW_H +#define VICE_WRITENOW_H + +#include <stdio.h> + +#include "types.h" + +void writenow_config_setup(uint8_t *rawcart); +int writenow_bin_attach(const char *filename); + +/* int writenow_bin_attach(const char *filename, uint8_t *rawcart); */ + +int writenow_crt_attach(FILE *fd, uint8_t *rawcart); +void writenow_detach(void); + +uint8_t writenow_blk5_read(uint16_t addr); + +struct snapshot_s; + +int writenow_snapshot_write_module(struct snapshot_s *s); +int writenow_snapshot_read_module(struct snapshot_s *s); + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <co...@us...> - 2025-04-29 15:24:54
|
Revision: 45653 http://sourceforge.net/p/vice-emu/code/45653 Author: compyx Date: 2025-04-29 15:24:36 +0000 (Tue, 29 Apr 2025) Log Message: ----------- Merge trunk (r45649:HEAD) into branch Modified Paths: -------------- branches/compyx/joymap-002/vice/doc/vice.texi branches/compyx/joymap-002/vice/src/arch/shared/sounddrv/soundaiff.c branches/compyx/joymap-002/vice/src/arch/shared/sounddrv/soundiff.c branches/compyx/joymap-002/vice/src/arch/shared/sounddrv/soundvoc.c branches/compyx/joymap-002/vice/src/cartridge.h branches/compyx/joymap-002/vice/src/drive/drivemem.c branches/compyx/joymap-002/vice/src/drive/iec/memiec.c branches/compyx/joymap-002/vice/src/ram.c branches/compyx/joymap-002/vice/src/tools/cartconv/vic20-cartridges.c branches/compyx/joymap-002/vice/src/userport/userport_wic64.c branches/compyx/joymap-002/vice/src/vic20/cart/Makefile.am branches/compyx/joymap-002/vice/src/vic20/cart/vic20-generic.c branches/compyx/joymap-002/vice/src/vic20/cart/vic20-generic.h branches/compyx/joymap-002/vice/src/vic20/cart/vic20cart.c branches/compyx/joymap-002/vice/src/vic20/cart/vic20cart.h branches/compyx/joymap-002/vice/src/vic20/cart/vic20cartmem.c branches/compyx/joymap-002/vice/src/vic20/vic20mem.c Added Paths: ----------- branches/compyx/joymap-002/vice/src/vic20/cart/writenow.c branches/compyx/joymap-002/vice/src/vic20/cart/writenow.h Modified: branches/compyx/joymap-002/vice/doc/vice.texi =================================================================== --- branches/compyx/joymap-002/vice/doc/vice.texi 2025-04-29 15:20:48 UTC (rev 45652) +++ branches/compyx/joymap-002/vice/doc/vice.texi 2025-04-29 15:24:36 UTC (rev 45653) @@ -14744,6 +14744,10 @@ @item -cartma <name> Specify Mikro Assembler cartridge ROM name +@findex -cartwn +@item -cartwn <name> +Specify Write Now cartridge ROM name + @findex -ultimem @item -ultimem <name> Specify Ultimem extension ROM name @@ -23615,6 +23619,8 @@ UltiMem @item vicfp Vic Flash Plugin +@item wn +Write Now @end table @b{PLUS4 cartridges:} @@ -34917,6 +34923,8 @@ @tab Super Expander @item 8 @tab Mikro Assembler +@item 9 +@tab Write Now @end multitable @c @node FIXME @@ -35229,6 +35237,37 @@ @c FIXME: cartridge details @c @node FIXME +@subsubsection 9 - Write Now + +@multitable @columnfractions .3 .7 +@item Size +@tab 8KiB (ROM) +@end multitable + +@example + 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F ASCII + ----------------------------------------------- ---------------- + 0000: 56 49 43 32 30 20 43 41 52 54 52 49 44 47 45 20 VIC20 CARTRIDGE + 0010: 00 00 00 40 02 00 00 09 00 00 00 00 00 00 00 00 ...@............ + 0020: 57 72 69 74 65 20 4e 6f 77 00 00 00 00 00 00 00 Write Now....... + 0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 0040: 43 48 49 50 00 00 20 10 00 00 00 00 a0 00 20 00 CHIP.. ....... . + 0050: 00 a5 2c c5 37 a5 2d e5 38 90 03 4c 22 a9 20 af ..,.7.-.8..L". . + 0060: a3 a5 3b 85 26 a5 3c 85 27 a9 01 85 48 20 80 a4 ..;.&.<.'...H .. + 0070: c8 a9 20 91 26 4c 3b a4 20 20 a7 20 3f a0 a9 f2 .. .&L;.....?... + 0080: 85 52 a9 10 85 53 20 ac a0 20 63 a1 4c 2b a0 a9 .R...S .. c.L+.. + 0090: 10 85 71 a5 2a 85 26 a5 2b 85 27 38 a5 2c e9 01 ..q.*.&.+.'8.,.. + +@dots{} + 2030: bd ed bf a2 00 81 28 e6 28 d0 02 e6 29 60 a0 20 ......(.(...)`.. + 2040: df 69 e9 5f 27 0b 43 48 45 4b 2e 49 54 82 43 4d .i._'.CHEK.IT.CM +@end example + +This cartridge maps 8KiB ROM into block5 ($a000-$afff), plus the last 2KiB of the ROM are mapped into IO ($9800-$9Bff) + +@c FIXME: cartridge details + +@c @node FIXME @subsection PLUS4 Cartridge Specifics @multitable @columnfractions .1 .9 Modified: branches/compyx/joymap-002/vice/src/arch/shared/sounddrv/soundaiff.c =================================================================== --- branches/compyx/joymap-002/vice/src/arch/shared/sounddrv/soundaiff.c 2025-04-29 15:20:48 UTC (rev 45652) +++ branches/compyx/joymap-002/vice/src/arch/shared/sounddrv/soundaiff.c 2025-04-29 15:24:36 UTC (rev 45653) @@ -33,6 +33,8 @@ #include "archdep.h" #include "log.h" +#define AIFF_HEADER_LEN 54 + static FILE *aiff_fd = NULL; static int samples = 0; @@ -42,7 +44,7 @@ unsigned int check_value; /* AIFF header. */ - unsigned char header[54] = "FORMssssAIFFCOMM\0\0\0\022\0cffff\0\020\100rrr\0\0\0\0\0\0SSNDssss\0\0\0\0\0\0\0\0"; + unsigned char header[AIFF_HEADER_LEN + 1] = "FORMssssAIFFCOMM\0\0\0\022\0cffff\0\020\100rrr\0\0\0\0\0\0SSNDssss\0\0\0\0\0\0\0\0"; uint32_t sample_rate = (uint32_t)*speed; @@ -69,7 +71,7 @@ check_value = check_value * 2; } - return (fwrite(header, 1, 54, aiff_fd) != 54); + return (fwrite(header, 1, AIFF_HEADER_LEN, aiff_fd) != AIFF_HEADER_LEN); } static int aiff_write(int16_t *pbuf, size_t nr) Modified: branches/compyx/joymap-002/vice/src/arch/shared/sounddrv/soundiff.c =================================================================== --- branches/compyx/joymap-002/vice/src/arch/shared/sounddrv/soundiff.c 2025-04-29 15:20:48 UTC (rev 45652) +++ branches/compyx/joymap-002/vice/src/arch/shared/sounddrv/soundiff.c 2025-04-29 15:24:36 UTC (rev 45653) @@ -33,6 +33,9 @@ #include "archdep.h" #include "log.h" +#define IFF_MONO_HEADER_LEN 48 +#define IFF_STEREO_HEADER_LEN 60 + static FILE *iff_fd = NULL; static int samples = 0; static int stereo = 0; @@ -40,8 +43,8 @@ static int iff_init(const char *param, int *speed, int *fragsize, int *fragnr, int *channels) { /* IFF/8SVX header. */ - unsigned char mono_header[48] = "FORMssss8SVXVHDR\0\0\0\024oooo\0\0\0\0\0\0\0\0rr\001\0\0\001\0\000BODYssss"; - unsigned char stereo_header[60] = "FORMssss8SVXVHDR\0\0\0\024oooo\0\0\0\0\0\0\0\0rr\001\0\0\001\0\0CHAN\0\0\0\004\0\0\0\006BODYssss"; + unsigned char mono_header[IFF_MONO_HEADER_LEN + 1] = "FORMssss8SVXVHDR\0\0\0\024oooo\0\0\0\0\0\0\0\0rr\001\0\0\001\0\000BODYssss"; + unsigned char stereo_header[IFF_STEREO_HEADER_LEN + 1] = "FORMssss8SVXVHDR\0\0\0\024oooo\0\0\0\0\0\0\0\0rr\001\0\0\001\0\0CHAN\0\0\0\004\0\0\0\006BODYssss"; uint16_t sample_rate = (uint16_t)*speed; @@ -58,7 +61,7 @@ stereo = 1; stereo_header[32] = (uint8_t)((sample_rate >> 8) & 0xff); stereo_header[33] = (uint8_t)(sample_rate & 0xff); - if (fwrite(stereo_header, 1, 60, iff_fd) != 60) { + if (fwrite(stereo_header, 1, IFF_STEREO_HEADER_LEN, iff_fd) != IFF_STEREO_HEADER_LEN) { fclose(iff_fd); return 1; } @@ -66,7 +69,7 @@ stereo = 0; mono_header[32] = (uint8_t)((sample_rate >> 8) & 0xff); mono_header[33] = (uint8_t)(sample_rate & 0xff); - if (fwrite(mono_header, 1, 48, iff_fd) != 48) { + if (fwrite(mono_header, 1, IFF_MONO_HEADER_LEN, iff_fd) != IFF_MONO_HEADER_LEN) { fclose(iff_fd); return 1; } Modified: branches/compyx/joymap-002/vice/src/arch/shared/sounddrv/soundvoc.c =================================================================== --- branches/compyx/joymap-002/vice/src/arch/shared/sounddrv/soundvoc.c 2025-04-29 15:20:48 UTC (rev 45652) +++ branches/compyx/joymap-002/vice/src/arch/shared/sounddrv/soundvoc.c 2025-04-29 15:24:36 UTC (rev 45653) @@ -34,6 +34,8 @@ #include "log.h" #define VOC_MAX 0x6fc00c /* taken from sound conversion program */ +#define VOC_HEADER_LEN 26 +#define VOC_BLOCK_HEADER_LEN 16 static FILE *voc_fd = NULL; static int samples = 0; @@ -43,8 +45,8 @@ static int voc_init(const char *param, int *speed, int *fragsize, int *fragnr, int *channels) { /* VOC header. */ - unsigned char header[26] = "Creative Voice File\032\032\0\024\001\037\021"; - unsigned char block_header[16] = "\011sssrrrr\026c\004\0\0\0\0\0"; + unsigned char header[VOC_HEADER_LEN + 1] = "Creative Voice File\032\032\0\024\001\037\021"; + unsigned char block_header[VOC_BLOCK_HEADER_LEN + 1] = "\011sssrrrr\026c\004\0\0\0\0\0"; uint32_t sample_rate = (uint32_t)*speed; voc_fd = fopen(param ? param : "vicesnd.voc", MODE_WRITE); @@ -55,7 +57,7 @@ samples = 0; extra_block = 0; - if (fwrite(header, 1, 26, voc_fd) != 26) { + if (fwrite(header, 1, VOC_HEADER_LEN, voc_fd) != VOC_HEADER_LEN) { fclose(voc_fd); return 1; } @@ -69,7 +71,7 @@ block_header[6] = (uint8_t)((sample_rate >> 16) & 0xff); block_header[7] = (uint8_t)((sample_rate >> 24) & 0xff); - return (fwrite(block_header, 1, 16, voc_fd) != 16); + return (fwrite(block_header, 1, VOC_BLOCK_HEADER_LEN, voc_fd) != VOC_BLOCK_HEADER_LEN); } static int voc_write(int16_t *pbuf, size_t nr) Modified: branches/compyx/joymap-002/vice/src/cartridge.h =================================================================== --- branches/compyx/joymap-002/vice/src/cartridge.h 2025-04-29 15:20:48 UTC (rev 45652) +++ branches/compyx/joymap-002/vice/src/cartridge.h 2025-04-29 15:24:36 UTC (rev 45653) @@ -478,8 +478,9 @@ #define CARTRIDGE_VIC20_RABBIT 6 /* rabbit.c */ #define CARTRIDGE_VIC20_SUPEREXPANDER 7 /* superexpander.c */ #define CARTRIDGE_VIC20_MIKRO_ASSEMBLER 8 /* mikroassembler.c */ +#define CARTRIDGE_VIC20_WRITE_NOW 9 /* writenow.c */ -#define CARTRIDGE_VIC20_LAST 8 /* cartconv: last cartridge in list */ +#define CARTRIDGE_VIC20_LAST 9 /* cartconv: last cartridge in list */ /* * VIC20 Generic cartridges @@ -548,6 +549,7 @@ #define CARTRIDGE_VIC20_NAME_RABBIT "Rabbit Tape" #define CARTRIDGE_VIC20_NAME_SUPEREXPANDER "Super Expander" #define CARTRIDGE_VIC20_NAME_MIKRO_ASSEMBLER "Mikro Assembler" +#define CARTRIDGE_VIC20_NAME_WRITE_NOW "Write Now" /* * plus4 cartridge system Modified: branches/compyx/joymap-002/vice/src/drive/drivemem.c =================================================================== --- branches/compyx/joymap-002/vice/src/drive/drivemem.c 2025-04-29 15:20:48 UTC (rev 45652) +++ branches/compyx/joymap-002/vice/src/drive/drivemem.c 2025-04-29 15:24:36 UTC (rev 45653) @@ -54,7 +54,7 @@ #define DEBUG_DRIVEMEM #ifdef DEBUG_DRIVEMEM -#define LOG(x) log_printf +#define LOG(x) log_printf x #else #define LOG(x) #endif Modified: branches/compyx/joymap-002/vice/src/drive/iec/memiec.c =================================================================== --- branches/compyx/joymap-002/vice/src/drive/iec/memiec.c 2025-04-29 15:20:48 UTC (rev 45652) +++ branches/compyx/joymap-002/vice/src/drive/iec/memiec.c 2025-04-29 15:24:36 UTC (rev 45653) @@ -46,7 +46,7 @@ #define DEBUG_MEMIEC #ifdef DEBUG_MEMIEC -#define LOG(x) log_printf +#define LOG(x) log_printf x #else #define LOG(x) #endif Modified: branches/compyx/joymap-002/vice/src/ram.c =================================================================== --- branches/compyx/joymap-002/vice/src/ram.c 2025-04-29 15:20:48 UTC (rev 45652) +++ branches/compyx/joymap-002/vice/src/ram.c 2025-04-29 15:24:36 UTC (rev 45653) @@ -349,7 +349,7 @@ unsigned char *mem; char *p = s, *pp; int i, a; - const char hextab[16] = "0123456789abcdef"; + const char hextab[16 + 1] = "0123456789abcdef"; mem = lib_malloc(len); ram_init(mem, len); Modified: branches/compyx/joymap-002/vice/src/tools/cartconv/vic20-cartridges.c =================================================================== --- branches/compyx/joymap-002/vice/src/tools/cartconv/vic20-cartridges.c 2025-04-29 15:20:48 UTC (rev 45652) +++ branches/compyx/joymap-002/vice/src/tools/cartconv/vic20-cartridges.c 2025-04-29 15:24:36 UTC (rev 45653) @@ -31,6 +31,7 @@ {0, 0, CARTRIDGE_SIZE_4KB, 0x1000, 0xa000, 1, CRT_CHIP_ROM, CARTRIDGE_VIC20_NAME_SUPEREXPANDER, "se", save_regular_crt}, /* FIXME: second bank should go to a000 */ {0, 0, CARTRIDGE_SIZE_8KB, 0x1000, 0x6000, 2, CRT_CHIP_ROM, CARTRIDGE_VIC20_NAME_MIKRO_ASSEMBLER, "ma", save_regular_crt}, + {0, 0, CARTRIDGE_SIZE_8KB, 0x2000, 0xA000, 1, CRT_CHIP_ROM, CARTRIDGE_VIC20_NAME_WRITE_NOW, "wn", save_regular_crt}, {0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL} }; Modified: branches/compyx/joymap-002/vice/src/userport/userport_wic64.c =================================================================== --- branches/compyx/joymap-002/vice/src/userport/userport_wic64.c 2025-04-29 15:20:48 UTC (rev 45652) +++ branches/compyx/joymap-002/vice/src/userport/userport_wic64.c 2025-04-29 15:24:36 UTC (rev 45653) @@ -1390,7 +1390,7 @@ { int enc_it = 0; int i; - static char hextab[16] = "0123456789abcdef"; + static char hextab[16 + 1] = "0123456789abcdef"; for (i = 0; i < len; i++) { encoded_helper[enc_it++] = hextab[((**p) >> 4) & 0xf]; Modified: branches/compyx/joymap-002/vice/src/vic20/cart/Makefile.am =================================================================== --- branches/compyx/joymap-002/vice/src/vic20/cart/Makefile.am 2025-04-29 15:20:48 UTC (rev 45652) +++ branches/compyx/joymap-002/vice/src/vic20/cart/Makefile.am 2025-04-29 15:24:36 UTC (rev 45653) @@ -49,7 +49,9 @@ vic20cart.c \ vic20cart.h \ vic20cartmem.c \ - vic20cartmem.h + vic20cartmem.h \ + writenow.c \ + writenow.h libmascuerade_a_SOURCES = \ mascuerade-stubs.h \ Modified: branches/compyx/joymap-002/vice/src/vic20/cart/vic20-generic.c =================================================================== --- branches/compyx/joymap-002/vice/src/vic20/cart/vic20-generic.c 2025-04-29 15:20:48 UTC (rev 45652) +++ branches/compyx/joymap-002/vice/src/vic20/cart/vic20-generic.c 2025-04-29 15:24:36 UTC (rev 45653) @@ -53,17 +53,11 @@ #include "zfile.h" #ifdef DEBUGCART -#define DBG(x) printf x +#define DBG(x) log_printf x #else #define DBG(x) #endif -#define TRY_RESOURCE_CARTFILE2 (1 << 8) -#define TRY_RESOURCE_CARTFILE4 (1 << 9) -#define TRY_RESOURCE_CARTFILE6 (1 << 10) -#define TRY_RESOURCE_CARTFILEA (1 << 11) -#define TRY_RESOURCE_CARTFILEB (1 << 12) - /* ------------------------------------------------------------------------- */ /* actual resources */ @@ -125,9 +119,12 @@ #define CART_ROM_SIZE 0x9000 static uint8_t *cart_rom = NULL; -/* Cartridge States */ -int generic_ram_blocks = 0; -int generic_rom_blocks = 0; +/* Flags that indicate which blocks of memory are used by RAM or ROM from the + generic cartridge. These will be combined and form the value that goes to + mem_cart_blocks, which will in turn be used by mem_initialize_memory() to + remap the memory accesses. */ +static int generic_ram_blocks = 0; +static int generic_rom_blocks = 0; static export_resource_t export_res = { CARTRIDGE_VIC20_NAME_GENERIC, 0, 0, NULL, NULL, CARTRIDGE_VIC20_GENERIC @@ -212,14 +209,6 @@ /* ------------------------------------------------------------------------- */ -void generic_init(void) -{ -} - -void generic_reset(void) -{ -} - void generic_config_setup(uint8_t *rawcart) { } @@ -240,7 +229,7 @@ long len; size_t n; - DBG(("attach_image type %d (%04x), file=`%s'.\n", type, (unsigned int)type, filename)); + DBG(("attach_image type %d (%04x), file=`%s'.", type, (unsigned int)type, filename)); fd = zfile_fopen(filename, MODE_READ); if (!fd) { @@ -263,7 +252,7 @@ break; default: /* not a valid file */ zfile_fclose(fd); - DBG(("attach_image error (length check), len=%ld.\n", len)); + DBG(("attach_image error (length check), len=%ld.", len)); return -1; break; } @@ -331,10 +320,10 @@ log_message(LOG_DEFAULT, "could not determine type of cartridge, defaulting to 2KiB $b000-$b7ff"); } } else { - DBG(("attach_image error (autodetect), len=%ld.\n", len)); + DBG(("attach_image error (autodetect), len=%ld.", len)); return -1; } - DBG(("detected cartridge type: %04x addr: %04x len: %04lx\n", (unsigned int)type, addr, (long unsigned int)len)); + DBG(("detected cartridge type: %04x addr: %04x len: %04lx", (unsigned int)type, addr, (long unsigned int)len)); } memset(rawcart, 0xff, 0x8000); /* init all blocks with 0xff */ @@ -348,7 +337,7 @@ } zfile_fclose(fd); - DBG(("loaded %ld 1KiB chunks, preparing type %d (%04x)\n", (long int)n, type, (unsigned int)type)); + DBG(("loaded %ld 1KiB chunks, preparing type %d (%04x)", (long int)n, type, (unsigned int)type)); /* depending on the detected type, set the respective filename string */ switch (type) { @@ -395,7 +384,7 @@ } break; default: - DBG(("attach_image error (string set), len=%ld.\n", len)); + DBG(("attach_image error (string set), len=%ld.", len)); return -1; break; } @@ -496,12 +485,12 @@ break; default: - DBG(("attach_image error (creating mirrors), len=%ld.\n", len)); + DBG(("attach_image error (creating mirrors), len=%ld.", len)); return -1; break; } - DBG(("attaching type %d (%04x)\n", type, (unsigned int)type)); + DBG(("attaching type %d (%04x)", type, (unsigned int)type)); /* attach cartridge data */ switch (type) { @@ -591,7 +580,7 @@ VIC_CART_BLK3 | VIC_CART_BLK5); break; default: - DBG(("attach_image error (image attach), len=%ld.\n", len)); + DBG(("attach_image error (image attach), len=%ld.", len)); return -1; break; } @@ -622,7 +611,7 @@ cart_rom = lib_malloc(CART_ROM_SIZE); } - DBG(("generic_bin_attach type %d, file=`%s'.\n", type, filename)); + DBG(("generic_bin_attach type %d, file=`%s'.", type, filename)); if (type == CARTRIDGE_VIC20_GENERIC) { /* @@ -638,6 +627,7 @@ return -1; } + /* update memory mapping to use the blocks of the generic cartridge(s) */ mem_cart_blocks = generic_ram_blocks | generic_rom_blocks; mem_initialize_memory(); return 0; @@ -659,7 +649,7 @@ cart_rom = lib_malloc(CART_ROM_SIZE); } - DBG(("generic_crt_attach\n")); + DBG(("generic_crt_attach")); do { @@ -669,6 +659,7 @@ if (export_add(&export_res) < 0) { goto exiterror; } + /* update memory mapping to use the blocks of the generic cartridge(s) */ mem_cart_blocks = generic_ram_blocks | generic_rom_blocks; mem_initialize_memory(); return CARTRIDGE_VIC20_GENERIC; @@ -676,7 +667,7 @@ goto exiterror; } - DBG(("chip %d at %02x len %02x\n", idx, chip.start, chip.size)); + DBG(("chip %d at %02x len %02x", idx, chip.start, chip.size)); if ((chip.start >= 0x2000) && (chip.start <= 0x3fff)) { /* block 1 */ generic_rom_blocks |= VIC_CART_BLK1; offset = chip.start; @@ -702,7 +693,7 @@ } while (idx < 8); /* FIXME */ exiterror: - DBG(("generic_crt_attach: error\n")); + DBG(("generic_crt_attach: error")); generic_detach(); return -1; } @@ -711,8 +702,11 @@ { generic_ram_blocks = 0; generic_rom_blocks = 0; + + /* reset memory map to all "no cartridge" */ mem_cart_blocks = 0; mem_initialize_memory(); + lib_free(cart_ram); lib_free(cart_rom); cart_ram = NULL; @@ -905,6 +899,7 @@ snapshot_module_close(m); + /* update memory mapping to use only the saved blocks */ mem_cart_blocks = generic_ram_blocks | generic_rom_blocks; mem_initialize_memory(); Modified: branches/compyx/joymap-002/vice/src/vic20/cart/vic20-generic.h =================================================================== --- branches/compyx/joymap-002/vice/src/vic20/cart/vic20-generic.h 2025-04-29 15:20:48 UTC (rev 45652) +++ branches/compyx/joymap-002/vice/src/vic20/cart/vic20-generic.h 2025-04-29 15:24:36 UTC (rev 45653) @@ -42,14 +42,6 @@ uint8_t generic_blk5_read(uint16_t addr); void generic_blk5_store(uint16_t addr, uint8_t value); -/* uint8_t generic_io2_read(uint16_t addr); */ -/* void generic_io2_store(uint16_t addr, uint8_t value); */ -/* uint8_t generic_io3_read(uint16_t addr); */ -/* void generic_io3_store(uint16_t addr, uint8_t value); */ - -void generic_init(void); -void generic_reset(void); - void generic_config_setup(uint8_t *rawcart); int generic_bin_attach(int type, const char *filename); Modified: branches/compyx/joymap-002/vice/src/vic20/cart/vic20cart.c =================================================================== --- branches/compyx/joymap-002/vice/src/vic20/cart/vic20cart.c 2025-04-29 15:20:48 UTC (rev 45652) +++ branches/compyx/joymap-002/vice/src/vic20/cart/vic20cart.c 2025-04-29 15:24:36 UTC (rev 45653) @@ -86,9 +86,10 @@ #include "sidcart.h" #include "ultimem.h" #include "vic-fp.h" +#include "writenow.h" #ifdef DEBUGCART -#define DBG(x) printf x +#define DBG(x) log_printf x #else #define DBG(x) #endif @@ -98,16 +99,14 @@ int cartridge_is_from_snapshot = 0; /* actual resources */ -static char *cartridge_file = NULL; -static int cartridge_type; -static int vic20cartridge_reset; +static char *cartridge_file = NULL; /* filename of the default cartridge */ +static int cartridge_type; /* type of the default cartridge */ +static int vic20cartridge_reset; /* if 1, reset VIC20 on cartridge change */ /* local shadow of some resources (e.g not yet set as default) */ static int vic20cart_type = CARTRIDGE_NONE; static char *cartfile = NULL; -static int cartres_flags = 0; - static int cartridge_attach_from_resource(int type, const char *filename); static cartridge_info_t cartlist[] = { @@ -130,6 +129,7 @@ { CARTRIDGE_VIC20_NAME_RABBIT, CARTRIDGE_VIC20_RABBIT, CARTRIDGE_GROUP_UTIL }, { CARTRIDGE_VIC20_NAME_SUPEREXPANDER, CARTRIDGE_VIC20_SUPEREXPANDER, CARTRIDGE_GROUP_UTIL }, { CARTRIDGE_VIC20_NAME_UM, CARTRIDGE_VIC20_UM, CARTRIDGE_GROUP_UTIL }, + { CARTRIDGE_VIC20_NAME_WRITE_NOW, CARTRIDGE_VIC20_WRITE_NOW, CARTRIDGE_GROUP_UTIL }, { NULL, 0, 0 } }; @@ -139,29 +139,19 @@ return &cartlist[0]; } -void reset_try_flags(void) -{ - cartres_flags = 0; -} - +/* this function coordinates the handling of the different resources that are + used for the cartridges, in particular the generic cartridge, and the + separate resources that exist for cartridges in each block */ int try_cartridge_attach(int c) { -/* FIXME: whatever this was trying to do, it doesnt work. eg having a default - (generic) cartridge in vicerc doesnt work when this logic is active. -*/ -/* - cartres_flags ^= c; - if (cartres_flags) { - return 0; - } -*/ - DBG(("try_cartridge_attach '%d'\n", c)); + DBG(("try_cartridge_attach '%d'", c)); return cartridge_attach_from_resource(vic20cart_type, cartfile); } +/* sets the "default cartridge type" resource */ static int set_cartridge_type(int val, void *param) { - DBG(("set_cartridge_type '%d'\n", val)); + DBG(("set_cartridge_type '%d'", val)); switch (val) { case CARTRIDGE_NONE: case CARTRIDGE_VIC20_GENERIC: @@ -174,6 +164,7 @@ case CARTRIDGE_VIC20_FP: case CARTRIDGE_VIC20_IEEE488: case CARTRIDGE_VIC20_SIDCART: + case CARTRIDGE_VIC20_WRITE_NOW: case CARTRIDGE_VIC20_DETECT: case CARTRIDGE_VIC20_4KB_2000: @@ -353,6 +344,9 @@ { "-cartma", CALL_FUNCTION, CMDLINE_ATTRIB_NEED_ARGS, attach_cartridge_cmdline, (void *)CARTRIDGE_VIC20_MIKRO_ASSEMBLER, NULL, NULL, "<Name>", "Specify " CARTRIDGE_VIC20_NAME_MIKRO_ASSEMBLER " cartridge ROM name" }, + { "-cartwn", CALL_FUNCTION, CMDLINE_ATTRIB_NEED_ARGS, + attach_cartridge_cmdline, (void *)CARTRIDGE_VIC20_WRITE_NOW, NULL, NULL, + "<Name>", "Specify " CARTRIDGE_VIC20_NAME_WRITE_NOW " cartridge ROM name" }, { "+cart", CALL_FUNCTION, CMDLINE_ATTRIB_NONE, detach_cartridge_cmdline, NULL, NULL, NULL, @@ -388,9 +382,11 @@ } /* ------------------------------------------------------------------------- */ + +// FIXME: type is passed, but vic20cart_type used instead? static int cartridge_attach_from_resource(int type, const char *filename) { - DBG(("cartridge_attach_from_resource type: %d name: '%s'\n", type, filename)); + DBG(("cartridge_attach_from_resource type: %d name: '%s'", type, filename)); if (vic20cart_type == CARTRIDGE_VIC20_GENERIC) { /* special case handling for the multiple file generic type */ return generic_attach_from_resource(vic20cart_type, cartfile); @@ -410,7 +406,7 @@ int ret, new_crttype; FILE *fd; - DBG(("crt_attach: %s\n", filename)); + DBG(("crt_attach: %s", filename)); fd = crt_open(filename, &header); @@ -423,7 +419,7 @@ /* handle our negative test IDs */ new_crttype -= 0x10000; } - DBG(("crt_attach ID: %d\n", new_crttype)); + DBG(("crt_attach ID: %d", new_crttype)); /* cart should always be detached. there is no reason for doing fancy checks here, and it will cause problems incase a cart MUST be detached before @@ -466,8 +462,11 @@ case CARTRIDGE_VIC20_UM: ret = vic_um_crt_attach(fd, rawcart, filename); break; + case CARTRIDGE_VIC20_WRITE_NOW: + ret = writenow_crt_attach(fd, rawcart); + break; default: - archdep_startup_log_error("unknown CRT ID: %d\n", new_crttype); + archdep_startup_log_error("unknown CRT ID: %d", new_crttype); ret = -1; break; } @@ -475,10 +474,10 @@ fclose(fd); if (ret == -1) { - DBG(("crt_attach error (%d)\n", ret)); + DBG(("crt_attach error (%d)", ret)); return -1; } - DBG(("crt_attach return ID: %d\n", new_crttype)); + DBG(("crt_attach return ID: %d", new_crttype)); return new_crttype; } @@ -528,8 +527,11 @@ case CARTRIDGE_VIC20_UM: ret = vic_um_bin_attach(filename); break; + case CARTRIDGE_VIC20_WRITE_NOW: + ret = writenow_bin_attach(filename); + break; } - DBG(("cart_bin_attach type: %d ret: %d\n", type, ret)); + DBG(("cart_bin_attach type: %d ret: %d", type, ret)); return ret; } @@ -549,7 +551,7 @@ int carttype = CARTRIDGE_NONE; int cartid = CARTRIDGE_NONE; - DBG(("cartridge_attach_image type '%d'(0x%04x) name: '%s'\n", type, type, filename)); + DBG(("cartridge_attach_image type '%d'(0x%04x) name: '%s'", type, (unsigned)type, filename)); /* if (filename == NULL) { return -1; @@ -580,7 +582,7 @@ /* allocate temporary array */ rawcart = lib_malloc(VIC20CART_IMAGE_LIMIT); - DBG(("CART: cartridge_attach_image type: %d ID: %d\n", type, carttype)); + DBG(("CART: cartridge_attach_image type: %d ID: %d", type, carttype)); log_message(LOG_DEFAULT, "Attached cartridge type %d, file=`%s'.", type, filename); @@ -607,7 +609,7 @@ } if (type == CARTRIDGE_CRT) { - DBG(("CART: attach CRT ID: %d '%s'\n", carttype, filename)); + DBG(("CART: attach CRT ID: %d '%s'", carttype, filename)); cartid = crt_attach(abs_filename, rawcart); if (cartid == CARTRIDGE_NONE) { goto exiterror; @@ -614,19 +616,22 @@ } vic20cart_type = cartid; } else { - DBG(("CART: attach BIN ID: %d '%s'\n", carttype, filename)); + DBG(("CART: attach BIN ID: %d '%s'", carttype, filename)); if (cart_bin_attach(carttype, abs_filename, rawcart) < 0) { goto exiterror; } + if (vic20cart_type != CARTRIDGE_VIC20_GENERIC) { + vic20cart_type = carttype; + } } - DBG(("CART: attach RAW ID: %d carttype: %d vic20cart_type:%d\n", + DBG(("CART: attach RAW ID: %d carttype: %d vic20cart_type:%d", cartid, carttype, vic20cart_type)); util_string_set(&cartfile, filename); cartridge_attach(vic20cart_type, NULL); - DBG(("CART: cartridge_attach_image type: %d ID: %d done.\n", type, carttype)); + DBG(("CART: cartridge_attach_image type: %d ID: %d done.", type, carttype)); lib_free(rawcart); log_message(LOG_DEFAULT, "CART: attached '%s' as ID %d.", abs_filename, carttype); lib_free(abs_filename); @@ -633,7 +638,7 @@ return 0; exiterror: - DBG(("CART: error\n")); + DBG(("CART: error")); lib_free(rawcart); log_message(LOG_DEFAULT, "CART: could not attach '%s'.", abs_filename); lib_free(abs_filename); @@ -655,7 +660,7 @@ int carttype = CARTRIDGE_NONE; int cartid = CARTRIDGE_NONE; - DBG(("cartridge_attach_add_image type '%d'(0x%04x) name: '%s'\n", type, type, filename)); + DBG(("cartridge_attach_add_image type '%d'(0x%04x) name: '%s'", type, (unsigned)type, filename)); /* if (filename == NULL) { return -1; @@ -686,12 +691,12 @@ /* allocate temporary array */ rawcart = lib_malloc(VIC20CART_IMAGE_LIMIT); - DBG(("CART: cartridge_attach_add_image type: %d ID: %d\n", type, carttype)); + DBG(("CART: cartridge_attach_add_image type: %d ID: %d", type, carttype)); log_message(LOG_DEFAULT, "Attached cartridge type %d, file=`%s'.", type, filename); if (type == CARTRIDGE_CRT) { - DBG(("CART: attach CRT ID: %d '%s'\n", carttype, filename)); + DBG(("CART: attach CRT ID: %d '%s'", carttype, filename)); cartid = crt_attach(abs_filename, rawcart); if (cartid == CARTRIDGE_NONE) { goto exiterror; @@ -698,13 +703,13 @@ } carttype = cartid; } else { - DBG(("CART: attach BIN ID: %d '%s'\n", carttype, filename)); + DBG(("CART: attach BIN ID: %d '%s'", carttype, filename)); if (cart_bin_attach(carttype, abs_filename, rawcart) < 0) { goto exiterror; } } - DBG(("CART: attach RAW ID: %d carttype: %d vic20cart_type:%d\n", + DBG(("CART: attach RAW ID: %d carttype: %d vic20cart_type:%d", cartid, carttype, vic20cart_type)); /* NOTE: when we use more than one .bin file, we cant set it as default cartridge */ @@ -711,7 +716,7 @@ util_string_set(&cartfile, NULL); cartridge_attach(vic20cart_type, NULL); - DBG(("CART: cartridge_attach_add_image type: %d ID: %d done.\n", type, carttype)); + DBG(("CART: cartridge_attach_add_image type: %d ID: %d done.", type, carttype)); lib_free(rawcart); log_message(LOG_DEFAULT, "CART: attached '%s' as ID %d.", abs_filename, carttype); lib_free(abs_filename); @@ -718,7 +723,7 @@ return 0; exiterror: - DBG(("CART: error\n")); + DBG(("CART: error")); lib_free(rawcart); log_message(LOG_DEFAULT, "CART: could not attach '%s'.", abs_filename); lib_free(abs_filename); @@ -737,7 +742,7 @@ */ int cartridge_enable(int type) { - DBG(("CART: enable type: %d\n", type)); + DBG(("CART: enable type: %d", type)); switch (type) { case CARTRIDGE_DIGIMAX: digimax_enable(); @@ -760,7 +765,7 @@ break; #endif default: - DBG(("CART: no enable hook %d\n", type)); + DBG(("CART: no enable hook %d", type)); break; } @@ -790,7 +795,7 @@ fprintf(stderr, "%s:%d: %s() isn't implemented yet, continuing\n", __FILE__, __LINE__, __func__); */ - DBG(("CART: enable type: %d\n", type)); + DBG(("CART: enable type: %d", type)); switch (type) { case CARTRIDGE_DIGIMAX: digimax_disable(); @@ -813,7 +818,7 @@ break; #endif default: - DBG(("CART: no disable hook %d\n", type)); + DBG(("CART: no disable hook %d", type)); break; } @@ -823,12 +828,13 @@ if (!cart_type_enabled(type)) { return 0; } - log_error(LOG_DEFAULT, "Failed to disable cartridge with ID %d.\n", type); + log_error(LOG_DEFAULT, "Failed to disable cartridge with ID %d.", type); return -1; #endif return 0; } +/* set the currently attached cartridge(s) as default */ void cartridge_set_default(void) { if (cartridge_is_from_snapshot) { @@ -838,11 +844,9 @@ } set_cartridge_type(vic20cart_type, NULL); set_cartridge_file((vic20cart_type == CARTRIDGE_NONE) ? "" : cartfile, NULL); - /* special case handling for the multiple file generic type */ + + /* clear the filenames of the separate files for the generic cartridge */ generic_set_default(); - - /* reset the try flags (we've only called the set function once each) */ - reset_try_flags(); } /** \brief Wipe "default cartidge" @@ -850,7 +854,7 @@ void cartridge_unset_default(void) { util_string_set(&cartridge_file, ""); - /* special case handling for the multiple file generic type */ + /* clear the filenames of the separate files for the generic cartridge */ generic_unset_default(); cartridge_type = CARTRIDGE_NONE; } @@ -1025,7 +1029,7 @@ int cartridge_get_id(int slot) { int type = vic20cart_type; - DBG(("cartridge_get_id(slot:%d): %d %d type:%d\n", slot, cartridge_type, vic20cart_type, type)); + DBG(("cartridge_get_id(slot:%d): %d %d type:%d", slot, cartridge_type, vic20cart_type, type)); return type; } @@ -1078,7 +1082,7 @@ while (e != NULL) { if (number_of_carts == VIC20CART_DUMP_MAX_CARTS) { - DBG(("CART snapshot save: active carts > max (%i)\n", number_of_carts)); + DBG(("CART snapshot save: active carts > max (%i)", number_of_carts)); return -1; } if (last_cart != (int)e->device->cartid) { @@ -1158,6 +1162,11 @@ return -1; } break; + case CARTRIDGE_VIC20_WRITE_NOW: + if (writenow_snapshot_write_module(s) < 0) { + return -1; + } + break; case CARTRIDGE_VIC20_IO2_RAM: if (ioramcart_io2_snapshot_write_module(s) < 0) { @@ -1277,7 +1286,7 @@ } if (number_of_carts > VIC20CART_DUMP_MAX_CARTS) { - DBG(("CART snapshot read: carts %i > max %i\n", number_of_carts, VIC20CART_DUMP_MAX_CARTS)); + DBG(("CART snapshot read: carts %i > max %i", number_of_carts, VIC20CART_DUMP_MAX_CARTS)); goto fail; } @@ -1346,6 +1355,11 @@ return -1; } break; + case CARTRIDGE_VIC20_WRITE_NOW: + if (writenow_snapshot_read_module(s) < 0) { + return -1; + } + break; case CARTRIDGE_VIC20_IO2_RAM: if (ioramcart_io2_snapshot_read_module(s) < 0) { Modified: branches/compyx/joymap-002/vice/src/vic20/cart/vic20cart.h =================================================================== --- branches/compyx/joymap-002/vice/src/vic20/cart/vic20cart.h 2025-04-29 15:20:48 UTC (rev 45652) +++ branches/compyx/joymap-002/vice/src/vic20/cart/vic20cart.h 2025-04-29 15:24:36 UTC (rev 45653) @@ -29,12 +29,18 @@ #include "types.h" -void reset_try_flags(void); +#define TRY_RESOURCE_CARTTYPE (1 << 0) +#define TRY_RESOURCE_CARTNAME (1 << 1) +#define TRY_RESOURCE_CARTRESET (1 << 2) + +#define TRY_RESOURCE_CARTFILE2 (1 << 8) +#define TRY_RESOURCE_CARTFILE4 (1 << 9) +#define TRY_RESOURCE_CARTFILE6 (1 << 10) +#define TRY_RESOURCE_CARTFILEA (1 << 11) +#define TRY_RESOURCE_CARTFILEB (1 << 12) + int try_cartridge_attach(int c); -#define TRY_RESOURCE_CARTTYPE (1 << 0) -#define TRY_RESOURCE_CARTNAME (1 << 1) -#define TRY_RESOURCE_CARTRESET (1 << 2) /* Cartridge ROM limit = 1MB */ #define VIC20CART_ROM_LIMIT (1024 * 1024) Modified: branches/compyx/joymap-002/vice/src/vic20/cart/vic20cartmem.c =================================================================== --- branches/compyx/joymap-002/vice/src/vic20/cart/vic20cartmem.c 2025-04-29 15:20:48 UTC (rev 45652) +++ branches/compyx/joymap-002/vice/src/vic20/cart/vic20cartmem.c 2025-04-29 15:24:36 UTC (rev 45653) @@ -24,7 +24,7 @@ * */ -#define DEBUGCART +/* #define DEBUGCART */ #include "vice.h" @@ -34,6 +34,7 @@ #include "machine.h" #include "mem.h" #include "resources.h" +#include "log.h" #ifdef HAVE_RAWNET #define CARTRIDGE_INCLUDE_PRIVATE_API #define CARTRIDGE_INCLUDE_PUBLIC_API @@ -65,9 +66,10 @@ #include "sidcart.h" #include "superexpander.h" #include "ultimem.h" +#include "writenow.h" #ifdef DEBUGCART -#define DBG(x) printf x +#define DBG(x) log_printf x #else #define DBG(x) #endif @@ -364,8 +366,10 @@ } } +/* A000-BFFF */ uint8_t cartridge_read_blk5(uint16_t addr) { + DBG(("cartridge_read_blk5 (%d) 0x%04x", mem_cartridge_type, addr)); switch (mem_cartridge_type) { case CARTRIDGE_VIC20_BEHRBONZ: vic20_cpu_last_data = behrbonz_blk25_read(addr); @@ -391,10 +395,14 @@ case CARTRIDGE_VIC20_SUPEREXPANDER: vic20_cpu_last_data = superexpander_blk5_read(addr); break; + case CARTRIDGE_VIC20_WRITE_NOW: + vic20_cpu_last_data = writenow_blk5_read(addr); + break; } return vic20_cpu_last_data; } +/* A000-BFFF */ uint8_t cartridge_peek_blk5(uint16_t addr) { switch (mem_cartridge_type) { @@ -412,10 +420,13 @@ return megacart_blk5_read(addr); case CARTRIDGE_VIC20_SUPEREXPANDER: return superexpander_blk5_read(addr); + case CARTRIDGE_VIC20_WRITE_NOW: + return writenow_blk5_read(addr); } return 0; } +/* A000-BFFF */ void cartridge_store_blk5(uint16_t addr, uint8_t value) { vic20_cpu_last_data = value; @@ -442,7 +453,6 @@ void cartridge_init(void) { - generic_init(); behrbonz_init(); finalexpansion_init(); megacart_init(); @@ -461,9 +471,6 @@ case CARTRIDGE_VIC20_BEHRBONZ: behrbonz_reset(); break; - case CARTRIDGE_VIC20_GENERIC: - generic_reset(); - break; case CARTRIDGE_VIC20_UM: vic_um_reset(); break; @@ -526,7 +533,7 @@ mem_cartridge_type = type; - DBG(("cartridge_attach type: %d\n", type)); + DBG(("cartridge_attach type: %d", type)); #if 0 switch (type) { case CARTRIDGE_VIC20_GENERIC: @@ -568,6 +575,8 @@ rabbit_detach(); megacart_detach(); vic_um_detach(); + writenow_detach(); + vic20_ieee488_detach(); #ifdef HAVE_MIDI vic20_midi_detach(); @@ -616,6 +625,9 @@ case CARTRIDGE_VIC20_RABBIT: rabbit_detach(); break; + case CARTRIDGE_VIC20_WRITE_NOW: + writenow_detach(); + break; } mem_cartridge_type = CARTRIDGE_NONE; /* this is probably redundant as it is also performed by the Copied: branches/compyx/joymap-002/vice/src/vic20/cart/writenow.c (from rev 45652, trunk/vice/src/vic20/cart/writenow.c) =================================================================== --- branches/compyx/joymap-002/vice/src/vic20/cart/writenow.c (rev 0) +++ branches/compyx/joymap-002/vice/src/vic20/cart/writenow.c 2025-04-29 15:24:36 UTC (rev 45653) @@ -0,0 +1,285 @@ +/* + * writenow.c -- VIC20 "Write NOW" Cartridge emulation. + * + * Written by + * 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 <stdlib.h> +#include <string.h> + +#include "archdep.h" +#include "writenow.h" +#include "cartio.h" +#include "cartridge.h" +#include "crt.h" +#include "export.h" +#include "lib.h" +#include "log.h" +#include "machine.h" +#include "mem.h" +#include "monitor.h" +#include "resources.h" +#include "snapshot.h" +#include "types.h" +#include "util.h" +#include "vic20cart.h" +#include "vic20cartmem.h" +#include "vic20mem.h" +#include "zfile.h" + +/* #define DEBUGWRITENOW */ + +#ifdef DEBUGWRITENOW +#define DBG(x) log_printf x +#else +#define DBG(x) +#endif + +/* + + "Write Now" + + - 8KiB ROM mapped to A000-BFFF + + - additionally the last 2KiB of the ROM are mapped to IO at 9800-9BFF + + start with SYS41000 +*/ + +/* ------------------------------------------------------------------------- */ + + +#define CART_ROM_SIZE (0x400 * 8) +static uint8_t *cart_rom = NULL; + +/* ------------------------------------------------------------------------- */ + +/* Some prototypes are needed */ +static uint8_t writenow_io2_read(uint16_t addr); +static int writenow_mon_dump(void); + +static io_source_t writenow_io2_device = { + CARTRIDGE_VIC20_NAME_WRITE_NOW, /* 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 */ + 0x9800, 0x9bff, 0x3ff, /* range for the device */ + 1, /* read is always valid */ + NULL, /* store function */ + NULL, /* NO poke function */ + writenow_io2_read, /* read function */ + NULL, /* NO peek function */ + writenow_mon_dump, /* device state information dump function */ + CARTRIDGE_VIC20_WRITE_NOW, /* cartridge ID */ + IO_PRIO_NORMAL, /* 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 io_source_list_t *writenow_io2_list_item = NULL; + +static const export_resource_t export_res23 = { + CARTRIDGE_VIC20_NAME_WRITE_NOW, 0, VIC_CART_BLK5, &writenow_io2_device, NULL, CARTRIDGE_VIC20_WRITE_NOW +}; + +/* ------------------------------------------------------------------------- */ + +static uint8_t writenow_io2_read(uint16_t addr) +{ + /* DBG(("writenow_io2_read 0x%04x", addr)); */ + return cart_rom[0x1800 + (addr & 0x3ff)]; +} + +/* read 0xa000-0xbfff */ +uint8_t writenow_blk5_read(uint16_t addr) +{ + /* DBG(("writenow_blk5_read 0x%04x", addr)); */ + return cart_rom[addr & 0x1fff]; +} + +/* ------------------------------------------------------------------------- */ + +static int zfile_load(const char *filename, uint8_t *dest, size_t size) +{ + FILE *fd; + off_t len; + + fd = zfile_fopen(filename, MODE_READ); + if (!fd) { + return -1; + } + len = archdep_file_size(fd); + if (len < 0 || (size_t)len != size) { + zfile_fclose(fd); + return -1; + } + if (fread(dest, size, 1, fd) < 1) { + zfile_fclose(fd); + return -1; + } + zfile_fclose(fd); + return 0; +} + +int writenow_crt_attach(FILE *fd, uint8_t *rawcart) +{ + crt_chip_header_t chip; + + if (!cart_rom) { + cart_rom = lib_malloc(CART_ROM_SIZE); + } + + if (crt_read_chip_header(&chip, fd)) { + goto exiterror; + } + + DBG(("chip at %02x len %02x\n", chip.start, chip.size)); + if (chip.size != CART_ROM_SIZE) { + goto exiterror; + } + + if (crt_read_chip(&cart_rom[0], 0, &chip, fd)) { + goto exiterror; + } + + if (export_add(&export_res23) < 0) { + goto exiterror; + } + + mem_cart_blocks = VIC_CART_IO2 | VIC_CART_BLK5; + mem_initialize_memory(); + + writenow_io2_list_item = io_source_register(&writenow_io2_device); + + return CARTRIDGE_VIC20_WRITE_NOW; + +exiterror: + writenow_detach(); + return -1; +} + +int writenow_bin_attach(const char *filename) +{ + if (!cart_rom) { + cart_rom = lib_malloc(CART_ROM_SIZE); + } + + if (zfile_load(filename, cart_rom, (size_t)CART_ROM_SIZE) < 0) { + writenow_detach(); + return -1; + } + + if (export_add(&export_res23) < 0) { + return -1; + } + + mem_cart_blocks = VIC_CART_IO2 | VIC_CART_BLK5; + mem_initialize_memory(); + + writenow_io2_list_item = io_source_register(&writenow_io2_device); + + return 0; +} + +void writenow_detach(void) +{ + mem_cart_blocks = 0; + mem_initialize_memory(); + lib_free(cart_rom); + cart_rom = NULL; + + export_remove(&export_res23); + if (writenow_io2_list_item != NULL) { + io_source_unregister(writenow_io2_list_item); + writenow_io2_list_item = NULL; + } +} + +/* ------------------------------------------------------------------------- */ + +#define VIC20CART_DUMP_VER_MAJOR 0 +#define VIC20CART_DUMP_VER_MINOR 1 +#define SNAP_MODULE_NAME "WRITENOW" + +int writenow_snapshot_write_module(snapshot_t *s) +{ + snapshot_module_t *m; + + m = snapshot_module_create(s, SNAP_MODULE_NAME, VIC20CART_DUMP_VER_MAJOR, VIC20CART_DUMP_VER_MINOR); + if (m == NULL) { + return -1; + } + + if (0 + || (SMW_BA(m, cart_rom, CART_ROM_SIZE) < 0)) { + snapshot_module_close(m); + return -1; + } + + snapshot_module_close(m); + return 0; +} + +int writenow_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; + } + + if (vmajor != VIC20CART_DUMP_VER_MAJOR) { + snapshot_module_close(m); + return -1; + } + + if (!cart_rom) { + cart_rom = lib_malloc(CART_ROM_SIZE); + } + + if (0 + || (SMR_BA(m, cart_rom, CART_ROM_SIZE) < 0)) { + snapshot_module_close(m); + lib_free(cart_rom); + cart_rom = NULL; + return -1; + } + + snapshot_module_close(m); + + mem_cart_blocks = VIC_CART_IO2 | VIC_CART_BLK5; + mem_initialize_memory(); + + return 0; +} + +/* ------------------------------------------------------------------------- */ + +static int writenow_mon_dump(void) +{ + return 0; +} Copied: branches/compyx/joymap-002/vice/src/vic20/cart/writenow.h (from rev 45652, trunk/vice/src/vic20/cart/writenow.h) =================================================================== --- branches/compyx/joymap-002/vice/src/vic20/cart/writenow.h (rev 0) +++ branches/compyx/joymap-002/vice/src/vic20/cart/writenow.h 2025-04-29 15:24:36 UTC (rev 45653) @@ -0,0 +1,49 @@ +/* + * writenow.h -- VIC20 "Write NOW" Cartridge emulation. + * + * Written by + * 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_WRITENOW_H +#define VICE_WRITENOW_H + +#include <stdio.h> + +#include "types.h" + +void writenow_config_setup(uint8_t *rawcart); +int writenow_bin_attach(const char *filename); + +/* int writenow_bin_attach(const char *filename, uint8_t *rawcart); */ + +int writenow_crt_attach(FILE *fd, uint8_t *rawcart); +void writenow_detach(void); + +uint8_t writenow_blk5_read(uint16_t addr); + +struct snapshot_s; + +int writenow_snapshot_write_module(struct snapshot_s *s); +int writenow_snapshot_read_module(struct snapshot_s *s); + +#endif Modified: branches/compyx/joymap-002/vice/src/vic20/vic20mem.c =================================================================== --- branches/compyx/joymap-002/vice/src/vic20/vic20mem.c 2025-04-29 15:20:48 UTC (rev 45652) +++ branches/compyx/joymap-002/vice/src/vic20/vic20mem.c 2025-04-29 15:24:36 UTC (rev 45653) @@ -61,6 +61,14 @@ #include "vic20rom.h" #include "vic20via.h" +/* #define DEBUG_VIC20MEM */ + +#ifdef DEBUG_VIC20MEM +#define DBG(x) log_printf x +#else +#define DBG(x) +#endif + /* ------------------------------------------------------------------------- */ /* The VIC20 memory. */ @@ -391,6 +399,8 @@ } } + DBG(("0400-0FFF %s", (mem_cart_blocks & VIC_CART_RAM123) ? "cartridge" : ((ram_block_0_enabled) ? "ram" : "open"))); + if (mem_cart_blocks & VIC_CART_BLK1) { /* a cartridge is selected, map everything to cart/vic20cartmem.c */ set_mem(0x20, 0x3f, @@ -405,6 +415,8 @@ } } + DBG(("2000-3FFF %s", (mem_cart_blocks & VIC_CART_BLK1) ? "cartridge" : ((ram_block_1_enabled) ? "ram" : "open"))); + if (mem_cart_blocks & VIC_CART_BLK2) { /* a cartridge is selected, map everything to cart/vic20cartmem.c */ set_mem(0x40, 0x5f, @@ -419,6 +431,8 @@ } } + DBG(("4000-5FFF %s", (mem_cart_blocks & VIC_CART_BLK2) ? "cartridge" : ((ram_block_2_enabled) ? "ram" : "open"))); + if (mem_cart_blocks & VIC_CART_BLK3) { /* a cartridge is selected, map everything to cart/vic20cartmem.c */ set_mem(0x60, 0x7f, @@ -433,6 +447,8 @@ } } + DBG(("6000-7FFF %s", (mem_cart_blocks & VIC_CART_BLK3) ? "cartridge" : ((ram_block_3_enabled) ? "ram" : "open"))); + if (mem_cart_blocks & VIC_CART_BLK5) { /* a cartridge is selected, map everything to cart/vic20cartmem.c */ set_mem(0xa0, 0xbf, @@ -447,6 +463,8 @@ } } + DBG(("A000-BFFF %s", (mem_cart_blocks & VIC_CART_BLK5) ? "cartridge" : ((ram_block_5_enabled) ? "ram" : "open"))); + /* Setup character generator ROM at $8000-$8FFF. */ set_mem(0x80, 0x8f, chargen_read, store_dummy_v_bus, chargen_peek, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <co...@us...> - 2025-04-29 15:21:05
|
Revision: 45652 http://sourceforge.net/p/vice-emu/code/45652 Author: compyx Date: 2025-04-29 15:20:48 +0000 (Tue, 29 Apr 2025) Log Message: ----------- Fix missing argument in DGB(x) macro expansions Another thing GCC 15.1 caught. Modified Paths: -------------- trunk/vice/src/drive/drivemem.c trunk/vice/src/drive/iec/memiec.c Modified: trunk/vice/src/drive/drivemem.c =================================================================== --- trunk/vice/src/drive/drivemem.c 2025-04-29 14:42:19 UTC (rev 45651) +++ trunk/vice/src/drive/drivemem.c 2025-04-29 15:20:48 UTC (rev 45652) @@ -54,7 +54,7 @@ #define DEBUG_DRIVEMEM #ifdef DEBUG_DRIVEMEM -#define LOG(x) log_printf +#define LOG(x) log_printf x #else #define LOG(x) #endif Modified: trunk/vice/src/drive/iec/memiec.c =================================================================== --- trunk/vice/src/drive/iec/memiec.c 2025-04-29 14:42:19 UTC (rev 45651) +++ trunk/vice/src/drive/iec/memiec.c 2025-04-29 15:20:48 UTC (rev 45652) @@ -46,7 +46,7 @@ #define DEBUG_MEMIEC #ifdef DEBUG_MEMIEC -#define LOG(x) log_printf +#define LOG(x) log_printf x #else #define LOG(x) #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <co...@us...> - 2025-04-29 14:42:38
|
Revision: 45651 http://sourceforge.net/p/vice-emu/code/45651 Author: compyx Date: 2025-04-29 14:42:19 +0000 (Tue, 29 Apr 2025) Log Message: ----------- Joystick: disable debug messages from "JoyDevice{N}" resources Comment out open/close log messages in resource setters. Modified Paths: -------------- branches/compyx/joymap-002/vice/src/joyport/joystick.c Modified: branches/compyx/joymap-002/vice/src/joyport/joystick.c =================================================================== --- branches/compyx/joymap-002/vice/src/joyport/joystick.c 2025-04-29 10:36:48 UTC (rev 45650) +++ branches/compyx/joymap-002/vice/src/joyport/joystick.c 2025-04-29 14:42:19 UTC (rev 45651) @@ -849,9 +849,11 @@ /* close old device */ if (joystick_init_done) { joydev = joystick_device_by_index(olddev); +#if 0 log_message(joy_log, "resource JoyDevice%d: closing old device %d (%s)", port_idx, olddev, joydev->name); +#endif joystick_device_close(joydev); } } @@ -872,9 +874,11 @@ /* open device for polling */ if (joystick_init_done) { joydev = joystick_device_by_index(newdev); +#if 0 log_message(joy_log, "resource JoyDevice%d: opening device %d (%s)", port_idx, newdev, joydev->name); +#endif if (!joystick_device_open(joydev)) { return -1; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <co...@us...> - 2025-04-29 10:37:08
|
Revision: 45650 http://sourceforge.net/p/vice-emu/code/45650 Author: compyx Date: 2025-04-29 10:36:48 +0000 (Tue, 29 Apr 2025) Log Message: ----------- Fix -Wunterminated-string-initialization warning GCC 15.1 (msys2) warns about initialization of arrays with string literals where the terminating NUL character is truncated (we don't actually use the NUL, but I'd rather not add `__attribute__((nonstring))`. Modified Paths: -------------- trunk/vice/src/arch/shared/sounddrv/soundaiff.c trunk/vice/src/arch/shared/sounddrv/soundiff.c trunk/vice/src/arch/shared/sounddrv/soundvoc.c trunk/vice/src/ram.c trunk/vice/src/userport/userport_wic64.c Modified: trunk/vice/src/arch/shared/sounddrv/soundaiff.c =================================================================== --- trunk/vice/src/arch/shared/sounddrv/soundaiff.c 2025-04-28 23:42:30 UTC (rev 45649) +++ trunk/vice/src/arch/shared/sounddrv/soundaiff.c 2025-04-29 10:36:48 UTC (rev 45650) @@ -33,6 +33,8 @@ #include "archdep.h" #include "log.h" +#define AIFF_HEADER_LEN 54 + static FILE *aiff_fd = NULL; static int samples = 0; @@ -42,7 +44,7 @@ unsigned int check_value; /* AIFF header. */ - unsigned char header[54] = "FORMssssAIFFCOMM\0\0\0\022\0cffff\0\020\100rrr\0\0\0\0\0\0SSNDssss\0\0\0\0\0\0\0\0"; + unsigned char header[AIFF_HEADER_LEN + 1] = "FORMssssAIFFCOMM\0\0\0\022\0cffff\0\020\100rrr\0\0\0\0\0\0SSNDssss\0\0\0\0\0\0\0\0"; uint32_t sample_rate = (uint32_t)*speed; @@ -69,7 +71,7 @@ check_value = check_value * 2; } - return (fwrite(header, 1, 54, aiff_fd) != 54); + return (fwrite(header, 1, AIFF_HEADER_LEN, aiff_fd) != AIFF_HEADER_LEN); } static int aiff_write(int16_t *pbuf, size_t nr) Modified: trunk/vice/src/arch/shared/sounddrv/soundiff.c =================================================================== --- trunk/vice/src/arch/shared/sounddrv/soundiff.c 2025-04-28 23:42:30 UTC (rev 45649) +++ trunk/vice/src/arch/shared/sounddrv/soundiff.c 2025-04-29 10:36:48 UTC (rev 45650) @@ -33,6 +33,9 @@ #include "archdep.h" #include "log.h" +#define IFF_MONO_HEADER_LEN 48 +#define IFF_STEREO_HEADER_LEN 60 + static FILE *iff_fd = NULL; static int samples = 0; static int stereo = 0; @@ -40,8 +43,8 @@ static int iff_init(const char *param, int *speed, int *fragsize, int *fragnr, int *channels) { /* IFF/8SVX header. */ - unsigned char mono_header[48] = "FORMssss8SVXVHDR\0\0\0\024oooo\0\0\0\0\0\0\0\0rr\001\0\0\001\0\000BODYssss"; - unsigned char stereo_header[60] = "FORMssss8SVXVHDR\0\0\0\024oooo\0\0\0\0\0\0\0\0rr\001\0\0\001\0\0CHAN\0\0\0\004\0\0\0\006BODYssss"; + unsigned char mono_header[IFF_MONO_HEADER_LEN + 1] = "FORMssss8SVXVHDR\0\0\0\024oooo\0\0\0\0\0\0\0\0rr\001\0\0\001\0\000BODYssss"; + unsigned char stereo_header[IFF_STEREO_HEADER_LEN + 1] = "FORMssss8SVXVHDR\0\0\0\024oooo\0\0\0\0\0\0\0\0rr\001\0\0\001\0\0CHAN\0\0\0\004\0\0\0\006BODYssss"; uint16_t sample_rate = (uint16_t)*speed; @@ -58,7 +61,7 @@ stereo = 1; stereo_header[32] = (uint8_t)((sample_rate >> 8) & 0xff); stereo_header[33] = (uint8_t)(sample_rate & 0xff); - if (fwrite(stereo_header, 1, 60, iff_fd) != 60) { + if (fwrite(stereo_header, 1, IFF_STEREO_HEADER_LEN, iff_fd) != IFF_STEREO_HEADER_LEN) { fclose(iff_fd); return 1; } @@ -66,7 +69,7 @@ stereo = 0; mono_header[32] = (uint8_t)((sample_rate >> 8) & 0xff); mono_header[33] = (uint8_t)(sample_rate & 0xff); - if (fwrite(mono_header, 1, 48, iff_fd) != 48) { + if (fwrite(mono_header, 1, IFF_MONO_HEADER_LEN, iff_fd) != IFF_MONO_HEADER_LEN) { fclose(iff_fd); return 1; } Modified: trunk/vice/src/arch/shared/sounddrv/soundvoc.c =================================================================== --- trunk/vice/src/arch/shared/sounddrv/soundvoc.c 2025-04-28 23:42:30 UTC (rev 45649) +++ trunk/vice/src/arch/shared/sounddrv/soundvoc.c 2025-04-29 10:36:48 UTC (rev 45650) @@ -34,6 +34,8 @@ #include "log.h" #define VOC_MAX 0x6fc00c /* taken from sound conversion program */ +#define VOC_HEADER_LEN 26 +#define VOC_BLOCK_HEADER_LEN 16 static FILE *voc_fd = NULL; static int samples = 0; @@ -43,8 +45,8 @@ static int voc_init(const char *param, int *speed, int *fragsize, int *fragnr, int *channels) { /* VOC header. */ - unsigned char header[26] = "Creative Voice File\032\032\0\024\001\037\021"; - unsigned char block_header[16] = "\011sssrrrr\026c\004\0\0\0\0\0"; + unsigned char header[VOC_HEADER_LEN + 1] = "Creative Voice File\032\032\0\024\001\037\021"; + unsigned char block_header[VOC_BLOCK_HEADER_LEN + 1] = "\011sssrrrr\026c\004\0\0\0\0\0"; uint32_t sample_rate = (uint32_t)*speed; voc_fd = fopen(param ? param : "vicesnd.voc", MODE_WRITE); @@ -55,7 +57,7 @@ samples = 0; extra_block = 0; - if (fwrite(header, 1, 26, voc_fd) != 26) { + if (fwrite(header, 1, VOC_HEADER_LEN, voc_fd) != VOC_HEADER_LEN) { fclose(voc_fd); return 1; } @@ -69,7 +71,7 @@ block_header[6] = (uint8_t)((sample_rate >> 16) & 0xff); block_header[7] = (uint8_t)((sample_rate >> 24) & 0xff); - return (fwrite(block_header, 1, 16, voc_fd) != 16); + return (fwrite(block_header, 1, VOC_BLOCK_HEADER_LEN, voc_fd) != VOC_BLOCK_HEADER_LEN); } static int voc_write(int16_t *pbuf, size_t nr) Modified: trunk/vice/src/ram.c =================================================================== --- trunk/vice/src/ram.c 2025-04-28 23:42:30 UTC (rev 45649) +++ trunk/vice/src/ram.c 2025-04-29 10:36:48 UTC (rev 45650) @@ -349,7 +349,7 @@ unsigned char *mem; char *p = s, *pp; int i, a; - const char hextab[16] = "0123456789abcdef"; + const char hextab[16 + 1] = "0123456789abcdef"; mem = lib_malloc(len); ram_init(mem, len); Modified: trunk/vice/src/userport/userport_wic64.c =================================================================== --- trunk/vice/src/userport/userport_wic64.c 2025-04-28 23:42:30 UTC (rev 45649) +++ trunk/vice/src/userport/userport_wic64.c 2025-04-29 10:36:48 UTC (rev 45650) @@ -1390,7 +1390,7 @@ { int enc_it = 0; int i; - static char hextab[16] = "0123456789abcdef"; + static char hextab[16 + 1] = "0123456789abcdef"; for (i = 0; i < len; i++) { encoded_helper[enc_it++] = hextab[((**p) >> 4) & 0xf]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gp...@us...> - 2025-04-28 23:42:48
|
Revision: 45649 http://sourceforge.net/p/vice-emu/code/45649 Author: gpz Date: 2025-04-28 23:42:30 +0000 (Mon, 28 Apr 2025) Log Message: ----------- cleanup and comment VIC20 cartridge stuff some more, added support for the 'Write Now' cartridge Modified Paths: -------------- trunk/vice/doc/vice.texi trunk/vice/src/cartridge.h trunk/vice/src/tools/cartconv/vic20-cartridges.c trunk/vice/src/vic20/cart/Makefile.am trunk/vice/src/vic20/cart/vic20-generic.c trunk/vice/src/vic20/cart/vic20-generic.h trunk/vice/src/vic20/cart/vic20cart.c trunk/vice/src/vic20/cart/vic20cart.h trunk/vice/src/vic20/cart/vic20cartmem.c trunk/vice/src/vic20/vic20mem.c Added Paths: ----------- trunk/vice/src/vic20/cart/writenow.c trunk/vice/src/vic20/cart/writenow.h Modified: trunk/vice/doc/vice.texi =================================================================== --- trunk/vice/doc/vice.texi 2025-04-28 16:50:35 UTC (rev 45648) +++ trunk/vice/doc/vice.texi 2025-04-28 23:42:30 UTC (rev 45649) @@ -14744,6 +14744,10 @@ @item -cartma <name> Specify Mikro Assembler cartridge ROM name +@findex -cartwn +@item -cartwn <name> +Specify Write Now cartridge ROM name + @findex -ultimem @item -ultimem <name> Specify Ultimem extension ROM name @@ -23615,6 +23619,8 @@ UltiMem @item vicfp Vic Flash Plugin +@item wn +Write Now @end table @b{PLUS4 cartridges:} @@ -34917,6 +34923,8 @@ @tab Super Expander @item 8 @tab Mikro Assembler +@item 9 +@tab Write Now @end multitable @c @node FIXME @@ -35229,6 +35237,37 @@ @c FIXME: cartridge details @c @node FIXME +@subsubsection 9 - Write Now + +@multitable @columnfractions .3 .7 +@item Size +@tab 8KiB (ROM) +@end multitable + +@example + 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F ASCII + ----------------------------------------------- ---------------- + 0000: 56 49 43 32 30 20 43 41 52 54 52 49 44 47 45 20 VIC20 CARTRIDGE + 0010: 00 00 00 40 02 00 00 09 00 00 00 00 00 00 00 00 ...@............ + 0020: 57 72 69 74 65 20 4e 6f 77 00 00 00 00 00 00 00 Write Now....... + 0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 0040: 43 48 49 50 00 00 20 10 00 00 00 00 a0 00 20 00 CHIP.. ....... . + 0050: 00 a5 2c c5 37 a5 2d e5 38 90 03 4c 22 a9 20 af ..,.7.-.8..L". . + 0060: a3 a5 3b 85 26 a5 3c 85 27 a9 01 85 48 20 80 a4 ..;.&.<.'...H .. + 0070: c8 a9 20 91 26 4c 3b a4 20 20 a7 20 3f a0 a9 f2 .. .&L;.....?... + 0080: 85 52 a9 10 85 53 20 ac a0 20 63 a1 4c 2b a0 a9 .R...S .. c.L+.. + 0090: 10 85 71 a5 2a 85 26 a5 2b 85 27 38 a5 2c e9 01 ..q.*.&.+.'8.,.. + +@dots{} + 2030: bd ed bf a2 00 81 28 e6 28 d0 02 e6 29 60 a0 20 ......(.(...)`.. + 2040: df 69 e9 5f 27 0b 43 48 45 4b 2e 49 54 82 43 4d .i._'.CHEK.IT.CM +@end example + +This cartridge maps 8KiB ROM into block5 ($a000-$afff), plus the last 2KiB of the ROM are mapped into IO ($9800-$9Bff) + +@c FIXME: cartridge details + +@c @node FIXME @subsection PLUS4 Cartridge Specifics @multitable @columnfractions .1 .9 Modified: trunk/vice/src/cartridge.h =================================================================== --- trunk/vice/src/cartridge.h 2025-04-28 16:50:35 UTC (rev 45648) +++ trunk/vice/src/cartridge.h 2025-04-28 23:42:30 UTC (rev 45649) @@ -478,8 +478,9 @@ #define CARTRIDGE_VIC20_RABBIT 6 /* rabbit.c */ #define CARTRIDGE_VIC20_SUPEREXPANDER 7 /* superexpander.c */ #define CARTRIDGE_VIC20_MIKRO_ASSEMBLER 8 /* mikroassembler.c */ +#define CARTRIDGE_VIC20_WRITE_NOW 9 /* writenow.c */ -#define CARTRIDGE_VIC20_LAST 8 /* cartconv: last cartridge in list */ +#define CARTRIDGE_VIC20_LAST 9 /* cartconv: last cartridge in list */ /* * VIC20 Generic cartridges @@ -548,6 +549,7 @@ #define CARTRIDGE_VIC20_NAME_RABBIT "Rabbit Tape" #define CARTRIDGE_VIC20_NAME_SUPEREXPANDER "Super Expander" #define CARTRIDGE_VIC20_NAME_MIKRO_ASSEMBLER "Mikro Assembler" +#define CARTRIDGE_VIC20_NAME_WRITE_NOW "Write Now" /* * plus4 cartridge system Modified: trunk/vice/src/tools/cartconv/vic20-cartridges.c =================================================================== --- trunk/vice/src/tools/cartconv/vic20-cartridges.c 2025-04-28 16:50:35 UTC (rev 45648) +++ trunk/vice/src/tools/cartconv/vic20-cartridges.c 2025-04-28 23:42:30 UTC (rev 45649) @@ -31,6 +31,7 @@ {0, 0, CARTRIDGE_SIZE_4KB, 0x1000, 0xa000, 1, CRT_CHIP_ROM, CARTRIDGE_VIC20_NAME_SUPEREXPANDER, "se", save_regular_crt}, /* FIXME: second bank should go to a000 */ {0, 0, CARTRIDGE_SIZE_8KB, 0x1000, 0x6000, 2, CRT_CHIP_ROM, CARTRIDGE_VIC20_NAME_MIKRO_ASSEMBLER, "ma", save_regular_crt}, + {0, 0, CARTRIDGE_SIZE_8KB, 0x2000, 0xA000, 1, CRT_CHIP_ROM, CARTRIDGE_VIC20_NAME_WRITE_NOW, "wn", save_regular_crt}, {0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL} }; Modified: trunk/vice/src/vic20/cart/Makefile.am =================================================================== --- trunk/vice/src/vic20/cart/Makefile.am 2025-04-28 16:50:35 UTC (rev 45648) +++ trunk/vice/src/vic20/cart/Makefile.am 2025-04-28 23:42:30 UTC (rev 45649) @@ -49,7 +49,9 @@ vic20cart.c \ vic20cart.h \ vic20cartmem.c \ - vic20cartmem.h + vic20cartmem.h \ + writenow.c \ + writenow.h libmascuerade_a_SOURCES = \ mascuerade-stubs.h \ Modified: trunk/vice/src/vic20/cart/vic20-generic.c =================================================================== --- trunk/vice/src/vic20/cart/vic20-generic.c 2025-04-28 16:50:35 UTC (rev 45648) +++ trunk/vice/src/vic20/cart/vic20-generic.c 2025-04-28 23:42:30 UTC (rev 45649) @@ -53,17 +53,11 @@ #include "zfile.h" #ifdef DEBUGCART -#define DBG(x) printf x +#define DBG(x) log_printf x #else #define DBG(x) #endif -#define TRY_RESOURCE_CARTFILE2 (1 << 8) -#define TRY_RESOURCE_CARTFILE4 (1 << 9) -#define TRY_RESOURCE_CARTFILE6 (1 << 10) -#define TRY_RESOURCE_CARTFILEA (1 << 11) -#define TRY_RESOURCE_CARTFILEB (1 << 12) - /* ------------------------------------------------------------------------- */ /* actual resources */ @@ -125,9 +119,12 @@ #define CART_ROM_SIZE 0x9000 static uint8_t *cart_rom = NULL; -/* Cartridge States */ -int generic_ram_blocks = 0; -int generic_rom_blocks = 0; +/* Flags that indicate which blocks of memory are used by RAM or ROM from the + generic cartridge. These will be combined and form the value that goes to + mem_cart_blocks, which will in turn be used by mem_initialize_memory() to + remap the memory accesses. */ +static int generic_ram_blocks = 0; +static int generic_rom_blocks = 0; static export_resource_t export_res = { CARTRIDGE_VIC20_NAME_GENERIC, 0, 0, NULL, NULL, CARTRIDGE_VIC20_GENERIC @@ -212,14 +209,6 @@ /* ------------------------------------------------------------------------- */ -void generic_init(void) -{ -} - -void generic_reset(void) -{ -} - void generic_config_setup(uint8_t *rawcart) { } @@ -240,7 +229,7 @@ long len; size_t n; - DBG(("attach_image type %d (%04x), file=`%s'.\n", type, (unsigned int)type, filename)); + DBG(("attach_image type %d (%04x), file=`%s'.", type, (unsigned int)type, filename)); fd = zfile_fopen(filename, MODE_READ); if (!fd) { @@ -263,7 +252,7 @@ break; default: /* not a valid file */ zfile_fclose(fd); - DBG(("attach_image error (length check), len=%ld.\n", len)); + DBG(("attach_image error (length check), len=%ld.", len)); return -1; break; } @@ -331,10 +320,10 @@ log_message(LOG_DEFAULT, "could not determine type of cartridge, defaulting to 2KiB $b000-$b7ff"); } } else { - DBG(("attach_image error (autodetect), len=%ld.\n", len)); + DBG(("attach_image error (autodetect), len=%ld.", len)); return -1; } - DBG(("detected cartridge type: %04x addr: %04x len: %04lx\n", (unsigned int)type, addr, (long unsigned int)len)); + DBG(("detected cartridge type: %04x addr: %04x len: %04lx", (unsigned int)type, addr, (long unsigned int)len)); } memset(rawcart, 0xff, 0x8000); /* init all blocks with 0xff */ @@ -348,7 +337,7 @@ } zfile_fclose(fd); - DBG(("loaded %ld 1KiB chunks, preparing type %d (%04x)\n", (long int)n, type, (unsigned int)type)); + DBG(("loaded %ld 1KiB chunks, preparing type %d (%04x)", (long int)n, type, (unsigned int)type)); /* depending on the detected type, set the respective filename string */ switch (type) { @@ -395,7 +384,7 @@ } break; default: - DBG(("attach_image error (string set), len=%ld.\n", len)); + DBG(("attach_image error (string set), len=%ld.", len)); return -1; break; } @@ -496,12 +485,12 @@ break; default: - DBG(("attach_image error (creating mirrors), len=%ld.\n", len)); + DBG(("attach_image error (creating mirrors), len=%ld.", len)); return -1; break; } - DBG(("attaching type %d (%04x)\n", type, (unsigned int)type)); + DBG(("attaching type %d (%04x)", type, (unsigned int)type)); /* attach cartridge data */ switch (type) { @@ -591,7 +580,7 @@ VIC_CART_BLK3 | VIC_CART_BLK5); break; default: - DBG(("attach_image error (image attach), len=%ld.\n", len)); + DBG(("attach_image error (image attach), len=%ld.", len)); return -1; break; } @@ -622,7 +611,7 @@ cart_rom = lib_malloc(CART_ROM_SIZE); } - DBG(("generic_bin_attach type %d, file=`%s'.\n", type, filename)); + DBG(("generic_bin_attach type %d, file=`%s'.", type, filename)); if (type == CARTRIDGE_VIC20_GENERIC) { /* @@ -638,6 +627,7 @@ return -1; } + /* update memory mapping to use the blocks of the generic cartridge(s) */ mem_cart_blocks = generic_ram_blocks | generic_rom_blocks; mem_initialize_memory(); return 0; @@ -659,7 +649,7 @@ cart_rom = lib_malloc(CART_ROM_SIZE); } - DBG(("generic_crt_attach\n")); + DBG(("generic_crt_attach")); do { @@ -669,6 +659,7 @@ if (export_add(&export_res) < 0) { goto exiterror; } + /* update memory mapping to use the blocks of the generic cartridge(s) */ mem_cart_blocks = generic_ram_blocks | generic_rom_blocks; mem_initialize_memory(); return CARTRIDGE_VIC20_GENERIC; @@ -676,7 +667,7 @@ goto exiterror; } - DBG(("chip %d at %02x len %02x\n", idx, chip.start, chip.size)); + DBG(("chip %d at %02x len %02x", idx, chip.start, chip.size)); if ((chip.start >= 0x2000) && (chip.start <= 0x3fff)) { /* block 1 */ generic_rom_blocks |= VIC_CART_BLK1; offset = chip.start; @@ -702,7 +693,7 @@ } while (idx < 8); /* FIXME */ exiterror: - DBG(("generic_crt_attach: error\n")); + DBG(("generic_crt_attach: error")); generic_detach(); return -1; } @@ -711,8 +702,11 @@ { generic_ram_blocks = 0; generic_rom_blocks = 0; + + /* reset memory map to all "no cartridge" */ mem_cart_blocks = 0; mem_initialize_memory(); + lib_free(cart_ram); lib_free(cart_rom); cart_ram = NULL; @@ -905,6 +899,7 @@ snapshot_module_close(m); + /* update memory mapping to use only the saved blocks */ mem_cart_blocks = generic_ram_blocks | generic_rom_blocks; mem_initialize_memory(); Modified: trunk/vice/src/vic20/cart/vic20-generic.h =================================================================== --- trunk/vice/src/vic20/cart/vic20-generic.h 2025-04-28 16:50:35 UTC (rev 45648) +++ trunk/vice/src/vic20/cart/vic20-generic.h 2025-04-28 23:42:30 UTC (rev 45649) @@ -42,14 +42,6 @@ uint8_t generic_blk5_read(uint16_t addr); void generic_blk5_store(uint16_t addr, uint8_t value); -/* uint8_t generic_io2_read(uint16_t addr); */ -/* void generic_io2_store(uint16_t addr, uint8_t value); */ -/* uint8_t generic_io3_read(uint16_t addr); */ -/* void generic_io3_store(uint16_t addr, uint8_t value); */ - -void generic_init(void); -void generic_reset(void); - void generic_config_setup(uint8_t *rawcart); int generic_bin_attach(int type, const char *filename); Modified: trunk/vice/src/vic20/cart/vic20cart.c =================================================================== --- trunk/vice/src/vic20/cart/vic20cart.c 2025-04-28 16:50:35 UTC (rev 45648) +++ trunk/vice/src/vic20/cart/vic20cart.c 2025-04-28 23:42:30 UTC (rev 45649) @@ -86,9 +86,10 @@ #include "sidcart.h" #include "ultimem.h" #include "vic-fp.h" +#include "writenow.h" #ifdef DEBUGCART -#define DBG(x) printf x +#define DBG(x) log_printf x #else #define DBG(x) #endif @@ -98,16 +99,14 @@ int cartridge_is_from_snapshot = 0; /* actual resources */ -static char *cartridge_file = NULL; -static int cartridge_type; -static int vic20cartridge_reset; +static char *cartridge_file = NULL; /* filename of the default cartridge */ +static int cartridge_type; /* type of the default cartridge */ +static int vic20cartridge_reset; /* if 1, reset VIC20 on cartridge change */ /* local shadow of some resources (e.g not yet set as default) */ static int vic20cart_type = CARTRIDGE_NONE; static char *cartfile = NULL; -static int cartres_flags = 0; - static int cartridge_attach_from_resource(int type, const char *filename); static cartridge_info_t cartlist[] = { @@ -130,6 +129,7 @@ { CARTRIDGE_VIC20_NAME_RABBIT, CARTRIDGE_VIC20_RABBIT, CARTRIDGE_GROUP_UTIL }, { CARTRIDGE_VIC20_NAME_SUPEREXPANDER, CARTRIDGE_VIC20_SUPEREXPANDER, CARTRIDGE_GROUP_UTIL }, { CARTRIDGE_VIC20_NAME_UM, CARTRIDGE_VIC20_UM, CARTRIDGE_GROUP_UTIL }, + { CARTRIDGE_VIC20_NAME_WRITE_NOW, CARTRIDGE_VIC20_WRITE_NOW, CARTRIDGE_GROUP_UTIL }, { NULL, 0, 0 } }; @@ -139,29 +139,19 @@ return &cartlist[0]; } -void reset_try_flags(void) -{ - cartres_flags = 0; -} - +/* this function coordinates the handling of the different resources that are + used for the cartridges, in particular the generic cartridge, and the + separate resources that exist for cartridges in each block */ int try_cartridge_attach(int c) { -/* FIXME: whatever this was trying to do, it doesnt work. eg having a default - (generic) cartridge in vicerc doesnt work when this logic is active. -*/ -/* - cartres_flags ^= c; - if (cartres_flags) { - return 0; - } -*/ - DBG(("try_cartridge_attach '%d'\n", c)); + DBG(("try_cartridge_attach '%d'", c)); return cartridge_attach_from_resource(vic20cart_type, cartfile); } +/* sets the "default cartridge type" resource */ static int set_cartridge_type(int val, void *param) { - DBG(("set_cartridge_type '%d'\n", val)); + DBG(("set_cartridge_type '%d'", val)); switch (val) { case CARTRIDGE_NONE: case CARTRIDGE_VIC20_GENERIC: @@ -174,6 +164,7 @@ case CARTRIDGE_VIC20_FP: case CARTRIDGE_VIC20_IEEE488: case CARTRIDGE_VIC20_SIDCART: + case CARTRIDGE_VIC20_WRITE_NOW: case CARTRIDGE_VIC20_DETECT: case CARTRIDGE_VIC20_4KB_2000: @@ -353,6 +344,9 @@ { "-cartma", CALL_FUNCTION, CMDLINE_ATTRIB_NEED_ARGS, attach_cartridge_cmdline, (void *)CARTRIDGE_VIC20_MIKRO_ASSEMBLER, NULL, NULL, "<Name>", "Specify " CARTRIDGE_VIC20_NAME_MIKRO_ASSEMBLER " cartridge ROM name" }, + { "-cartwn", CALL_FUNCTION, CMDLINE_ATTRIB_NEED_ARGS, + attach_cartridge_cmdline, (void *)CARTRIDGE_VIC20_WRITE_NOW, NULL, NULL, + "<Name>", "Specify " CARTRIDGE_VIC20_NAME_WRITE_NOW " cartridge ROM name" }, { "+cart", CALL_FUNCTION, CMDLINE_ATTRIB_NONE, detach_cartridge_cmdline, NULL, NULL, NULL, @@ -388,9 +382,11 @@ } /* ------------------------------------------------------------------------- */ + +// FIXME: type is passed, but vic20cart_type used instead? static int cartridge_attach_from_resource(int type, const char *filename) { - DBG(("cartridge_attach_from_resource type: %d name: '%s'\n", type, filename)); + DBG(("cartridge_attach_from_resource type: %d name: '%s'", type, filename)); if (vic20cart_type == CARTRIDGE_VIC20_GENERIC) { /* special case handling for the multiple file generic type */ return generic_attach_from_resource(vic20cart_type, cartfile); @@ -410,7 +406,7 @@ int ret, new_crttype; FILE *fd; - DBG(("crt_attach: %s\n", filename)); + DBG(("crt_attach: %s", filename)); fd = crt_open(filename, &header); @@ -423,7 +419,7 @@ /* handle our negative test IDs */ new_crttype -= 0x10000; } - DBG(("crt_attach ID: %d\n", new_crttype)); + DBG(("crt_attach ID: %d", new_crttype)); /* cart should always be detached. there is no reason for doing fancy checks here, and it will cause problems incase a cart MUST be detached before @@ -466,8 +462,11 @@ case CARTRIDGE_VIC20_UM: ret = vic_um_crt_attach(fd, rawcart, filename); break; + case CARTRIDGE_VIC20_WRITE_NOW: + ret = writenow_crt_attach(fd, rawcart); + break; default: - archdep_startup_log_error("unknown CRT ID: %d\n", new_crttype); + archdep_startup_log_error("unknown CRT ID: %d", new_crttype); ret = -1; break; } @@ -475,10 +474,10 @@ fclose(fd); if (ret == -1) { - DBG(("crt_attach error (%d)\n", ret)); + DBG(("crt_attach error (%d)", ret)); return -1; } - DBG(("crt_attach return ID: %d\n", new_crttype)); + DBG(("crt_attach return ID: %d", new_crttype)); return new_crttype; } @@ -528,8 +527,11 @@ case CARTRIDGE_VIC20_UM: ret = vic_um_bin_attach(filename); break; + case CARTRIDGE_VIC20_WRITE_NOW: + ret = writenow_bin_attach(filename); + break; } - DBG(("cart_bin_attach type: %d ret: %d\n", type, ret)); + DBG(("cart_bin_attach type: %d ret: %d", type, ret)); return ret; } @@ -549,7 +551,7 @@ int carttype = CARTRIDGE_NONE; int cartid = CARTRIDGE_NONE; - DBG(("cartridge_attach_image type '%d'(0x%04x) name: '%s'\n", type, type, filename)); + DBG(("cartridge_attach_image type '%d'(0x%04x) name: '%s'", type, (unsigned)type, filename)); /* if (filename == NULL) { return -1; @@ -580,7 +582,7 @@ /* allocate temporary array */ rawcart = lib_malloc(VIC20CART_IMAGE_LIMIT); - DBG(("CART: cartridge_attach_image type: %d ID: %d\n", type, carttype)); + DBG(("CART: cartridge_attach_image type: %d ID: %d", type, carttype)); log_message(LOG_DEFAULT, "Attached cartridge type %d, file=`%s'.", type, filename); @@ -607,7 +609,7 @@ } if (type == CARTRIDGE_CRT) { - DBG(("CART: attach CRT ID: %d '%s'\n", carttype, filename)); + DBG(("CART: attach CRT ID: %d '%s'", carttype, filename)); cartid = crt_attach(abs_filename, rawcart); if (cartid == CARTRIDGE_NONE) { goto exiterror; @@ -614,19 +616,22 @@ } vic20cart_type = cartid; } else { - DBG(("CART: attach BIN ID: %d '%s'\n", carttype, filename)); + DBG(("CART: attach BIN ID: %d '%s'", carttype, filename)); if (cart_bin_attach(carttype, abs_filename, rawcart) < 0) { goto exiterror; } + if (vic20cart_type != CARTRIDGE_VIC20_GENERIC) { + vic20cart_type = carttype; + } } - DBG(("CART: attach RAW ID: %d carttype: %d vic20cart_type:%d\n", + DBG(("CART: attach RAW ID: %d carttype: %d vic20cart_type:%d", cartid, carttype, vic20cart_type)); util_string_set(&cartfile, filename); cartridge_attach(vic20cart_type, NULL); - DBG(("CART: cartridge_attach_image type: %d ID: %d done.\n", type, carttype)); + DBG(("CART: cartridge_attach_image type: %d ID: %d done.", type, carttype)); lib_free(rawcart); log_message(LOG_DEFAULT, "CART: attached '%s' as ID %d.", abs_filename, carttype); lib_free(abs_filename); @@ -633,7 +638,7 @@ return 0; exiterror: - DBG(("CART: error\n")); + DBG(("CART: error")); lib_free(rawcart); log_message(LOG_DEFAULT, "CART: could not attach '%s'.", abs_filename); lib_free(abs_filename); @@ -655,7 +660,7 @@ int carttype = CARTRIDGE_NONE; int cartid = CARTRIDGE_NONE; - DBG(("cartridge_attach_add_image type '%d'(0x%04x) name: '%s'\n", type, type, filename)); + DBG(("cartridge_attach_add_image type '%d'(0x%04x) name: '%s'", type, (unsigned)type, filename)); /* if (filename == NULL) { return -1; @@ -686,12 +691,12 @@ /* allocate temporary array */ rawcart = lib_malloc(VIC20CART_IMAGE_LIMIT); - DBG(("CART: cartridge_attach_add_image type: %d ID: %d\n", type, carttype)); + DBG(("CART: cartridge_attach_add_image type: %d ID: %d", type, carttype)); log_message(LOG_DEFAULT, "Attached cartridge type %d, file=`%s'.", type, filename); if (type == CARTRIDGE_CRT) { - DBG(("CART: attach CRT ID: %d '%s'\n", carttype, filename)); + DBG(("CART: attach CRT ID: %d '%s'", carttype, filename)); cartid = crt_attach(abs_filename, rawcart); if (cartid == CARTRIDGE_NONE) { goto exiterror; @@ -698,13 +703,13 @@ } carttype = cartid; } else { - DBG(("CART: attach BIN ID: %d '%s'\n", carttype, filename)); + DBG(("CART: attach BIN ID: %d '%s'", carttype, filename)); if (cart_bin_attach(carttype, abs_filename, rawcart) < 0) { goto exiterror; } } - DBG(("CART: attach RAW ID: %d carttype: %d vic20cart_type:%d\n", + DBG(("CART: attach RAW ID: %d carttype: %d vic20cart_type:%d", cartid, carttype, vic20cart_type)); /* NOTE: when we use more than one .bin file, we cant set it as default cartridge */ @@ -711,7 +716,7 @@ util_string_set(&cartfile, NULL); cartridge_attach(vic20cart_type, NULL); - DBG(("CART: cartridge_attach_add_image type: %d ID: %d done.\n", type, carttype)); + DBG(("CART: cartridge_attach_add_image type: %d ID: %d done.", type, carttype)); lib_free(rawcart); log_message(LOG_DEFAULT, "CART: attached '%s' as ID %d.", abs_filename, carttype); lib_free(abs_filename); @@ -718,7 +723,7 @@ return 0; exiterror: - DBG(("CART: error\n")); + DBG(("CART: error")); lib_free(rawcart); log_message(LOG_DEFAULT, "CART: could not attach '%s'.", abs_filename); lib_free(abs_filename); @@ -737,7 +742,7 @@ */ int cartridge_enable(int type) { - DBG(("CART: enable type: %d\n", type)); + DBG(("CART: enable type: %d", type)); switch (type) { case CARTRIDGE_DIGIMAX: digimax_enable(); @@ -760,7 +765,7 @@ break; #endif default: - DBG(("CART: no enable hook %d\n", type)); + DBG(("CART: no enable hook %d", type)); break; } @@ -790,7 +795,7 @@ fprintf(stderr, "%s:%d: %s() isn't implemented yet, continuing\n", __FILE__, __LINE__, __func__); */ - DBG(("CART: enable type: %d\n", type)); + DBG(("CART: enable type: %d", type)); switch (type) { case CARTRIDGE_DIGIMAX: digimax_disable(); @@ -813,7 +818,7 @@ break; #endif default: - DBG(("CART: no disable hook %d\n", type)); + DBG(("CART: no disable hook %d", type)); break; } @@ -823,12 +828,13 @@ if (!cart_type_enabled(type)) { return 0; } - log_error(LOG_DEFAULT, "Failed to disable cartridge with ID %d.\n", type); + log_error(LOG_DEFAULT, "Failed to disable cartridge with ID %d.", type); return -1; #endif return 0; } +/* set the currently attached cartridge(s) as default */ void cartridge_set_default(void) { if (cartridge_is_from_snapshot) { @@ -838,11 +844,9 @@ } set_cartridge_type(vic20cart_type, NULL); set_cartridge_file((vic20cart_type == CARTRIDGE_NONE) ? "" : cartfile, NULL); - /* special case handling for the multiple file generic type */ + + /* clear the filenames of the separate files for the generic cartridge */ generic_set_default(); - - /* reset the try flags (we've only called the set function once each) */ - reset_try_flags(); } /** \brief Wipe "default cartidge" @@ -850,7 +854,7 @@ void cartridge_unset_default(void) { util_string_set(&cartridge_file, ""); - /* special case handling for the multiple file generic type */ + /* clear the filenames of the separate files for the generic cartridge */ generic_unset_default(); cartridge_type = CARTRIDGE_NONE; } @@ -1025,7 +1029,7 @@ int cartridge_get_id(int slot) { int type = vic20cart_type; - DBG(("cartridge_get_id(slot:%d): %d %d type:%d\n", slot, cartridge_type, vic20cart_type, type)); + DBG(("cartridge_get_id(slot:%d): %d %d type:%d", slot, cartridge_type, vic20cart_type, type)); return type; } @@ -1078,7 +1082,7 @@ while (e != NULL) { if (number_of_carts == VIC20CART_DUMP_MAX_CARTS) { - DBG(("CART snapshot save: active carts > max (%i)\n", number_of_carts)); + DBG(("CART snapshot save: active carts > max (%i)", number_of_carts)); return -1; } if (last_cart != (int)e->device->cartid) { @@ -1158,6 +1162,11 @@ return -1; } break; + case CARTRIDGE_VIC20_WRITE_NOW: + if (writenow_snapshot_write_module(s) < 0) { + return -1; + } + break; case CARTRIDGE_VIC20_IO2_RAM: if (ioramcart_io2_snapshot_write_module(s) < 0) { @@ -1277,7 +1286,7 @@ } if (number_of_carts > VIC20CART_DUMP_MAX_CARTS) { - DBG(("CART snapshot read: carts %i > max %i\n", number_of_carts, VIC20CART_DUMP_MAX_CARTS)); + DBG(("CART snapshot read: carts %i > max %i", number_of_carts, VIC20CART_DUMP_MAX_CARTS)); goto fail; } @@ -1346,6 +1355,11 @@ return -1; } break; + case CARTRIDGE_VIC20_WRITE_NOW: + if (writenow_snapshot_read_module(s) < 0) { + return -1; + } + break; case CARTRIDGE_VIC20_IO2_RAM: if (ioramcart_io2_snapshot_read_module(s) < 0) { Modified: trunk/vice/src/vic20/cart/vic20cart.h =================================================================== --- trunk/vice/src/vic20/cart/vic20cart.h 2025-04-28 16:50:35 UTC (rev 45648) +++ trunk/vice/src/vic20/cart/vic20cart.h 2025-04-28 23:42:30 UTC (rev 45649) @@ -29,12 +29,18 @@ #include "types.h" -void reset_try_flags(void); +#define TRY_RESOURCE_CARTTYPE (1 << 0) +#define TRY_RESOURCE_CARTNAME (1 << 1) +#define TRY_RESOURCE_CARTRESET (1 << 2) + +#define TRY_RESOURCE_CARTFILE2 (1 << 8) +#define TRY_RESOURCE_CARTFILE4 (1 << 9) +#define TRY_RESOURCE_CARTFILE6 (1 << 10) +#define TRY_RESOURCE_CARTFILEA (1 << 11) +#define TRY_RESOURCE_CARTFILEB (1 << 12) + int try_cartridge_attach(int c); -#define TRY_RESOURCE_CARTTYPE (1 << 0) -#define TRY_RESOURCE_CARTNAME (1 << 1) -#define TRY_RESOURCE_CARTRESET (1 << 2) /* Cartridge ROM limit = 1MB */ #define VIC20CART_ROM_LIMIT (1024 * 1024) Modified: trunk/vice/src/vic20/cart/vic20cartmem.c =================================================================== --- trunk/vice/src/vic20/cart/vic20cartmem.c 2025-04-28 16:50:35 UTC (rev 45648) +++ trunk/vice/src/vic20/cart/vic20cartmem.c 2025-04-28 23:42:30 UTC (rev 45649) @@ -24,7 +24,7 @@ * */ -#define DEBUGCART +/* #define DEBUGCART */ #include "vice.h" @@ -34,6 +34,7 @@ #include "machine.h" #include "mem.h" #include "resources.h" +#include "log.h" #ifdef HAVE_RAWNET #define CARTRIDGE_INCLUDE_PRIVATE_API #define CARTRIDGE_INCLUDE_PUBLIC_API @@ -65,9 +66,10 @@ #include "sidcart.h" #include "superexpander.h" #include "ultimem.h" +#include "writenow.h" #ifdef DEBUGCART -#define DBG(x) printf x +#define DBG(x) log_printf x #else #define DBG(x) #endif @@ -364,8 +366,10 @@ } } +/* A000-BFFF */ uint8_t cartridge_read_blk5(uint16_t addr) { + DBG(("cartridge_read_blk5 (%d) 0x%04x", mem_cartridge_type, addr)); switch (mem_cartridge_type) { case CARTRIDGE_VIC20_BEHRBONZ: vic20_cpu_last_data = behrbonz_blk25_read(addr); @@ -391,10 +395,14 @@ case CARTRIDGE_VIC20_SUPEREXPANDER: vic20_cpu_last_data = superexpander_blk5_read(addr); break; + case CARTRIDGE_VIC20_WRITE_NOW: + vic20_cpu_last_data = writenow_blk5_read(addr); + break; } return vic20_cpu_last_data; } +/* A000-BFFF */ uint8_t cartridge_peek_blk5(uint16_t addr) { switch (mem_cartridge_type) { @@ -412,10 +420,13 @@ return megacart_blk5_read(addr); case CARTRIDGE_VIC20_SUPEREXPANDER: return superexpander_blk5_read(addr); + case CARTRIDGE_VIC20_WRITE_NOW: + return writenow_blk5_read(addr); } return 0; } +/* A000-BFFF */ void cartridge_store_blk5(uint16_t addr, uint8_t value) { vic20_cpu_last_data = value; @@ -442,7 +453,6 @@ void cartridge_init(void) { - generic_init(); behrbonz_init(); finalexpansion_init(); megacart_init(); @@ -461,9 +471,6 @@ case CARTRIDGE_VIC20_BEHRBONZ: behrbonz_reset(); break; - case CARTRIDGE_VIC20_GENERIC: - generic_reset(); - break; case CARTRIDGE_VIC20_UM: vic_um_reset(); break; @@ -526,7 +533,7 @@ mem_cartridge_type = type; - DBG(("cartridge_attach type: %d\n", type)); + DBG(("cartridge_attach type: %d", type)); #if 0 switch (type) { case CARTRIDGE_VIC20_GENERIC: @@ -568,6 +575,8 @@ rabbit_detach(); megacart_detach(); vic_um_detach(); + writenow_detach(); + vic20_ieee488_detach(); #ifdef HAVE_MIDI vic20_midi_detach(); @@ -616,6 +625,9 @@ case CARTRIDGE_VIC20_RABBIT: rabbit_detach(); break; + case CARTRIDGE_VIC20_WRITE_NOW: + writenow_detach(); + break; } mem_cartridge_type = CARTRIDGE_NONE; /* this is probably redundant as it is also performed by the Added: trunk/vice/src/vic20/cart/writenow.c =================================================================== --- trunk/vice/src/vic20/cart/writenow.c (rev 0) +++ trunk/vice/src/vic20/cart/writenow.c 2025-04-28 23:42:30 UTC (rev 45649) @@ -0,0 +1,285 @@ +/* + * writenow.c -- VIC20 "Write NOW" Cartridge emulation. + * + * Written by + * 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 <stdlib.h> +#include <string.h> + +#include "archdep.h" +#include "writenow.h" +#include "cartio.h" +#include "cartridge.h" +#include "crt.h" +#include "export.h" +#include "lib.h" +#include "log.h" +#include "machine.h" +#include "mem.h" +#include "monitor.h" +#include "resources.h" +#include "snapshot.h" +#include "types.h" +#include "util.h" +#include "vic20cart.h" +#include "vic20cartmem.h" +#include "vic20mem.h" +#include "zfile.h" + +/* #define DEBUGWRITENOW */ + +#ifdef DEBUGWRITENOW +#define DBG(x) log_printf x +#else +#define DBG(x) +#endif + +/* + + "Write Now" + + - 8KiB ROM mapped to A000-BFFF + + - additionally the last 2KiB of the ROM are mapped to IO at 9800-9BFF + + start with SYS41000 +*/ + +/* ------------------------------------------------------------------------- */ + + +#define CART_ROM_SIZE (0x400 * 8) +static uint8_t *cart_rom = NULL; + +/* ------------------------------------------------------------------------- */ + +/* Some prototypes are needed */ +static uint8_t writenow_io2_read(uint16_t addr); +static int writenow_mon_dump(void); + +static io_source_t writenow_io2_device = { + CARTRIDGE_VIC20_NAME_WRITE_NOW, /* 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 */ + 0x9800, 0x9bff, 0x3ff, /* range for the device */ + 1, /* read is always valid */ + NULL, /* store function */ + NULL, /* NO poke function */ + writenow_io2_read, /* read function */ + NULL, /* NO peek function */ + writenow_mon_dump, /* device state information dump function */ + CARTRIDGE_VIC20_WRITE_NOW, /* cartridge ID */ + IO_PRIO_NORMAL, /* 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 io_source_list_t *writenow_io2_list_item = NULL; + +static const export_resource_t export_res23 = { + CARTRIDGE_VIC20_NAME_WRITE_NOW, 0, VIC_CART_BLK5, &writenow_io2_device, NULL, CARTRIDGE_VIC20_WRITE_NOW +}; + +/* ------------------------------------------------------------------------- */ + +static uint8_t writenow_io2_read(uint16_t addr) +{ + /* DBG(("writenow_io2_read 0x%04x", addr)); */ + return cart_rom[0x1800 + (addr & 0x3ff)]; +} + +/* read 0xa000-0xbfff */ +uint8_t writenow_blk5_read(uint16_t addr) +{ + /* DBG(("writenow_blk5_read 0x%04x", addr)); */ + return cart_rom[addr & 0x1fff]; +} + +/* ------------------------------------------------------------------------- */ + +static int zfile_load(const char *filename, uint8_t *dest, size_t size) +{ + FILE *fd; + off_t len; + + fd = zfile_fopen(filename, MODE_READ); + if (!fd) { + return -1; + } + len = archdep_file_size(fd); + if (len < 0 || (size_t)len != size) { + zfile_fclose(fd); + return -1; + } + if (fread(dest, size, 1, fd) < 1) { + zfile_fclose(fd); + return -1; + } + zfile_fclose(fd); + return 0; +} + +int writenow_crt_attach(FILE *fd, uint8_t *rawcart) +{ + crt_chip_header_t chip; + + if (!cart_rom) { + cart_rom = lib_malloc(CART_ROM_SIZE); + } + + if (crt_read_chip_header(&chip, fd)) { + goto exiterror; + } + + DBG(("chip at %02x len %02x\n", chip.start, chip.size)); + if (chip.size != CART_ROM_SIZE) { + goto exiterror; + } + + if (crt_read_chip(&cart_rom[0], 0, &chip, fd)) { + goto exiterror; + } + + if (export_add(&export_res23) < 0) { + goto exiterror; + } + + mem_cart_blocks = VIC_CART_IO2 | VIC_CART_BLK5; + mem_initialize_memory(); + + writenow_io2_list_item = io_source_register(&writenow_io2_device); + + return CARTRIDGE_VIC20_WRITE_NOW; + +exiterror: + writenow_detach(); + return -1; +} + +int writenow_bin_attach(const char *filename) +{ + if (!cart_rom) { + cart_rom = lib_malloc(CART_ROM_SIZE); + } + + if (zfile_load(filename, cart_rom, (size_t)CART_ROM_SIZE) < 0) { + writenow_detach(); + return -1; + } + + if (export_add(&export_res23) < 0) { + return -1; + } + + mem_cart_blocks = VIC_CART_IO2 | VIC_CART_BLK5; + mem_initialize_memory(); + + writenow_io2_list_item = io_source_register(&writenow_io2_device); + + return 0; +} + +void writenow_detach(void) +{ + mem_cart_blocks = 0; + mem_initialize_memory(); + lib_free(cart_rom); + cart_rom = NULL; + + export_remove(&export_res23); + if (writenow_io2_list_item != NULL) { + io_source_unregister(writenow_io2_list_item); + writenow_io2_list_item = NULL; + } +} + +/* ------------------------------------------------------------------------- */ + +#define VIC20CART_DUMP_VER_MAJOR 0 +#define VIC20CART_DUMP_VER_MINOR 1 +#define SNAP_MODULE_NAME "WRITENOW" + +int writenow_snapshot_write_module(snapshot_t *s) +{ + snapshot_module_t *m; + + m = snapshot_module_create(s, SNAP_MODULE_NAME, VIC20CART_DUMP_VER_MAJOR, VIC20CART_DUMP_VER_MINOR); + if (m == NULL) { + return -1; + } + + if (0 + || (SMW_BA(m, cart_rom, CART_ROM_SIZE) < 0)) { + snapshot_module_close(m); + return -1; + } + + snapshot_module_close(m); + return 0; +} + +int writenow_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; + } + + if (vmajor != VIC20CART_DUMP_VER_MAJOR) { + snapshot_module_close(m); + return -1; + } + + if (!cart_rom) { + cart_rom = lib_malloc(CART_ROM_SIZE); + } + + if (0 + || (SMR_BA(m, cart_rom, CART_ROM_SIZE) < 0)) { + snapshot_module_close(m); + lib_free(cart_rom); + cart_rom = NULL; + return -1; + } + + snapshot_module_close(m); + + mem_cart_blocks = VIC_CART_IO2 | VIC_CART_BLK5; + mem_initialize_memory(); + + return 0; +} + +/* ------------------------------------------------------------------------- */ + +static int writenow_mon_dump(void) +{ + return 0; +} Added: trunk/vice/src/vic20/cart/writenow.h =================================================================== --- trunk/vice/src/vic20/cart/writenow.h (rev 0) +++ trunk/vice/src/vic20/cart/writenow.h 2025-04-28 23:42:30 UTC (rev 45649) @@ -0,0 +1,49 @@ +/* + * writenow.h -- VIC20 "Write NOW" Cartridge emulation. + * + * Written by + * 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_WRITENOW_H +#define VICE_WRITENOW_H + +#include <stdio.h> + +#include "types.h" + +void writenow_config_setup(uint8_t *rawcart); +int writenow_bin_attach(const char *filename); + +/* int writenow_bin_attach(const char *filename, uint8_t *rawcart); */ + +int writenow_crt_attach(FILE *fd, uint8_t *rawcart); +void writenow_detach(void); + +uint8_t writenow_blk5_read(uint16_t addr); + +struct snapshot_s; + +int writenow_snapshot_write_module(struct snapshot_s *s); +int writenow_snapshot_read_module(struct snapshot_s *s); + +#endif Modified: trunk/vice/src/vic20/vic20mem.c =================================================================== --- trunk/vice/src/vic20/vic20mem.c 2025-04-28 16:50:35 UTC (rev 45648) +++ trunk/vice/src/vic20/vic20mem.c 2025-04-28 23:42:30 UTC (rev 45649) @@ -61,6 +61,14 @@ #include "vic20rom.h" #include "vic20via.h" +/* #define DEBUG_VIC20MEM */ + +#ifdef DEBUG_VIC20MEM +#define DBG(x) log_printf x +#else +#define DBG(x) +#endif + /* ------------------------------------------------------------------------- */ /* The VIC20 memory. */ @@ -391,6 +399,8 @@ } } + DBG(("0400-0FFF %s", (mem_cart_blocks & VIC_CART_RAM123) ? "cartridge" : ((ram_block_0_enabled) ? "ram" : "open"))); + if (mem_cart_blocks & VIC_CART_BLK1) { /* a cartridge is selected, map everything to cart/vic20cartmem.c */ set_mem(0x20, 0x3f, @@ -405,6 +415,8 @@ } } + DBG(("2000-3FFF %s", (mem_cart_blocks & VIC_CART_BLK1) ? "cartridge" : ((ram_block_1_enabled) ? "ram" : "open"))); + if (mem_cart_blocks & VIC_CART_BLK2) { /* a cartridge is selected, map everything to cart/vic20cartmem.c */ set_mem(0x40, 0x5f, @@ -419,6 +431,8 @@ } } + DBG(("4000-5FFF %s", (mem_cart_blocks & VIC_CART_BLK2) ? "cartridge" : ((ram_block_2_enabled) ? "ram" : "open"))); + if (mem_cart_blocks & VIC_CART_BLK3) { /* a cartridge is selected, map everything to cart/vic20cartmem.c */ set_mem(0x60, 0x7f, @@ -433,6 +447,8 @@ } } + DBG(("6000-7FFF %s", (mem_cart_blocks & VIC_CART_BLK3) ? "cartridge" : ((ram_block_3_enabled) ? "ram" : "open"))); + if (mem_cart_blocks & VIC_CART_BLK5) { /* a cartridge is selected, map everything to cart/vic20cartmem.c */ set_mem(0xa0, 0xbf, @@ -447,6 +463,8 @@ } } + DBG(("A000-BFFF %s", (mem_cart_blocks & VIC_CART_BLK5) ? "cartridge" : ((ram_block_5_enabled) ? "ram" : "open"))); + /* Setup character generator ROM at $8000-$8FFF. */ set_mem(0x80, 0x8f, chargen_read, store_dummy_v_bus, chargen_peek, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |