-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MEGA65: the start of cartridge support #380
- Loading branch information
Showing
8 changed files
with
171 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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-2022 LGB (Gábor Lénárt) <[email protected]> | ||
## Copyright (C)2016-2023 LGB (Gábor Lénárt) <[email protected]> | ||
# | ||
# 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,7 +20,7 @@ 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 | ||
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 | ||
CFLAGS_TARGET_xmega65 = $(SDL2_CFLAGS) $(MATH_CFLAGS) $(SOCKET_CFLAGS) $(XEMUGUI_CFLAGS) | ||
LDFLAGS_TARGET_xmega65 = $(SDL2_LIBS) $(MATH_LIBS) $(SOCKET_LIBS) $(XEMUGUI_LIBS) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* 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) <[email protected]> | ||
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 "xemu/emutools.h" | ||
#include "cart.h" | ||
#include "xemu/emutools_files.h" | ||
|
||
static Uint8 cart_mem[0x10000]; | ||
static int loaded = 0; | ||
|
||
|
||
void cart_init ( void ) | ||
{ | ||
memset(cart_mem, 0xFF, sizeof cart_mem); | ||
} | ||
|
||
|
||
Uint8 cart_read_byte ( unsigned int addr ) | ||
{ | ||
Uint8 data = 0xFF; | ||
if (addr < sizeof(cart_mem)) | ||
data = cart_mem[addr]; | ||
DEBUGPRINT("CART: reading byte ($%02X) at $%X" NL, data, addr + 0x4000000); | ||
return data; | ||
} | ||
|
||
|
||
void cart_write_byte ( unsigned int addr, Uint8 data ) | ||
{ | ||
DEBUGPRINT("CART: writing byte ($%02X) at $%X" NL, data, addr + 0x4000000); | ||
} | ||
|
||
|
||
int cart_load_bin ( const char *fn, const unsigned int addr, const char *cry ) | ||
{ | ||
if (!fn || !*fn) | ||
return 0; | ||
loaded = 0; | ||
if (addr >= sizeof(cart_mem)) { | ||
if (cry) | ||
ERROR_WINDOW("%s\nOutside of 64K range\n%s", cry, fn); | ||
return -1; | ||
} | ||
const int ret = xemu_load_file(fn, cart_mem + addr, 1, sizeof(cart_mem) - addr, cry); | ||
if (ret <= 0) | ||
return -1; | ||
DEBUGPRINT("CART: %d byte(s) loaded at offset $%04X from file %s" NL, ret, addr, fn); | ||
loaded = 1; | ||
return 0; | ||
} | ||
|
||
|
||
int cart_detect_id ( void ) | ||
{ | ||
static const Uint8 cart_id[] = {'M', '6', '5'}; | ||
return memcmp(cart_mem + 0x8007, cart_id, sizeof cart_id); | ||
} | ||
|
||
|
||
int cart_is_loaded ( void ) | ||
{ | ||
return loaded; | ||
} | ||
|
||
|
||
void cart_copy_from ( const Uint16 cart_addr, Uint8 *target, const Uint16 size ) | ||
{ | ||
memcpy(target, cart_mem + cart_addr, size); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* 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) <[email protected]> | ||
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_CART_H_INCLUDED | ||
#define XEMU_MEGA65_CART_H_INCLUDED | ||
|
||
extern void cart_init ( void ); | ||
extern Uint8 cart_read_byte ( unsigned int addr ); | ||
extern void cart_write_byte ( unsigned int addr, Uint8 data ); | ||
extern int cart_load_bin ( const char *fn, const unsigned int addr, const char *cry ); | ||
extern void cart_copy_from ( const Uint16 cart_addr, Uint8 *target, const Uint16 size ); | ||
extern int cart_detect_id ( void ); | ||
extern int cart_is_loaded ( void ); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters