Skip to content

Commit

Permalink
sd-content, fpgra recfg, reset meminit #140
Browse files Browse the repository at this point in the history
  • Loading branch information
lgblgblgb committed Dec 10, 2021
1 parent fe6354b commit c228867
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 832 deletions.
55 changes: 35 additions & 20 deletions build/m65-memcontent-generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,23 @@
MEMCONTENT_VERSION_ID = 1

FILE_DB = {
"HICKUP.M65": "hickup",
"COLOURRAM.BIN": "cramutils",
"BANNER.M65": "banner",
"FREEZER.M65": "freezer",
"ONBOARD.M65": "onboard",
"mega65.rom": "openrom",
"megaflash-a200t.prg": "megaflash",
"AUDIOMIX.M65": "audiomix",
"C64THUMB.M65": "c64thumb",
"C65THUMB.M65": "c65thumb",
"ROMLOAD.M65": "romload",
"SPRITED.M65": "sprited",
"charrom.bin": "chrwom",
# -------------------------------------------------------------------- #
# mega65-core-base-name | file-id |SD-image-name(None=not-on-SD) #
#--------------------------------------------------------------------- #
"HICKUP.M65": ("hickup", None ),
"COLOURRAM.BIN": ("cramutils", None ),
"BANNER.M65": ("banner", "BANNER.M65" ),
"FREEZER.M65": ("freezer", "FREEZER.M65" ),
"ONBOARD.M65": ("onboard", "ONBOARD.M65" ), # Do we really need this on SD-card?
"mega65.rom": ("openrom", None ),
#"megaflash-a200t.prg": ("megaflash", None ),
"AUDIOMIX.M65": ("audiomix", "AUDIOMIX.M65" ),
"C64THUMB.M65": ("c64thumb", "C64THUMB.M65" ),
"C65THUMB.M65": ("c65thumb", "C65THUMB.M65" ),
"ROMLOAD.M65": ("romload", "ROMLOAD.M65" ), # Do we really need this on SD-card?
"SPRITED.M65": ("sprited", "SPRITED.M65" ),
"charrom.bin": ("chrwom", None ),
}
files_done = set()

HEADER = """/* !THIS IS A GENERATED FILE! DO NOT EDIT!
* Instead, say 'make recreatememcontent' to re-generate this file
Expand All @@ -52,8 +54,6 @@
* which is available in source form at https://github.com/MEGA65/mega65-core
* always, as per GNU/GPL. */
#include "xemu/emutools.h"
"""


