diff --git a/targets/mega65/Makefile b/targets/mega65/Makefile index fefd179a..120c9336 100644 --- a/targets/mega65/Makefile +++ b/targets/mega65/Makefile @@ -1,6 +1,6 @@ ## A work-in-progess MEGA65 (Commodore-65 clone origins) emulator ## Part of the Xemu project, please visit: https://github.com/lgblgblgb/xemu -## Copyright (C)2016-2023 LGB (Gábor Lénárt) +## Copyright (C)2016-2024 LGB (Gábor Lénárt) # # 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 @@ -20,8 +20,8 @@ TARGET = mega65 PRG_TARGET = xmega65 EMU_DESCRIPTION = MEGA65 -SRCS_TARGET_xmega65 = configdb.c mega65.c sdcard.c uart_monitor.c hypervisor.c m65_snapshot.c memory_mapper.c io_mapper.c vic4.c vic4_palette.c ethernet65.c input_devices.c memcontent.c ui.c fat32.c sdcontent.c audio65.c inject.c dma65.c rom.c hdos.c matrix_mode.c cart.c -SRCS_COMMON_xmega65 = emutools.c cpu65.c cia6526.c emutools_hid.c sid.c f011_core.c c64_kbd_mapping.c emutools_config.c emutools_snapshot.c emutools_files.c emutools_umon.c emutools_socketapi.c ethertap.c d81access.c emutools_gui.c basic_text.c opl3.c lodepng.c compressed_disk_image.c cpu65_disasm.c +SRCS_TARGET_xmega65 = configdb.c mega65.c sdcard.c uart_monitor.c hypervisor.c memory_mapper.c io_mapper.c vic4.c vic4_palette.c ethernet65.c input_devices.c memcontent.c ui.c fat32.c sdcontent.c audio65.c inject.c dma65.c rom.c hdos.c matrix_mode.c cart.c +SRCS_COMMON_xmega65 = emutools.c cpu65.c cia6526.c emutools_hid.c sid.c f011_core.c c64_kbd_mapping.c emutools_config.c emutools_files.c emutools_umon.c emutools_socketapi.c ethertap.c d81access.c emutools_gui.c basic_text.c opl3.c lodepng.c compressed_disk_image.c cpu65_disasm.c CFLAGS_TARGET_xmega65 = $(SDL2_CFLAGS) $(MATH_CFLAGS) $(SOCKET_CFLAGS) $(XEMUGUI_CFLAGS) LDFLAGS_TARGET_xmega65 = $(SDL2_LIBS) $(MATH_LIBS) $(SOCKET_LIBS) $(XEMUGUI_LIBS) LDFLAGS_TARGET_xmega65_ON_html = -s STACK_SIZE=655360 --preload-file=$$HOME/.local/share/xemu-lgb/mega65/mega65.img.compressed3@/files/mega65.img --preload-file=$$HOME/mega65/megapoly.d81@/files/files/hdos/mega65.d81 diff --git a/targets/mega65/configdb.c b/targets/mega65/configdb.c index 31dff606..449a9e4d 100644 --- a/targets/mega65/configdb.c +++ b/targets/mega65/configdb.c @@ -57,10 +57,6 @@ static const struct xemutools_configdef_str_st str_options[] = { { "dumpmem", NULL, "Save memory content on exit", &configdb.dumpmem }, { "dumpscreen", NULL, "Save screen content (ASCII) on exit", &configdb.dumpscreen }, { "screenshot", NULL, "Save screenshot (PNG) on exit and vice-versa (for testing!)", &configdb.screenshot_and_exit }, -#ifdef XEMU_SNAPSHOT_SUPPORT - { "snapload", NULL, "Load a snapshot from the given file", &configdb.snapload }, - { "snapsave", NULL, "Save a snapshot into the given file before Xemu would exit", &configdb.snapsave }, -#endif #ifdef HAS_UARTMON_SUPPORT { "uartmon", NULL, "Sets the name for named unix-domain socket for uartmon, otherwise disabled", &configdb.uartmon }, #endif diff --git a/targets/mega65/configdb.h b/targets/mega65/configdb.h index 23738899..89cef071 100644 --- a/targets/mega65/configdb.h +++ b/targets/mega65/configdb.h @@ -54,10 +54,6 @@ struct configdb_st { char *dumpmem; char *dumpscreen; char *screenshot_and_exit; -#ifdef XEMU_SNAPSHOT_SUPPORT - char *snapload; - char *snapsave; -#endif #ifdef HAS_UARTMON_SUPPORT char *uartmon; #endif diff --git a/targets/mega65/dma65.c b/targets/mega65/dma65.c index 6788eec1..c8191dfb 100644 --- a/targets/mega65/dma65.c +++ b/targets/mega65/dma65.c @@ -665,58 +665,3 @@ void dma_set_list_addr_from_bytes ( const Uint8 *p ) list_addr = p[0] + (p[1] << 8) + (p[2] << 16) + ((p[3] & 0x0F) << 24); DEBUGDMA("DMA: list address is set 'externally' to $%X" NL, list_addr); } - -/* --- SNAPSHOT RELATED --- */ - -#ifdef XEMU_SNAPSHOT_SUPPORT - -// Note: currently state is not saved "within" a DMA operation. It's only a problem, if a DMA -// operation is not handled fully here, but implemented as an iterating update method from the -// emulator code. FIXME. - -#include - -#define SNAPSHOT_DMA_BLOCK_VERSION 2 -#define SNAPSHOT_DMA_BLOCK_SIZE 0x100 - - -int dma_snapshot_load_state ( const struct xemu_snapshot_definition_st *def, struct xemu_snapshot_block_st *block ) -{ - Uint8 buffer[SNAPSHOT_DMA_BLOCK_SIZE]; - int a; - if (block->block_version != SNAPSHOT_DMA_BLOCK_VERSION || block->sub_counter || block->sub_size != sizeof buffer) - RETURN_XSNAPERR_USER("Bad C65 block syntax"); - a = xemusnap_read_file(buffer, sizeof buffer); - if (a) return a; - /* loading state ... */ - memcpy(dma_registers, buffer, sizeof dma_registers); - dma_chip_revision = buffer[0x80]; - dma_chip_initial_revision = buffer[0x81]; - //dma_chip_revision_is_dynamic = buffer[0x82]; - modulo.enabled = buffer[0x83]; - dma_status = buffer[0x84]; - in_dma_update = buffer[0x85]; - return 0; -} - - -int dma_snapshot_save_state ( const struct xemu_snapshot_definition_st *def ) -{ - Uint8 buffer[SNAPSHOT_DMA_BLOCK_SIZE]; - int a = xemusnap_write_block_header(def->idstr, SNAPSHOT_DMA_BLOCK_VERSION); - if (a) return a; - memset(buffer, 0xFF, sizeof buffer); - /* saving state ... */ - memcpy(buffer, dma_registers, sizeof dma_registers); - buffer[0x80] = dma_chip_revision; - buffer[0x81] = dma_chip_initial_revision; - //buffer[0x82] = dma_chip_revision_is_dynamic ? 1 : 0; - buffer[0x83] = modulo.enabled ? 1 : 0; - buffer[0x84] = dma_status; // bit useless to store (see below, actually it's a problem), but to think about the future ... - buffer[0x85] = in_dma_update ? 1 : 0; // -- "" -- - if (dma_status) - WARNING_WINDOW("f018_core DMA snapshot save: snapshot with DMA pending! Snapshot WILL BE incorrect on loading! FIXME!"); // FIXME! - return xemusnap_write_sub_block(buffer, sizeof buffer); -} - -#endif diff --git a/targets/mega65/dma65.h b/targets/mega65/dma65.h index 7ff76cd8..f44d1bbb 100644 --- a/targets/mega65/dma65.h +++ b/targets/mega65/dma65.h @@ -32,10 +32,4 @@ extern int dma_get_revision ( void ); extern void dma_get_list_addr_as_bytes ( Uint8 *p ); extern void dma_set_list_addr_from_bytes ( const Uint8 *p ); -#ifdef XEMU_SNAPSHOT_SUPPORT -#include "xemu/emutools_snapshot.h" -extern int dma_snapshot_load_state ( const struct xemu_snapshot_definition_st *def, struct xemu_snapshot_block_st *block ); -extern int dma_snapshot_save_state ( const struct xemu_snapshot_definition_st *def ); -#endif - #endif diff --git a/targets/mega65/ethernet65.c b/targets/mega65/ethernet65.c index 34709206..31680780 100644 --- a/targets/mega65/ethernet65.c +++ b/targets/mega65/ethernet65.c @@ -36,7 +36,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ would result in quite slow emulation :( * FIXME: it uses thread, and it's horrible code!! there are tons of race conditions, etc ... It's not so nice work to use threads, but it would be hard to do otherwise, sadly. - * FIXME FIXME FIXME: No support for snapshotting ... * Maybe allow TUN devices to be supported. It does not handle ethernet level stuffs, no source and target MAC for example :-O But TUN devices are supported by wider range of OSes (eg: OSX) and we probably can emulate the missing ethernet level stuffs somehow in this source on RX (and chop diff --git a/targets/mega65/io_mapper.c b/targets/mega65/io_mapper.c index eec39773..2d8947a3 100644 --- a/targets/mega65/io_mapper.c +++ b/targets/mega65/io_mapper.c @@ -36,7 +36,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ int fpga_switches = 0; // State of FPGA board switches (bits 0 - 15), set switch 12 (hypervisor serial output) Uint8 D6XX_registers[0x100]; // mega65 specific D6XX range, excluding the UART part (not used here!) -Uint8 D7XX[0x100]; // FIXME: hack for future M65 stuffs like ALU! FIXME: no snapshot on these! +Uint8 D7XX[0x100]; // FIXME: hack for future M65 stuffs like ALU! struct Cia6526 cia1, cia2; // CIA emulation structures for the two CIAs int cpu_mega65_opcodes = 0; // used by the CPU emu as well! static int bigmult_valid_result = 0; diff --git a/targets/mega65/m65_snapshot.c b/targets/mega65/m65_snapshot.c deleted file mode 100644 index 6fb260cb..00000000 --- a/targets/mega65/m65_snapshot.c +++ /dev/null @@ -1,98 +0,0 @@ -/* A work-in-progess MEGA65 (Commodore 65 clone origins) emulator - Part of the Xemu project, please visit: https://github.com/lgblgblgb/xemu - Copyright (C)2016,2017,2021 LGB (Gábor Lénárt) - -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 */ - -#ifdef XEMU_SNAPSHOT_SUPPORT - -#define NEED_SID_H - -#include "xemu/emutools.h" -#include "xemu/emutools_snapshot.h" -#include "xemu/emutools_config.h" -#include "mega65.h" -#include "xemu/cpu65.h" -#include "xemu/cia6526.h" -#include "vic4.h" -#include "dma65.h" -#include "hypervisor.h" -#include "sdcard.h" -#include "xemu/f011_core.h" -#include "m65_snapshot.h" -#include "memory_mapper.h" -#include "audio65.h" -#include "io_mapper.h" -#include - -#define M65_MEMORY_BLOCK_VERSION 1 - -struct memblock_st { - Uint8 *data; - int size; -}; - - -static int snapcallback_memory_loader ( const struct xemu_snapshot_definition_st *def, struct xemu_snapshot_block_st *block ) -{ - const struct memblock_st *mem = (const struct memblock_st *)def->user_data; - if (block->block_version != M65_MEMORY_BLOCK_VERSION || block->sub_counter != 0 || block->sub_size > mem->size) - RETURN_XSNAPERR_USER("Bad memory block syntax @ %s", def->idstr); - memset(mem->data, 0xFF, mem->size); - return xemusnap_read_file(mem->data, block->sub_size); // read that damn memory dump -} - - -static int snapcallback_memory_saver ( const struct xemu_snapshot_definition_st *def ) -{ - const struct memblock_st *mem = (const struct memblock_st *)def->user_data; - int ret = xemusnap_write_block_header(def->idstr, M65_MEMORY_BLOCK_VERSION); - if (ret) return ret; - ret = mem->size - 1; - while (ret && mem->data[ret] == 0xFF) - ret--; - return xemusnap_write_sub_block(mem->data, ret + 1); -} - - -#define DEFINE_SNAPSHOT_MEMORY_BLOCK(name, structure) { "MemoryRegion:" name, (void*)&structure, snapcallback_memory_loader, snapcallback_memory_saver } - - -static const struct memblock_st memblock_main_ram = { main_ram, sizeof main_ram }; -static const struct memblock_st memblock_colour_ram = { colour_ram, sizeof colour_ram }; -static const struct memblock_st memblock_char_wom = { char_wom, sizeof char_wom }; -static const struct memblock_st memblock_hypervisor = { hypervisor_ram, 0x4000 }; - -const struct xemu_snapshot_definition_st m65_snapshot_definition[] = { - { "CPU", NULL, cpu65_snapshot_load_state, cpu65_snapshot_save_state }, - { "CIA#1", &cia1, cia_snapshot_load_state, cia_snapshot_save_state }, - { "CIA#2", &cia2, cia_snapshot_load_state, cia_snapshot_save_state }, - { "VIC-4", NULL, vic4_snapshot_load_state, vic4_snapshot_save_state }, - { "M65", NULL, m65emu_snapshot_load_state, m65emu_snapshot_save_state }, - { "SID#1", &sid[0], sid_snapshot_load_state, sid_snapshot_save_state }, - { "SID#2", &sid[1], sid_snapshot_load_state, sid_snapshot_save_state }, - { "SID#3", &sid[3], sid_snapshot_load_state, sid_snapshot_save_state }, - { "SID#4", &sid[4], sid_snapshot_load_state, sid_snapshot_save_state }, - { "DMAgic", NULL, dma_snapshot_load_state, dma_snapshot_save_state }, - { "SDcard", NULL, sdcard_snapshot_load_state, sdcard_snapshot_save_state }, - { "FDC-F011", NULL, fdc_snapshot_load_state, fdc_snapshot_save_state }, - DEFINE_SNAPSHOT_MEMORY_BLOCK("RAM:Main", memblock_main_ram), - DEFINE_SNAPSHOT_MEMORY_BLOCK("RAM:Colour", memblock_colour_ram), - DEFINE_SNAPSHOT_MEMORY_BLOCK("WOM:Char", memblock_char_wom), - DEFINE_SNAPSHOT_MEMORY_BLOCK("RAM:Hyppo", memblock_hypervisor), - { NULL, NULL, m65emu_snapshot_loading_finalize, NULL } -}; - -#endif diff --git a/targets/mega65/m65_snapshot.h b/targets/mega65/m65_snapshot.h deleted file mode 100644 index 0c5910bb..00000000 --- a/targets/mega65/m65_snapshot.h +++ /dev/null @@ -1,34 +0,0 @@ -/* A work-in-progess MEGA65 (Commodore 65 clone origins) emulator - Part of the Xemu project, please visit: https://github.com/lgblgblgb/xemu - Copyright (C)2016,2017,2021 LGB (Gábor Lénárt) - -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 XEMU_MEGA65_SNAPSHOT_H_INCLUDED -#define XEMU_MEGA65_SNAPSHOT_H_INCLUDED - -#ifdef XEMU_SNAPSHOT_SUPPORT -#include "xemu/emutools_snapshot.h" - -// From other modules ... -extern int m65emu_snapshot_load_state ( const struct xemu_snapshot_definition_st *def, struct xemu_snapshot_block_st *block ); -extern int m65emu_snapshot_save_state ( const struct xemu_snapshot_definition_st *def ); -extern int m65emu_snapshot_loading_finalize ( const struct xemu_snapshot_definition_st *def, struct xemu_snapshot_block_st *block ); - -// From our .c file -extern const struct xemu_snapshot_definition_st m65_snapshot_definition[]; - -#endif -#endif diff --git a/targets/mega65/mega65.c b/targets/mega65/mega65.c index 426eded0..08525218 100644 --- a/targets/mega65/mega65.c +++ b/targets/mega65/mega65.c @@ -30,7 +30,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "xemu/c64_kbd_mapping.h" #include "xemu/emutools_config.h" #include "xemu/emutools_umon.h" -#include "m65_snapshot.h" #include "memory_mapper.h" #include "io_mapper.h" #include "ethernet65.h" @@ -253,19 +252,6 @@ static Uint8 cia2_in_b ( void ) } -#ifdef XEMU_SNAPSHOT_SUPPORT -static void m65_snapshot_saver_on_exit_callback ( void ) -{ - if (!configdb.snapsave) - return; - if (xemusnap_save(configdb.snapsave)) - ERROR_WINDOW("Could not save snapshot \"%s\": %s", configdb.snapsave, xemusnap_error_buffer); - else - INFO_WINDOW("Snapshot has been saved to \"%s\".", configdb.snapsave); -} -#endif - - static int preinit_memory_item ( const char *name, const char *desc, Uint8 *target_ptr, const Uint8 *source_ptr, const int source_size, const int min_size, const int max_size, const char *fn ) { if (source_size < min_size || source_size > max_size || min_size > max_size) @@ -443,14 +429,6 @@ static void mega65_init ( void ) if (configdb.useutilmenu) hwa_kbd_set_fake_key(0x20); DEBUG("INIT: end of initialization!" NL); -#ifdef XEMU_SNAPSHOT_SUPPORT - xemusnap_init(m65_snapshot_definition); - if (configdb.snapload) { - if (xemusnap_load(configdb.snapload)) - FATAL("Couldn't load snapshot \"%s\": %s", configdb.snapload, xemusnap_error_buffer); - } - atexit(m65_snapshot_saver_on_exit_callback); -#endif } @@ -908,79 +886,3 @@ int main ( int argc, char **argv ) XEMU_MAIN_LOOP(emulation_loop, 25, 1); return 0; } - -/* --- SNAPSHOT RELATED --- */ - -#ifdef XEMU_SNAPSHOT_SUPPORT - -#include - -#define SNAPSHOT_M65_BLOCK_VERSION 2 -#define SNAPSHOT_M65_BLOCK_SIZE (0x100 + sizeof(D6XX_registers) + sizeof(D7XX)) - - -int m65emu_snapshot_load_state ( const struct xemu_snapshot_definition_st *def, struct xemu_snapshot_block_st *block ) -{ - Uint8 buffer[SNAPSHOT_M65_BLOCK_SIZE]; - int a; - if (block->block_version != SNAPSHOT_M65_BLOCK_VERSION || block->sub_counter || block->sub_size != sizeof buffer) - RETURN_XSNAPERR_USER("Bad M65 block syntax"); - a = xemusnap_read_file(buffer, sizeof buffer); - if (a) return a; - /* loading state ... */ - memcpy(D6XX_registers, buffer + 0x100, sizeof D6XX_registers); - memcpy(D7XX, buffer + 0x200, sizeof D7XX); - in_hypervisor = 1; // simulate hypervisor mode, to allow to write some regs now instead of causing a TRAP now ... - io_write(0x367D, D6XX_registers[0x7D]); // write $(D)67D in VIC-IV I/O mode! (sets ROM protection, linear addressing mode enable ...) - // TODO FIXME: see if there is a need for other registers from D6XX_registers to write back to take effect on loading snapshot! - // end of spec, hypervisor-needed faked mode for loading snapshot ... - map_mask = (int)P_AS_BE32(buffer + 0); - map_offset_low = (int)P_AS_BE32(buffer + 4); - map_offset_high = (int)P_AS_BE32(buffer + 8); - cpu65.cpu_inhibit_interrupts = (int)P_AS_BE32(buffer + 12); - in_hypervisor = (int)P_AS_BE32(buffer + 16); // sets hypervisor state from snapshot (hypervisor/userspace) - map_megabyte_low = (int)P_AS_BE32(buffer + 20); - map_megabyte_high = (int)P_AS_BE32(buffer + 24); - //force_fast_loaded = (int)P_AS_BE32(buffer + 28); // activated in m65emu_snapshot_loading_finalize() as force_fast can be set at multiple places through loading snapshot! - // +32 is free for 4 bytes now ... can be used later - memory_set_cpu_io_port_ddr_and_data(buffer[36], buffer[37]); - return 0; -} - - -int m65emu_snapshot_save_state ( const struct xemu_snapshot_definition_st *def ) -{ - Uint8 buffer[SNAPSHOT_M65_BLOCK_SIZE]; - int a = xemusnap_write_block_header(def->idstr, SNAPSHOT_M65_BLOCK_VERSION); - if (a) return a; - memset(buffer, 0xFF, sizeof buffer); - /* saving state ... */ - U32_AS_BE(buffer + 0, map_mask); - U32_AS_BE(buffer + 4, map_offset_low); - U32_AS_BE(buffer + 8, map_offset_high); - U32_AS_BE(buffer + 12, cpu65.cpu_inhibit_interrupts); - U32_AS_BE(buffer + 16, in_hypervisor); - U32_AS_BE(buffer + 20, map_megabyte_low); - U32_AS_BE(buffer + 24, map_megabyte_high); - //U32_AS_BE(buffer + 28, force_fast); // see notes on this at load_state and finalize stuff! - // +32 is free for 4 bytes now ... can be used later - buffer[36] = memory_get_cpu_io_port(0); - buffer[37] = memory_get_cpu_io_port(1); - memcpy(buffer + 0x100, D6XX_registers, sizeof D6XX_registers); - memcpy(buffer + 0x200, D7XX, sizeof D7XX); - return xemusnap_write_sub_block(buffer, sizeof buffer); -} - - -int m65emu_snapshot_loading_finalize ( const struct xemu_snapshot_definition_st *def, struct xemu_snapshot_block_st *block ) -{ - DEBUGPRINT("SNAP: loaded (finalize-callback: begin)" NL); - memory_set_vic3_rom_mapping(vic_registers[0x30]); - memory_set_do_map(); - //force_fast = force_fast_loaded; // force_fast is handled through different places, so we must have a "finalize" construct and saved separately to have the actual effect ... - machine_set_speed(1); - DEBUGPRINT("SNAP: loaded (finalize-callback: end)" NL); - OSD(-1, -1, "Snapshot has been loaded."); - return 0; -} -#endif diff --git a/targets/mega65/sdcard.c b/targets/mega65/sdcard.c index 1caeee2e..2823b6c7 100644 --- a/targets/mega65/sdcard.c +++ b/targets/mega65/sdcard.c @@ -1262,55 +1262,3 @@ Uint8 sdcard_read_register ( const int reg ) } return data; } - - -/* --- SNAPSHOT RELATED --- */ - - -#ifdef XEMU_SNAPSHOT_SUPPORT - -#include - -#define SNAPSHOT_SDCARD_BLOCK_VERSION 0 -#define SNAPSHOT_SDCARD_BLOCK_SIZE (0x100 + sizeof(disk_buffers)) - -int sdcard_snapshot_load_state ( const struct xemu_snapshot_definition_st *def, struct xemu_snapshot_block_st *block ) -{ - Uint8 buffer[SNAPSHOT_SDCARD_BLOCK_SIZE]; - int a; - if (block->block_version != SNAPSHOT_SDCARD_BLOCK_VERSION || block->sub_counter || block->sub_size != sizeof buffer) - RETURN_XSNAPERR_USER("Bad SD-Card block syntax"); - a = xemusnap_read_file(buffer, sizeof buffer); - if (a) return a; - /* loading state ... */ - memcpy(sd_sector_registers, buffer, 4); - memcpy(sd_d81_img1_start, buffer + 4, 4); - fd_mounted = (int)P_AS_BE32(buffer + 8); - sd_is_read_only = (int)P_AS_BE32(buffer + 16); - //d81_is_read_only = (int)P_AS_BE32(buffer + 20); - //use_d81 = (int)P_AS_BE32(buffer + 24); - sd_status = buffer[0xFF]; - memcpy(disk_buffers, buffer + 0x100, sizeof disk_buffers); - return 0; -} - - -int sdcard_snapshot_save_state ( const struct xemu_snapshot_definition_st *def ) -{ - Uint8 buffer[SNAPSHOT_SDCARD_BLOCK_SIZE]; - int a = xemusnap_write_block_header(def->idstr, SNAPSHOT_SDCARD_BLOCK_VERSION); - if (a) return a; - memset(buffer, 0xFF, sizeof buffer); - /* saving state ... */ - memcpy(buffer, sd_sector_registers, 4); - memcpy(buffer + 4,sd_d81_img1_start, 4); - U32_AS_BE(buffer + 8, fd_mounted); - U32_AS_BE(buffer + 16, sd_is_read_only); - //U32_AS_BE(buffer + 20, d81_is_read_only); - //U32_AS_BE(buffer + 24, use_d81); - buffer[0xFF] = sd_status; - memcpy(buffer + 0x100, disk_buffers, sizeof disk_buffers); - return xemusnap_write_sub_block(buffer, sizeof buffer); -} - -#endif diff --git a/targets/mega65/sdcard.h b/targets/mega65/sdcard.h index 7da158d6..61d72cf0 100644 --- a/targets/mega65/sdcard.h +++ b/targets/mega65/sdcard.h @@ -64,10 +64,4 @@ static inline int has_block_nonzero_byte ( const Uint8 *p ) return 0; } -#ifdef XEMU_SNAPSHOT_SUPPORT -#include "xemu/emutools_snapshot.h" -extern int sdcard_snapshot_load_state ( const struct xemu_snapshot_definition_st *def , struct xemu_snapshot_block_st *block ); -extern int sdcard_snapshot_save_state ( const struct xemu_snapshot_definition_st *def ); -#endif - #endif diff --git a/targets/mega65/vic4.c b/targets/mega65/vic4.c index b651b5dd..eb869f39 100644 --- a/targets/mega65/vic4.c +++ b/targets/mega65/vic4.c @@ -1702,56 +1702,3 @@ void vic4_set_emulation_colour_effect ( int val ) vic4_revalidate_all_palette(); } } - - -/* --- SNAPSHOT RELATED --- */ - - -#ifdef XEMU_SNAPSHOT_SUPPORT - -#include - -#define SNAPSHOT_VIC4_BLOCK_VERSION 2 -#define SNAPSHOT_VIC4_BLOCK_SIZE (0x100 + ((NO_OF_PALETTE_REGS) * 3)) - -int vic4_snapshot_load_state ( const struct xemu_snapshot_definition_st *def, struct xemu_snapshot_block_st *block ) -{ - Uint8 buffer[SNAPSHOT_VIC4_BLOCK_SIZE]; - int a; - if (block->block_version != SNAPSHOT_VIC4_BLOCK_VERSION || block->sub_counter || block->sub_size != sizeof buffer) - RETURN_XSNAPERR_USER("Bad VIC4 block syntax"); - a = xemusnap_read_file(buffer, sizeof buffer); - if (a) return a; - /* loading state ... */ - for (a = 0; a < 0x80; a++) - vic_write_reg(a, buffer[a + 0x80]); - c128_d030_reg = buffer[0x7F]; - memcpy(vic_palette_bytes_red, buffer + 0x100 , NO_OF_PALETTE_REGS); - memcpy(vic_palette_bytes_green, buffer + 0x100 + NO_OF_PALETTE_REGS, NO_OF_PALETTE_REGS); - memcpy(vic_palette_bytes_blue, buffer + 0x100 + 2 * NO_OF_PALETTE_REGS, NO_OF_PALETTE_REGS); - vic4_revalidate_all_palette(); - io_mode = buffer[0]; - DEBUG("SNAP: VIC4: changing I/O mode to %d(%s)" NL, io_mode, iomode_names[io_mode]); - interrupt_status = (int)P_AS_BE32(buffer + 1); - return 0; -} - - -int vic4_snapshot_save_state ( const struct xemu_snapshot_definition_st *def ) -{ - Uint8 buffer[SNAPSHOT_VIC4_BLOCK_SIZE]; - int a = xemusnap_write_block_header(def->idstr, SNAPSHOT_VIC4_BLOCK_VERSION); - if (a) return a; - memset(buffer, 0xFF, sizeof buffer); - /* saving state ... */ - memcpy(buffer + 0x80, vic_registers, 0x80); // $80 bytes - buffer[0x7F] = c128_d030_reg; - memcpy(buffer + 0x100 , vic_palette_bytes_red, NO_OF_PALETTE_REGS); - memcpy(buffer + 0x100 + NO_OF_PALETTE_REGS, vic_palette_bytes_green, NO_OF_PALETTE_REGS); - memcpy(buffer + 0x100 + 2 * NO_OF_PALETTE_REGS, vic_palette_bytes_blue, NO_OF_PALETTE_REGS); - buffer[0] = io_mode; - U32_AS_BE(buffer + 1, interrupt_status); - return xemusnap_write_sub_block(buffer, sizeof buffer); -} - -#endif diff --git a/targets/mega65/vic4.h b/targets/mega65/vic4.h index e6b892b8..dbb5a9c2 100644 --- a/targets/mega65/vic4.h +++ b/targets/mega65/vic4.h @@ -275,10 +275,4 @@ extern char *vic4_textshot ( void ); extern int vic4_textinsert ( const char *text ); extern void vic4_set_emulation_colour_effect ( int val ); -#ifdef XEMU_SNAPSHOT_SUPPORT -#include "xemu/emutools_snapshot.h" -extern int vic4_snapshot_load_state ( const struct xemu_snapshot_definition_st *def , struct xemu_snapshot_block_st *block ); -extern int vic4_snapshot_save_state ( const struct xemu_snapshot_definition_st *def ); -#endif - #endif diff --git a/targets/mega65/xemu-target.h b/targets/mega65/xemu-target.h index 8ac4eb84..2827bede 100644 --- a/targets/mega65/xemu-target.h +++ b/targets/mega65/xemu-target.h @@ -1,6 +1,6 @@ /* A work-in-progess MEGA65 (Commodore 65 clone origins) emulator Part of the Xemu project, please visit: https://github.com/lgblgblgb/xemu - Copyright (C)2016-2023 LGB (Gábor Lénárt) + Copyright (C)2016-2024 LGB (Gábor Lénárt) 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 @@ -21,7 +21,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #define CPU_65CE02 #define MEGA65 #define CPU65_65CE02_6502NMOS_TIMING_EMULATION -//#define XEMU_SNAPSHOT_SUPPORT "MEGA65" #define CPU_STEP_MULTI_OPS //#define DEBUG_CPU #define CPU_CUSTOM_MEMORY_FUNCTIONS_H "cpu_custom_functions.h"