/*
* cpmcart.c
*
* Written by
* Marco van den Heuvel <blackystardust68@yahoo.com>
*
* Based on code written by
* Andreas Boose <viceteam@t-online.de>
*
* 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 <stdlib.h>
#include "6510core.h"
#include "alarm.h"
#include "c64cia.h"
#include "c64mem.h"
#include "cartio.h"
#include "cartridge.h"
#include "cmdline.h"
#include "cpmcart.h"
#include "daa.h"
#include "export.h"
#include "interrupt.h"
#include "log.h"
#include "maincpu.h"
#include "mem.h"
#include "monitor.h"
#include "resources.h"
#include "snapshot.h"
#include "types.h"
#include "z80regs.h"
#ifdef Z80_4MHZ
#define CLK_ADD(clock, amount) clock = z80cpu_clock_add(clock, amount)
#else
#define CLK_ADD(clock, amount) clock += amount
#endif
static uint8_t reg_a = 0;
static uint8_t reg_b = 0;
static uint8_t reg_c = 0;
static uint8_t reg_d = 0;
static uint8_t reg_e = 0;
static uint8_t reg_f = 0;
static uint8_t reg_h = 0;
static uint8_t reg_l = 0;
static uint8_t reg_ixh = 0;
static uint8_t reg_ixl = 0;
static uint8_t reg_iyh = 0;
static uint8_t reg_iyl = 0;
static uint16_t reg_sp = 0;
static uint32_t z80_reg_pc = 0;
static uint8_t reg_i = 0;
static uint8_t reg_r = 0;
static uint8_t iff1 = 0;
static uint8_t iff2 = 0;
static uint8_t im_mode = 0;
static uint8_t reg_a2 = 0;
static uint8_t reg_b2 = 0;
static uint8_t reg_c2 = 0;
static uint8_t reg_d2 = 0;
static uint8_t reg_e2 = 0;
static uint8_t reg_f2 = 0;
static uint8_t reg_h2 = 0;
static uint8_t reg_l2 = 0;
static int z80_started = 0;
static int cpmcart_enabled = 0;
static read_func_ptr_t cpmcart_mem_read_tab[0x101];
static store_func_ptr_t cpmcart_mem_write_tab[0x101];
static uint8_t cpmcart_wrap_read(uint16_t addr)
{
uint32_t address = ((uint32_t)addr + 0x1000) & 0xffff;
return cpmcart_mem_read_tab[addr >> 8]((uint16_t)address);
}
static void cpmcart_wrap_store(uint16_t addr, uint8_t value)
{
uint32_t address = ((uint32_t)addr + 0x1000) & 0xffff;
cpmcart_mem_write_tab[addr >> 8]((uint16_t)address, value);
}
static void set_read_item(int index, uint8_t (*func)(uint16_t addr))
{
cpmcart_mem_read_tab[index] = func;
}
static void set_write_item(int index, void (*func)(uint16_t addr, uint8_t val))
{
cpmcart_mem_write_tab[index] = func;
}
static void cpmcart_mem_init(void)
{
int i;
/* z80 $0000-$bfff -> c64 $1000-$cfff (RAM) */
for (i = 0; i < 0xc0; ++i) {
set_read_item(i, ram_read);
set_write_item(i, ram_store);
}
/* z80 $c000-$c7ff -> c64 $d000-$d7ff (VICII/SID I/O) */
set_read_item(0xc0, c64io_d000_read);
set_write_item(0xc0, c64io_d000_store);
set_read_item(0xc1, c64io_d100_read);
set_write_item(0xc1, c64io_d100_store);
set_read_item(0xc2, c64io_d200_read);
set_write_item(0xc2, c64io_d200_store);
set_read_item(0xc3, c64io_d300_read);
set_write_item(0xc3, c64io_d300_store);
set_read_item(0xc4, c64io_d400_read);
set_write_item(0xc4, c64io_d400_store);
set_read_item(0xc5, c64io_d500_read);
set_write_item(0xc5, c64io_d500_store);
set_read_item(0xc6, c64io_d600_read);
set_write_item(0xc6, c64io_d600_store);
set_read_item(0xc7, c64io_d700_read);
set_write_item(0xc7, c64io_d700_store);
/* z80 $c800-$cbff -> c64 $d800-$dbff (VICII colorram) */
for (i = 0xc8; i <= 0xcb; ++i) {
set_read_item(i, colorram_read);
set_write_item(i, colorram_store);
}
/* z80 $cc00-$ccff -> c64 $dc00-$dcff (CIA1) */
set_read_item(0xcc, cia1_read);
set_write_item(0xcc, cia1_store);
/* z80 $cd00-$cdff -> c64 $dd00-$ddff (CIA1) */
set_read_item(0xcd, cia2_read);
set_write_item(0xcd, cia2_store);
/* z80 $ce00-$ceff -> c64 $de00-$deff (I/O-1) */
set_read_item(0xce, c64io_de00_read);
set_write_item(0xce, c64io_de00_store);
/* z80 $cf00-$cfff -> c64 $df00-$dfff (I/O-2) */
set_read_item(0xcf, c64io_df00_read);
set_write_item(0xcf, c64io_df00_store);
/* z80 $d000-$efff -> c64 $e000-$ffff (RAM) */
for (i = 0xd0; i < 0xf0; ++i) {
set_read_item(i, ram_read);
set_write_item(i, ram_store);
}
/* z80 $f000-$ffff -> c64 $0000-$0fff (RAM) */
for (i = 0xf0; i < 0x100; ++i) {
set_read_item(i, ram_read);
set_write_item(i, ram_store);
}
}
static void cpmcart_io_store(uint16_t addr, uint8_t byte)
{
int val = byte & 1;
if (!z80_started && !val) {
z80_started = 1;
} else if (z80_started && val) {
z80_started = 0;
}
}
int cpmcart_cart_enabled(void)
{
return cpmcart_enabled;
}
static int cpmcart_dump(void)
{
mon_out("Active CPU: %s\n", z80_started ? "Z80" : "6510");
return 0;
}
static io_source_t cpmcart_device = {
"CP/M Cartridge", /* name of the device */
IO_DETACH_RESOURCE, /* use resource to detach the device when involved in a read-collision */
"CPMCart", /* resource to set to '0' */
0xde00, 0xdeff, 0xff, /* range of the device, address is ignored, reg:$de00, mirrors:$de01-$deff */
0, /* read is never valid, device is write only */
cpmcart_io_store, /* store function */
NULL, /* NO poke function */
NULL, /* NO read function */
NULL, /* NO peek function */
cpmcart_dump, /* device state information dump function */
CARTRIDGE_CPM, /* 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 */
};
static io_source_list_t *cpmcart_list_item = NULL;
static const export_resource_t export_res = {
CARTRIDGE_NAME_CPM, 0, 0, &cpmcart_device, NULL, CARTRIDGE_CPM
};
static int set_cpmcart_enabled(int value, void *param)
{
int val = value ? 1 : 0;
if (cpmcart_enabled != val) {
if (val) {
if (export_add(&export_res) < 0) {
return -1;
}
cpmcart_list_item = io_source_register(&cpmcart_device);
cpmcart_enabled = 1;
} else {
export_remove(&export_res);
io_source_unregister(cpmcart_list_item);
cpmcart_list_item = NULL;
cpmcart_enabled = 0;
z80_started = 0;
}
}
return 0;
}
static const resource_int_t resources_int[] = {
{ "CPMCart", 0, RES_EVENT_STRICT, (resource_value_t)0,
&cpmcart_enabled, set_cpmcart_enabled, NULL },
RESOURCE_INT_LIST_END
};
int cpmcart_resources_init(void)
{
cpmcart_mem_init();
return resources_register_int(resources_int);
}
static const cmdline_option_t cmdline_options[] =
{
{ "-cpmcart", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
NULL, NULL, "CPMCart", (resource_value_t)1,
NULL, "Enable the CP/M cartridge" },
{ "+cpmcart", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
NULL, NULL, "
没有合适的资源?快使用搜索试试~ 我知道了~
nes,md,gba模拟器源码,以及编译方法
共2000个文件
h:993个
c:987个
cpp:12个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 177 浏览量
2024-07-02
21:13:36
上传
评论 1
收藏 264.56MB RAR 举报
温馨提示
emu是一个多游戏模拟器引擎,每一个需要单独编译,提供源码以及对应的编译方法。 安装ubuntu 16.04 下载gcc 8.2 安装 然后安装automake 1.16 ,1.15 安装jdk8 sdk 里面配套的ndk 21e
资源推荐
资源详情
资源评论
收起资源包目录
nes,md,gba模拟器源码,以及编译方法 (2000个子文件)
cpmcart.c 247KB
z80.c 237KB
FdcAudio.c 234KB
mon_parse.c 171KB
R800.c 171KB
6809.c 160KB
mon_lex.c 154KB
c1541.c 145KB
65816core.c 144KB
6510core.c 135KB
drive-sound.c 113KB
c64carthooks.c 113KB
mmcreplay.c 109KB
6510dtvcore.c 108KB
65c02core.c 102KB
petcat.c 98KB
viciidtv-draw.c 80KB
keyboard.c 76KB
drv-nl10.c 76KB
vicii-mem.c 73KB
asmz80.c 73KB
info.c 72KB
asm6809.c 70KB
c128meminit.c 69KB
file_drv.c 69KB
sfx_soundexpander.c 68KB
monitor.c 68KB
cartconv.c 67KB
mouse.c 66KB
c64cartmem.c 64KB
cs8900.c 62KB
ciacore.c 61KB
petmem.c 60KB
tapecart.c 59KB
fmopl.c 59KB
Machine.c 58KB
autostart.c 57KB
scpu64mem.c 56KB
vicii-sprites.c 56KB
viciivsid-sprites.c 56KB
ide64.c 56KB
rotation.c 56KB
mon_disassemble.c 55KB
vdrive-rel.c 54KB
reu.c 54KB
mmc64.c 54KB
vdc-draw.c 53KB
vicii.c 52KB
viacore.c 52KB
viciivsid-draw.c 51KB
vicii-draw.c 51KB
ata.c 50KB
sound.c 50KB
viciivsid-mem.c 50KB
pc8477.c 48KB
p64.c 48KB
c64.c 48KB
retroreplay.c 47KB
vicii-chip-model.c 46KB
c128mem.c 46KB
magicvoice.c 46KB
Properties.c 45KB
viciivsid.c 45KB
c128.c 45KB
plus4mem.c 44KB
drive-snapshot.c 43KB
vdrive-command.c 41KB
tap.c 41KB
Board.c 41KB
userport_joystick.c 41KB
scpu64.c 40KB
c64dtvmem.c 40KB
wd1770.c 40KB
cbm5x0mem.c 40KB
ds12c887.c 39KB
datasette.c 39KB
resources.c 39KB
c64mem.c 39KB
aciacore.c 38KB
event.c 38KB
Actions.c 37KB
cbm2mem.c 37KB
fastsid.c 37KB
c64memsc.c 37KB
util.c 36KB
sid-snapshot.c 36KB
petdww.c 34KB
ted-draw.c 34KB
render2x2.c 34KB
lib.c 34KB
vic20.c 34KB
crtc.c 34KB
c128memlimit.c 33KB
fdc.c 33KB
drv-1520.c 33KB
zfile.c 33KB
c64dtvcpu.c 33KB
serial-iec-device.c 33KB
ds1202_1302.c 32KB
ScsiDevice.c 32KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
计算机毕业设计(源码都能跑起来)
- 粉丝: 3913
- 资源: 1567
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 国际象棋检测11-YOLO(v7至v9)、COCO、Darknet、Paligemma、VOC数据集合集.rar
- 使用Python和matplotlib库绘制爱心图形的技术教程
- Java外卖项目(瑞吉外卖项目的扩展)
- 必应图片壁纸Python爬虫代码bing-img.zip
- 基于Pygame库实现新年烟花效果的Python代码
- 浪漫节日代码 - 爱心代码、圣诞树代码
- 睡眠健康与生活方式数据集,睡眠和生活习惯关联分析()
- 2024~2025(1)Oracle数据库技术A卷-22软单、软嵌.doc
- 国际象棋检测10-YOLO(v5至v9)、COCO、CreateML、Paligemma数据集合集.rar
- 100个情侣头像,唯美手绘情侣头像
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功