Expand All @@ -77,6 +77,7 @@ def bin_dump(data):
if len(sys.argv) < 4:
sys.stderr.write("Bad usage.\n")
sys.exit(1)
files_done = set()
c_file = sys.argv[1]
h_file = sys.argv[2]
in_files = sys.argv[3:]
Expand All @@ -87,14 +88,28 @@ def bin_dump(data):
h_data += """\n// This must be incremented by ONE every time, when memcontent.c changes, or even
// if sdcontent.c is changed in a way to write new files, new content, or whatever
// to the SD-card as part of the "update system files" process. Edit this in the python generator though, not in this file!
#define MEMCONTENT_VERSION_ID {}\n""".format(MEMCONTENT_VERSION_ID)
#define MEMCONTENT_VERSION_ID {}\n\n""".format(MEMCONTENT_VERSION_ID)
c_data += "#include \"memcontent.h\"\n\n"
h_data += "#include \"xemu/emutools.h\"\n\n"
h_data += "// Special structure array for system files update on the SD-image\n"
c_data += "// Special structure array for system files update on the SD-image\n"
on_sd = sorted([k for k, v in FILE_DB.items() if v[1] is not None])
h_data += "struct meminitdata_sdfiles_st { const Uint8 *p; const char *fn; const int size; };\n"
h_data += "#define MEMINITDATA_SDFILES_ITEMS {}\n".format(len(on_sd))
h_data += "extern const struct meminitdata_sdfiles_st meminitdata_sdfiles_db[MEMINITDATA_SDFILES_ITEMS];\n"
c_data += "const struct meminitdata_sdfiles_st meminitdata_sdfiles_db[MEMINITDATA_SDFILES_ITEMS] = {\n"
print("Adding files also as SD-content: {}".format(" ".join(on_sd)))
for a in on_sd:
c_data += "\t{"
c_data += " meminitdata_{}, \"{}\", MEMINITDATA_{}_SIZE ".format(FILE_DB[a][0], FILE_DB[a][1].upper(), FILE_DB[a][0].upper())
c_data += "},\n"
c_data += "};\n\n"
for fn in in_files:
fn_base = fn.split("/")[-1]
if fn_base not in FILE_DB:
sys.stderr.write("Unknown file encountered: {}\n".format(fn))
sys.exit(1)
fn_id = FILE_DB[fn_base]
fn_id = FILE_DB[fn_base][0]
if fn_id in files_done:
sys.stderr.write("ERROR: file {} is used more than once by id \"{}\"!\n".format(fn, fn_id))
sys.exit(1)
Expand All @@ -115,6 +130,6 @@ def bin_dump(data):
with open(c_file, "wt") as f: f.write(c_data)
with open(h_file, "wt") as f: f.write(h_data)
for k, v in FILE_DB.items():
if v not in files_done:
print("Warning: entity {} was not specified (via filename {})\n".format(v, k))
if v[0] not in files_done:
print("Warning: entity {} was not specified (via filename {})\n".format(v[0], k))
sys.exit(0)
2 changes: 1 addition & 1 deletion targets/mega65/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ CFLAGS_TARGET_xmega65 = $(SDL2_CFLAGS) $(MATH_CFLAGS) $(SOCKET_CFLAGS) $(XEMUGUI
LDFLAGS_TARGET_xmega65 = $(SDL2_LIBS) $(MATH_LIBS) $(SOCKET_LIBS) $(XEMUGUI_LIBS)

MEGA65_CORE = ../../../mega65-core
MEGA65_FILES = bin/charrom.bin bin/HICKUP.M65 bin/COLOURRAM.BIN sdcard-files/BANNER.M65 sdcard-files/FREEZER.M65 sdcard-files/ONBOARD.M65 src/open-roms/bin/mega65.rom src/utilities/megaflash-a200t.prg
MEGA65_FILES = bin/charrom.bin bin/HICKUP.M65 bin/COLOURRAM.BIN sdcard-files/BANNER.M65 sdcard-files/FREEZER.M65 sdcard-files/ONBOARD.M65 src/open-roms/bin/mega65.rom
MEGA65_FILES += sdcard-files/AUDIOMIX.M65 sdcard-files/C64THUMB.M65 sdcard-files/C65THUMB.M65 sdcard-files/ROMLOAD.M65 sdcard-files/SPRITED.M65

include ../../build/Makefile.common
Expand Down
4 changes: 3 additions & 1 deletion targets/mega65/input_devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#define DEBUGKBDHWA(...) DEBUG(__VA_ARGS__)
#define DEBUGKBDHWACOM(...) //DEBUGPRINT(__VA_ARGS__)

//#define FREEZER_WORKS


/* Note: M65 has a "hardware accelerated" keyboard scanner, it can provide you the
last pressed character as ASCII (!) without the need to actually scan/etc the
Expand Down Expand Up @@ -258,7 +260,7 @@ void kbd_trigger_restore_trap ( void )
} else
DEBUGPRINT("KBD: *IGNORING* RESTORE trap trigger, already in hypervisor mode!" NL);
#else
WARNING_WINDOW("Long press of RESTORE would trigger FREEZER.\nHowever FREEZER is not yet implemented in Xemu :-(");
WARNING_WINDOW("Long press of RESTORE would trigger FREEZER.\nHowever FREEZER does not yet work inside Xemu :-(");
#endif
}
}
Expand Down
8 changes: 8 additions & 0 deletions targets/mega65/io_mapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "input_devices.h"
#include "audio65.h"
#include "configdb.h"
#include "mega65.h"


int fpga_switches = 0; // State of FPGA board switches (bits 0 - 15), set switch 12 (hypervisor serial output)
Expand Down Expand Up @@ -459,6 +460,13 @@ void io_write ( unsigned int addr, Uint8 data )
addr, data, cpld_firmware_version[addr - 0x32] ^ fpga_firmware_version[addr - 0x32],
xemu_query_gate, xemu_query_interface_p);
return;
case 0xCF:
if (data == 0x42) {
if (ARE_YOU_SURE("FPGA reconfiguration request. System must be reset.\nIs it OK to do now?\nAnswering NO may crash your program requesting this task though,\nor can result in endless loop of trying.", ARE_YOU_SURE_DEFAULT_YES)) {
reset_mega65();
}
}
return;
default:
DEBUG("MEGA65: this I/O port is not emulated in Xemu yet: $D6%02X (tried to be written with $%02X)" NL, addr, data);
return;
Expand Down
1 change: 1 addition & 0 deletions targets/mega65/mega65.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ static void shutdown_callback ( void )

void reset_mega65 ( void )
{
refill_memory_from_preinit_cache(); // FIXME: hack, to allow to enter into utility menu (otherwise hickup displays you must power-cycle ..)
eth65_reset();
D6XX_registers[0x7D] &= ~16; // FIXME: other default speed controls on reset?
c128_d030_reg = 0xFF;
Expand Down
Loading

0 comments on commit c228867

Please sign in to comment.