mirror of
https://github.com/86Box/86Box.git
synced 2026-02-23 09:58:19 -07:00
Merge branch 'master' of https://github.com/86Box/86Box
This commit is contained in:
@@ -96,3 +96,4 @@ AppDir:
|
||||
AppImage:
|
||||
arch: !ENV '${arch_appimage}'
|
||||
file_name: !ENV '${appimage_path}'
|
||||
comp: gzip
|
||||
|
||||
43
.ci/build.sh
43
.ci/build.sh
@@ -603,7 +603,7 @@ else
|
||||
grep -q " bullseye " /etc/apt/sources.list || echo [!] WARNING: System not running the expected Debian version
|
||||
|
||||
# Establish general dependencies.
|
||||
pkgs="cmake ninja-build pkg-config git wget p7zip-full extra-cmake-modules wayland-protocols tar gzip file appstream qttranslations5-l10n"
|
||||
pkgs="cmake ninja-build pkg-config git wget p7zip-full extra-cmake-modules wayland-protocols tar gzip file appstream qttranslations5-l10n python3-pip python3-venv squashfs-tools"
|
||||
if [ "$(dpkg --print-architecture)" = "$arch_deb" ]
|
||||
then
|
||||
pkgs="$pkgs build-essential"
|
||||
@@ -1141,55 +1141,32 @@ EOF
|
||||
|
||||
# Copy line.
|
||||
echo "$line" >> AppImageBuilder-generated.yml
|
||||
|
||||
# Workaround for appimage-builder issues 272 and 283 (i686 and armhf are also missing)
|
||||
if [ "$arch_appimage" != "x86_64" -a "$line" = " files:" ]
|
||||
then
|
||||
# Some mild arbitrary code execution with a dummy package...
|
||||
[ ! -d /runtime ] && sudo apt-get -y -o 'DPkg::Post-Invoke::=mkdir -p /runtime; chmod 777 /runtime' install libsixel1 > /dev/null 2>&1
|
||||
|
||||
echo " include:" >> AppImageBuilder-generated.yml
|
||||
for loader in "/lib/$libdir/ld-linux"*.so.*
|
||||
do
|
||||
for loader_copy in "$loader" "/lib/$(basename "$loader")"
|
||||
do
|
||||
if [ ! -e "/runtime/compat$loader_copy" ]
|
||||
then
|
||||
mkdir -p "/runtime/compat$(dirname "$loader_copy")"
|
||||
ln -s "$loader" "/runtime/compat$loader_copy"
|
||||
fi
|
||||
echo " - /runtime/compat$loader_copy" >> AppImageBuilder-generated.yml
|
||||
done
|
||||
done
|
||||
fi
|
||||
done < .ci/AppImageBuilder.yml
|
||||
|
||||
# Download appimage-builder if necessary.
|
||||
appimage_builder_url="https://github.com/AppImageCrafters/appimage-builder/releases/download/v1.1.0/appimage-builder-1.1.0-$(uname -m).AppImage"
|
||||
appimage_builder_binary="$cache_dir/$(basename "$appimage_builder_url")"
|
||||
if [ ! -e "$appimage_builder_binary" ]
|
||||
appimage_builder_commit=22fefa298f9cee922a651a6f65a46fe0ccbfa34e # from issue 376
|
||||
appimage_builder_dir="$cache_dir/appimage-builder-$appimage_builder_commit"
|
||||
if [ ! -x "$appimage_builder_dir/bin/appimage-builder" ]
|
||||
then
|
||||
rm -rf "$cache_dir/"*".AppImage" # remove old versions
|
||||
wget -qO "$appimage_builder_binary" "$appimage_builder_url"
|
||||
rm -rf "$cache_dir/appimage-builder-"* # remove old versions
|
||||
python3 -m venv "$appimage_builder_dir" # venv to solve some Debian setuptools headaches
|
||||
"$appimage_builder_dir/bin/pip" install -U "git+https://github.com/AppImageCrafters/appimage-builder.git@$appimage_builder_commit"
|
||||
fi
|
||||
|
||||
# Symlink appimage-builder binary and global cache directory.
|
||||
# Symlink appimage-builder global cache directory.
|
||||
rm -rf appimage-builder.AppImage appimage-builder-cache "$project-"*".AppImage" # also remove any dangling AppImages which may interfere with the renaming process
|
||||
ln -s "$appimage_builder_binary" appimage-builder.AppImage
|
||||
chmod u+x appimage-builder.AppImage
|
||||
mkdir -p "$cache_dir/appimage-builder-cache"
|
||||
ln -s "$cache_dir/appimage-builder-cache" appimage-builder-cache
|
||||
|
||||
# Run appimage-builder in extract-and-run mode for Docker compatibility.
|
||||
# Run appimage-builder from the virtual environment created above.
|
||||
# --appdir is a workaround for appimage-builder issue 270 reported by us.
|
||||
for retry in 1 2 3 4 5
|
||||
do
|
||||
project="$project" project_id="$project_id" project_version="$project_version" project_icon="$project_icon" arch_deb="$arch_deb" \
|
||||
arch_appimage="$arch_appimage" appimage_path="$cwd/$package_name.AppImage" APPIMAGE_EXTRACT_AND_RUN=1 ./appimage-builder.AppImage \
|
||||
arch_appimage="$arch_appimage" appimage_path="$cwd/$package_name.AppImage" "$appimage_builder_dir/bin/appimage-builder" \
|
||||
--recipe AppImageBuilder-generated.yml --appdir "$(grep -oP '^\s+path: \K(.+)' AppImageBuilder-generated.yml)"
|
||||
status=$?
|
||||
[ $status -eq 0 ] && break
|
||||
[ $status -eq 127 ] && rm -rf /tmp/appimage_extracted_*
|
||||
done
|
||||
|
||||
# Remove appimage-builder binary on failure, just in case it's corrupted.
|
||||
|
||||
21
.github/workflows/cmake_linux.yml
vendored
21
.github/workflows/cmake_linux.yml
vendored
@@ -54,10 +54,12 @@ jobs:
|
||||
ui:
|
||||
- name: SDL GUI
|
||||
qt: off
|
||||
qt6: off
|
||||
static: on
|
||||
- name: Qt GUI
|
||||
- name: Qt 5 GUI
|
||||
qt: on
|
||||
slug: -Qt
|
||||
qt6: off
|
||||
slug: -Qt5
|
||||
packages: >-
|
||||
qtbase5-dev
|
||||
qtbase5-private-dev
|
||||
@@ -65,6 +67,20 @@ jobs:
|
||||
qttranslations5-l10n
|
||||
libevdev-dev
|
||||
libxkbcommon-x11-dev
|
||||
- name: Qt 6 GUI
|
||||
qt: on
|
||||
qt6: on
|
||||
slug: -Qt6
|
||||
packages: >-
|
||||
qt6-base-dev
|
||||
qt6-base-private-dev
|
||||
qt6-tools-dev
|
||||
qt6-tools-dev-tools
|
||||
qt6-l10n-tools
|
||||
qt6-translations-l10n
|
||||
libevdev-dev
|
||||
libxkbcommon-x11-dev
|
||||
libvulkan-dev
|
||||
environment:
|
||||
- arch: x86_64
|
||||
toolchain: ./cmake/flags-gcc-x86_64.cmake
|
||||
@@ -110,6 +126,7 @@ jobs:
|
||||
-D NEW_DYNAREC=${{ matrix.dynarec.new }}
|
||||
-D CMAKE_INSTALL_PREFIX=./build/artifacts
|
||||
-D QT=${{ matrix.ui.qt }}
|
||||
-D USE_QT6=${{ matrix.ui.qt6 }}
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
|
||||
@@ -194,6 +194,9 @@ cmake_dependent_option(WACOM "Wacom Input Devices"
|
||||
cmake_dependent_option(XL24 "ATI VGA Wonder XL24 (ATI-28800-6)" ON "DEV_BRANCH" OFF)
|
||||
cmake_dependent_option(NV3 "NVidia RIVA 128/128ZX (NV3/NV3T)" ON "DEV_BRANCH" OFF)
|
||||
|
||||
cmake_dependent_option(NETSWITCH "Network Switch Support" ON "DEV_BRANCH" OFF)
|
||||
|
||||
|
||||
# Ditto but for Qt
|
||||
if(QT)
|
||||
option(USE_QT6 "Use Qt6 instead of Qt5" OFF)
|
||||
@@ -230,7 +233,7 @@ if(NOT EMU_BUILD_NUM)
|
||||
set(EMU_BUILD_NUM 0)
|
||||
endif()
|
||||
if(NOT EMU_COPYRIGHT_YEAR)
|
||||
set(EMU_COPYRIGHT_YEAR 2024)
|
||||
set(EMU_COPYRIGHT_YEAR 2025)
|
||||
endif()
|
||||
|
||||
# Libasan
|
||||
@@ -239,4 +242,6 @@ if(LIBASAN)
|
||||
add_link_options(-fsanitize=address)
|
||||
endif()
|
||||
|
||||
set(CMAKE_TOP_LEVEL_PROCESSED TRUE)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
233
src/86box.c
233
src/86box.c
@@ -88,7 +88,7 @@
|
||||
#include <86box/scsi_device.h>
|
||||
#include <86box/cdrom.h>
|
||||
#include <86box/cdrom_interface.h>
|
||||
#include <86box/zip.h>
|
||||
#include <86box/rdisk.h>
|
||||
#include <86box/mo.h>
|
||||
#include <86box/scsi_disk.h>
|
||||
#include <86box/cdrom_image.h>
|
||||
@@ -161,7 +161,7 @@ int window_remember;
|
||||
int vid_resize; /* (C) allow resizing */
|
||||
int invert_display = 0; /* (C) invert the display */
|
||||
int suppress_overscan = 0; /* (C) suppress overscans */
|
||||
int lang_id = 0; /* (C) language id */
|
||||
int lang_id = 0; /* (G) language id */
|
||||
int scale = 0; /* (C) screen scale factor */
|
||||
int dpi_scale = 0; /* (C) DPI scaling of the emulated
|
||||
screen */
|
||||
@@ -199,13 +199,13 @@ int cpu = 0; /* (C) cpu typ
|
||||
int fpu_type = 0; /* (C) fpu type */
|
||||
int fpu_softfloat = 0; /* (C) fpu uses softfloat */
|
||||
int time_sync = 0; /* (C) enable time sync */
|
||||
int confirm_reset = 1; /* (C) enable reset confirmation */
|
||||
int confirm_exit = 1; /* (C) enable exit confirmation */
|
||||
int confirm_save = 1; /* (C) enable save confirmation */
|
||||
int confirm_reset = 1; /* (G) enable reset confirmation */
|
||||
int confirm_exit = 1; /* (G) enable exit confirmation */
|
||||
int confirm_save = 1; /* (G) enable save confirmation */
|
||||
int enable_discord = 0; /* (C) enable Discord integration */
|
||||
int pit_mode = -1; /* (C) force setting PIT mode */
|
||||
int fm_driver = 0; /* (C) select FM sound driver */
|
||||
int open_dir_usr_path = 0; /* (C) default file open dialog directory
|
||||
int open_dir_usr_path = 0; /* (G) default file open dialog directory
|
||||
of usr_path */
|
||||
int video_fullscreen_scale_maximized = 0; /* (C) Whether fullscreen scaling settings
|
||||
also apply when maximized. */
|
||||
@@ -215,7 +215,7 @@ int hook_enabled = 1; /* (C) Keyboar
|
||||
int test_mode = 0; /* (C) Test mode */
|
||||
char uuid[MAX_UUID_LEN] = { '\0' }; /* (C) UUID or machine identifier */
|
||||
int sound_muted = 0; /* (C) Is sound muted? */
|
||||
int inhibit_multimedia_keys; /* (C) Inhibit multimedia keys on Windows. */
|
||||
int inhibit_multimedia_keys; /* (G) Inhibit multimedia keys on Windows. */
|
||||
int force_10ms; /* (C) Force 10ms CPU frame intervals. */
|
||||
|
||||
int other_ide_present = 0; /* IDE controllers from non-IDE cards are
|
||||
@@ -232,27 +232,27 @@ struct accelKey acc_keys[NUM_ACCELS];
|
||||
struct accelKey def_acc_keys[NUM_ACCELS] = {
|
||||
{ .name="send_ctrl_alt_del", .desc="Send Control+Alt+Del",
|
||||
.seq="Ctrl+F12" },
|
||||
|
||||
{ .name="send_ctrl_alt_esc", .desc="Send Control+Alt+Escape",
|
||||
|
||||
{ .name="send_ctrl_alt_esc", .desc="Send Control+Alt+Escape",
|
||||
.seq="Ctrl+F10" },
|
||||
|
||||
{ .name="fullscreen", .desc="Toggle fullscreen",
|
||||
|
||||
{ .name="fullscreen", .desc="Toggle fullscreen",
|
||||
.seq="Ctrl+Alt+PgUp" },
|
||||
|
||||
{ .name="screenshot", .desc="Screenshot",
|
||||
|
||||
{ .name="screenshot", .desc="Screenshot",
|
||||
.seq="Ctrl+F11" },
|
||||
|
||||
{ .name="release_mouse", .desc="Release mouse pointer",
|
||||
|
||||
{ .name="release_mouse", .desc="Release mouse pointer",
|
||||
.seq="Ctrl+End" },
|
||||
|
||||
{ .name="hard_reset", .desc="Hard reset",
|
||||
|
||||
{ .name="hard_reset", .desc="Hard reset",
|
||||
.seq="Ctrl+Alt+F12" },
|
||||
|
||||
{ .name="pause", .desc="Toggle pause",
|
||||
|
||||
{ .name="pause", .desc="Toggle pause",
|
||||
.seq="Ctrl+Alt+F1" },
|
||||
|
||||
{ .name="mute", .desc="Toggle mute",
|
||||
.seq="Ctrl+Alt+M" }
|
||||
|
||||
{ .name="mute", .desc="Toggle mute",
|
||||
.seq="Ctrl+Alt+M" }
|
||||
};
|
||||
|
||||
char vmm_path[1024] = { '\0'}; /* TEMPORARY - VM manager path to scan for VMs */
|
||||
@@ -276,6 +276,7 @@ extern double exp_pow_table[0x800];
|
||||
char exe_path[2048]; /* path (dir) of executable */
|
||||
char usr_path[1024]; /* path (dir) of user data */
|
||||
char cfg_path[1024]; /* full path of config file */
|
||||
char global_cfg_path[1024]; /* full path of config file */
|
||||
FILE *stdlog = NULL; /* file to log output to */
|
||||
#if 0
|
||||
int scrnsz_x = SCREEN_RES_X; /* current screen size, X */
|
||||
@@ -299,9 +300,9 @@ static wchar_t mouse_msg[3][200];
|
||||
static volatile atomic_int do_pause_ack = 0;
|
||||
static volatile atomic_int pause_ack = 0;
|
||||
|
||||
#ifndef RELEASE_BUILD
|
||||
#define LOG_SIZE_BUFFER 8192 /* Log size buffer */
|
||||
|
||||
#define LOG_SIZE_BUFFER 1024 /* Log size buffer */
|
||||
#ifndef RELEASE_BUILD
|
||||
|
||||
static char buff[LOG_SIZE_BUFFER];
|
||||
|
||||
@@ -313,8 +314,8 @@ static int suppr_seen = 1;
|
||||
void pclog_ensure_stdlog_open(void);
|
||||
#endif
|
||||
|
||||
/*
|
||||
Ensures STDLOG is open for pclog_ex
|
||||
/*
|
||||
Ensures STDLOG is open for pclog_ex and pclog_ex_cyclic
|
||||
*/
|
||||
void pclog_ensure_stdlog_open(void)
|
||||
{
|
||||
@@ -363,8 +364,6 @@ pclog_ex(UNUSED(const char *fmt), UNUSED(va_list ap))
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
pclog_toggle_suppr(void)
|
||||
{
|
||||
@@ -386,11 +385,35 @@ pclog(UNUSED(const char *fmt), ...)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Log something even in release builds. */
|
||||
void
|
||||
always_log(const char *fmt, ...)
|
||||
{
|
||||
char temp[LOG_SIZE_BUFFER];
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
|
||||
if (stdlog == NULL) {
|
||||
if (log_path[0] != '\0') {
|
||||
stdlog = plat_fopen(log_path, "w");
|
||||
if (stdlog == NULL)
|
||||
stdlog = stdout;
|
||||
} else
|
||||
stdlog = stdout;
|
||||
}
|
||||
|
||||
vsprintf(temp, fmt, ap);
|
||||
fprintf(stdlog, "%s", temp);
|
||||
fflush(stdlog);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/* Log a fatal error, and display a UI message before exiting. */
|
||||
void
|
||||
fatal(const char *fmt, ...)
|
||||
{
|
||||
char temp[1024];
|
||||
char temp[LOG_SIZE_BUFFER];
|
||||
va_list ap;
|
||||
char *sp;
|
||||
|
||||
@@ -438,7 +461,7 @@ fatal(const char *fmt, ...)
|
||||
void
|
||||
fatal_ex(const char *fmt, va_list ap)
|
||||
{
|
||||
char temp[1024];
|
||||
char temp[LOG_SIZE_BUFFER];
|
||||
char *sp;
|
||||
|
||||
if (stdlog == NULL) {
|
||||
@@ -481,7 +504,7 @@ fatal_ex(const char *fmt, va_list ap)
|
||||
void
|
||||
warning(const char *fmt, ...)
|
||||
{
|
||||
char temp[1024];
|
||||
char temp[LOG_SIZE_BUFFER];
|
||||
va_list ap;
|
||||
char *sp;
|
||||
|
||||
@@ -517,7 +540,7 @@ warning(const char *fmt, ...)
|
||||
void
|
||||
warning_ex(const char *fmt, va_list ap)
|
||||
{
|
||||
char temp[1024];
|
||||
char temp[LOG_SIZE_BUFFER];
|
||||
char *sp;
|
||||
|
||||
if (stdlog == NULL) {
|
||||
@@ -594,13 +617,15 @@ extern void device_find_all_descs(void);
|
||||
static void
|
||||
pc_show_usage(char *s)
|
||||
{
|
||||
char p[4096] = { 0 };
|
||||
char p[8192] = { 0 };
|
||||
|
||||
sprintf(p,
|
||||
"\n%sUsage: 86box [options] [cfg-file]\n\n"
|
||||
"Valid options are:\n\n"
|
||||
"-? or --help\t\t\t- show this information\n"
|
||||
#ifdef SHOW_EXTRA_PARAMS
|
||||
"-C or --config path\t\t- set 'path' to be config file\n"
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
"-D or --debug\t\t\t- force debug output logging\n"
|
||||
#endif
|
||||
@@ -610,38 +635,47 @@ pc_show_usage(char *s)
|
||||
"-F or --fullscreen\t\t- start in fullscreen mode\n"
|
||||
"-G or --lang langid\t\t- start with specified language\n"
|
||||
"\t\t\t\t (e.g. en-US, or system)\n"
|
||||
#ifdef SHOW_EXTRA_PARAMS
|
||||
#ifdef _WIN32
|
||||
"-H or --hwnd id,hwnd\t\t- sends back the main dialog's hwnd\n"
|
||||
#endif
|
||||
#endif
|
||||
"-I or --image d:path\t\t- load 'path' as floppy image on drive d\n"
|
||||
#ifdef USE_INSTRUMENT
|
||||
"-J or --instrument name\t- set 'name' to be the profiling instrument\n"
|
||||
#endif
|
||||
"-L or --logfile pat\t\t- set 'path' to be the logfile\n"
|
||||
"-L or --logfile path\t\t- set 'path' to be the logfile\n"
|
||||
"-M or --missing\t\t- dump missing machines and video cards\n"
|
||||
"-N or --noconfirm\t\t- do not ask for confirmation on quit\n"
|
||||
"-P or --vmpath path\t\t- set 'path' to be root for vm\n"
|
||||
"-O or --global path\t\t- set 'path' to be global config file\n"
|
||||
"-R or --rompath path\t\t- set 'path' to be ROM path\n"
|
||||
#ifndef USE_SDL_UI
|
||||
"-S or --settings\t\t\t- show only the settings dialog\n"
|
||||
#endif
|
||||
#ifdef SHOW_EXTRA_PARAMS
|
||||
"-T or --testmode\t\t- test mode: execute the test mode entry\n"
|
||||
"\t\t\t\t point on init/hard reset\n"
|
||||
#endif
|
||||
"-V or --vmname name\t\t- overrides the name of the running VM\n"
|
||||
#ifdef _WIN32
|
||||
"-W or --nohook\t\t- disables keyboard hook\n"
|
||||
"\t\t\t\t (compatibility-only outside Windows)\n"
|
||||
#else
|
||||
"-W or --nohook\t\t- alters keyboard behavior\n"
|
||||
#endif
|
||||
"-X or --clear what\t\t- clears the 'what' (cmos/flash/both)\n"
|
||||
#ifdef SHOW_EXTRA_PARAMS
|
||||
"-Y or --donothing\t\t- do not show any UI or run the emulation\n"
|
||||
"-Z or --lastvmpath\t\t- the last parameter is VM path rather\n"
|
||||
"\t\t\t\t than config\n"
|
||||
#endif
|
||||
"-Z or --lastvmpath\t\t- the last param. is VM path rather than config\n"
|
||||
"\nA config file can be specified. If none is, the default file will be used.\n",
|
||||
(s == NULL) ? "" : s);
|
||||
s);
|
||||
|
||||
#ifdef _WIN32
|
||||
ui_msgbox(MBX_ANSI | ((s == NULL) ? MBX_INFO : MBX_WARNING), p);
|
||||
#else
|
||||
if (s == NULL)
|
||||
pclog("%s", p);
|
||||
always_log("%s", p);
|
||||
else
|
||||
ui_msgbox(MBX_ANSI | MBX_WARNING, p);
|
||||
#endif
|
||||
@@ -660,6 +694,7 @@ pc_init(int argc, char *argv[])
|
||||
char *ppath = NULL;
|
||||
char *rpath = NULL;
|
||||
char *cfg = NULL;
|
||||
char *global = NULL;
|
||||
char *p;
|
||||
char temp[2048];
|
||||
char *fn[FDD_NUM] = { NULL };
|
||||
@@ -730,7 +765,7 @@ usage:
|
||||
}
|
||||
}
|
||||
|
||||
pc_show_usage(NULL);
|
||||
pc_show_usage("");
|
||||
return 0;
|
||||
} else if (!strcasecmp(argv[c], "--lastvmpath") || !strcasecmp(argv[c], "-Z")) {
|
||||
lvmp = 1;
|
||||
@@ -779,6 +814,11 @@ usage:
|
||||
#ifdef DEPRECATE_USAGE
|
||||
deprecated = 0;
|
||||
#endif
|
||||
} else if (!strcasecmp(argv[c], "--global") || !strcasecmp(argv[c], "-O")) {
|
||||
if ((c + 1) == argc || plat_dir_check(argv[c + 1]))
|
||||
goto usage;
|
||||
|
||||
global = argv[++c];
|
||||
} else if (!strcasecmp(argv[c], "--image") || !strcasecmp(argv[c], "-I")) {
|
||||
if ((c + 1) == argc)
|
||||
goto usage;
|
||||
@@ -851,7 +891,7 @@ usage:
|
||||
|
||||
lang_init = plat_language_code(argv[++c]);
|
||||
if (!lang_init)
|
||||
printf("\nWarning: Invalid language code, ignoring --lang parameter.\n\n");
|
||||
always_log("\nWarning: Invalid language code, ignoring --lang parameter.\n\n");
|
||||
|
||||
// The return value of 0 only means that the code is invalid,
|
||||
// not related to that translation is exists or not for the
|
||||
@@ -1010,6 +1050,14 @@ usage:
|
||||
/* At this point, we can safely create the full path name. */
|
||||
path_append_filename(cfg_path, usr_path, p);
|
||||
|
||||
/* Build the global configuration file path. */
|
||||
if (global == NULL) {
|
||||
plat_get_global_config_dir(global_cfg_path, sizeof(global_cfg_path));
|
||||
path_append_filename(global_cfg_path, global_cfg_path, CONFIG_FILE);
|
||||
} else {
|
||||
strncpy(global_cfg_path, global, sizeof(global_cfg_path) - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the current directory's name
|
||||
*
|
||||
@@ -1051,52 +1099,56 @@ usage:
|
||||
pclog("# ROM path: %s\n", rom_path->path);
|
||||
}
|
||||
|
||||
pclog("# Global configuration file: %s\n", global_cfg_path);
|
||||
pclog("# Configuration file: %s\n#\n\n", cfg_path);
|
||||
if (strlen(vmm_path) != 0) {
|
||||
vmm_enabled = 1;
|
||||
pclog("# VM Manager enabled. Path: %s\n", vmm_path);
|
||||
}
|
||||
/*
|
||||
* We are about to read the configuration file, which MAY
|
||||
* put data into global variables (the hard- and floppy
|
||||
* disks are an example) so we have to initialize those
|
||||
* modules before we load the config..
|
||||
*/
|
||||
hdd_init();
|
||||
network_init();
|
||||
mouse_init();
|
||||
cdrom_global_init();
|
||||
zip_global_init();
|
||||
mo_global_init();
|
||||
|
||||
/* Initialize the keyboard accelerator list with default values */
|
||||
for (int x = 0; x < NUM_ACCELS; x++) {
|
||||
strcpy(acc_keys[x].name, def_acc_keys[x].name);
|
||||
strcpy(acc_keys[x].desc, def_acc_keys[x].desc);
|
||||
strcpy(acc_keys[x].seq, def_acc_keys[x].seq);
|
||||
}
|
||||
if (!vmm_enabled) {
|
||||
/*
|
||||
* We are about to read the configuration file, which MAY
|
||||
* put data into global variables (the hard- and floppy
|
||||
* disks are an example) so we have to initialize those
|
||||
* modules before we load the config..
|
||||
*/
|
||||
hdd_init();
|
||||
network_init();
|
||||
mouse_init();
|
||||
cdrom_global_init();
|
||||
rdisk_global_init();
|
||||
mo_global_init();
|
||||
|
||||
/* Load the configuration file. */
|
||||
config_load();
|
||||
/* Initialize the keyboard accelerator list with default values */
|
||||
for (int x = 0; x < NUM_ACCELS; x++) {
|
||||
strcpy(acc_keys[x].name, def_acc_keys[x].name);
|
||||
strcpy(acc_keys[x].desc, def_acc_keys[x].desc);
|
||||
strcpy(acc_keys[x].seq, def_acc_keys[x].seq);
|
||||
}
|
||||
|
||||
/* Clear the CMOS and/or BIOS flash file, if we were started with
|
||||
the relevant parameter(s). */
|
||||
if (clear_cmos) {
|
||||
delete_nvr_file(0);
|
||||
clear_cmos = 0;
|
||||
}
|
||||
/* Load the configuration file. */
|
||||
config_load();
|
||||
|
||||
if (clear_flash) {
|
||||
delete_nvr_file(1);
|
||||
clear_flash = 0;
|
||||
}
|
||||
/* Clear the CMOS and/or BIOS flash file, if we were started with
|
||||
the relevant parameter(s). */
|
||||
if (clear_cmos) {
|
||||
delete_nvr_file(0);
|
||||
clear_cmos = 0;
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < FDD_NUM; i++) {
|
||||
if (fn[i] != NULL) {
|
||||
if (strlen(fn[i]) <= 511)
|
||||
strncpy(floppyfns[i], fn[i], 511);
|
||||
free(fn[i]);
|
||||
fn[i] = NULL;
|
||||
if (clear_flash) {
|
||||
delete_nvr_file(1);
|
||||
clear_flash = 0;
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < FDD_NUM; i++) {
|
||||
if (fn[i] != NULL) {
|
||||
if (strlen(fn[i]) <= 511)
|
||||
strncpy(floppyfns[i], fn[i], 511);
|
||||
free(fn[i]);
|
||||
fn[i] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1262,6 +1314,11 @@ pc_init_modules(void)
|
||||
|
||||
machine_status_init();
|
||||
|
||||
serial_set_next_inst(0);
|
||||
|
||||
lpt_set_3bc_used(0);
|
||||
lpt_set_next_inst(0);
|
||||
|
||||
for (c = 0; c <= 0x7ff; c++) {
|
||||
int64_t exp = c - 1023; /* 1023 = BIAS64 */
|
||||
exp_pow_table[c] = pow(2.0, (double) exp);
|
||||
@@ -1376,10 +1433,6 @@ pc_reset_hard_close(void)
|
||||
|
||||
lpt_devices_close();
|
||||
|
||||
#ifdef UNCOMMENT_LATER
|
||||
lpt_close();
|
||||
#endif
|
||||
|
||||
nvr_save();
|
||||
nvr_close();
|
||||
|
||||
@@ -1395,7 +1448,7 @@ pc_reset_hard_close(void)
|
||||
|
||||
cdrom_close();
|
||||
|
||||
zip_close();
|
||||
rdisk_close();
|
||||
|
||||
mo_close();
|
||||
|
||||
@@ -1408,6 +1461,9 @@ pc_reset_hard_close(void)
|
||||
cpu_close();
|
||||
|
||||
serial_set_next_inst(0);
|
||||
|
||||
lpt_set_3bc_used(0);
|
||||
lpt_set_next_inst(0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1446,6 +1502,8 @@ pc_reset_hard_init(void)
|
||||
scsi_reset();
|
||||
scsi_device_init();
|
||||
|
||||
ide_hard_reset();
|
||||
|
||||
/* Initialize the actual machine and its basic modules. */
|
||||
machine_init();
|
||||
|
||||
@@ -1467,6 +1525,7 @@ pc_reset_hard_init(void)
|
||||
|
||||
/* Initialize parallel devices. */
|
||||
/* note: PLIP LPT side has to be initialized before the network side */
|
||||
lpt_standalone_init();
|
||||
lpt_devices_init();
|
||||
|
||||
/* Reset and reconfigure the serial ports. */
|
||||
@@ -1489,9 +1548,6 @@ pc_reset_hard_init(void)
|
||||
|
||||
fdd_reset();
|
||||
|
||||
/* Reset the CD-ROM Controller module. */
|
||||
cdrom_interface_reset();
|
||||
|
||||
/* Reset and reconfigure the SCSI layer. */
|
||||
scsi_card_init();
|
||||
|
||||
@@ -1499,9 +1555,12 @@ pc_reset_hard_init(void)
|
||||
|
||||
cdrom_hard_reset();
|
||||
|
||||
/* Reset the CD-ROM Controller module. */
|
||||
cdrom_interface_reset();
|
||||
|
||||
mo_hard_reset();
|
||||
|
||||
zip_hard_reset();
|
||||
rdisk_hard_reset();
|
||||
|
||||
|
||||
/* Reset any ISA ROM cards. */
|
||||
@@ -1664,7 +1723,7 @@ pc_close(UNUSED(thread_t *ptr))
|
||||
|
||||
cdrom_close();
|
||||
|
||||
zip_close();
|
||||
rdisk_close();
|
||||
|
||||
mo_close();
|
||||
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
# Copyright 2024 Jasmine Iwanek.
|
||||
#
|
||||
|
||||
if(NOT CMAKE_TOP_LEVEL_PROCESSED)
|
||||
message(FATAL_ERROR "Incorrect source directory specified. Delete your build directory and retry with the top-level directory instead")
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
endif()
|
||||
@@ -99,7 +103,7 @@ if(INSTRUMENT)
|
||||
add_compile_definitions(USE_INSTRUMENT)
|
||||
endif()
|
||||
|
||||
target_link_libraries(86Box cpu chipset mch dev mem fdd game cdrom zip mo hdd
|
||||
target_link_libraries(86Box cpu chipset mch dev mem fdd game cdrom rdisk mo hdd
|
||||
net print scsi sio snd utils vid voodoo plat ui)
|
||||
|
||||
if(HAIKU)
|
||||
@@ -149,16 +153,6 @@ if(APPLE)
|
||||
target_link_libraries(86Box Freetype::Freetype)
|
||||
endif()
|
||||
|
||||
find_package(SDL2 REQUIRED)
|
||||
include_directories(${SDL2_INCLUDE_DIRS})
|
||||
if(STATIC_BUILD AND TARGET SDL2::SDL2-static)
|
||||
target_link_libraries(86Box SDL2::SDL2-static)
|
||||
elseif(TARGET SDL2::SDL2)
|
||||
target_link_libraries(86Box SDL2::SDL2)
|
||||
else()
|
||||
target_link_libraries(86Box ${SDL2_LIBRARIES})
|
||||
endif()
|
||||
|
||||
find_package(PNG REQUIRED)
|
||||
include_directories(${PNG_INCLUDE_DIRS})
|
||||
target_link_libraries(86Box PNG::PNG)
|
||||
|
||||
40
src/acpi.c
40
src/acpi.c
@@ -2373,26 +2373,32 @@ acpi_reset(void *priv)
|
||||
dev->regs.gporeg[i] = dev->gporeg_default[i];
|
||||
if (dev->vendor == VEN_VIA_596B) {
|
||||
dev->regs.gpo_val = 0x7fffffff;
|
||||
/* FIC VA-503A:
|
||||
- Bit 11: ATX power (active high)
|
||||
- Bit 4: 80-conductor cable on primary IDE channel (active low)
|
||||
- Bit 3: 80-conductor cable on secondary IDE channel (active low)
|
||||
- Bit 2: password cleared (active low)
|
||||
ASUS P3V4X:
|
||||
- Bit 15: 80-conductor cable on secondary IDE channel (active low)
|
||||
- Bit 5: 80-conductor cable on primary IDE channel (active low)
|
||||
BCM GT694VA:
|
||||
- Bit 19: 80-conductor cable on secondary IDE channel (active low)
|
||||
- Bit 17: 80-conductor cable on primary IDE channel (active low)
|
||||
ASUS CUV4X-LS:
|
||||
- Bit 2: 80-conductor cable on secondary IDE channel (active low)
|
||||
- Bit 1: 80-conductor cable on primary IDE channel (active low)
|
||||
Acorp 6VIA90AP:
|
||||
- Bit 3: 80-conductor cable on secondary IDE channel (active low)
|
||||
- Bit 1: 80-conductor cable on primary IDE channel (active low) */
|
||||
/*
|
||||
- FIC VA-503A:
|
||||
- Bit 11: ATX power (active high);
|
||||
- Bit 4: 80-conductor cable on primary IDE channel (active low);
|
||||
- Bit 3: 80-conductor cable on secondary IDE channel (active low);
|
||||
- Bit 2: password cleared (active low).
|
||||
- ASUS P3V4X:
|
||||
- Bit 15: 80-conductor cable on secondary IDE channel (active low);
|
||||
- Bit 5: 80-conductor cable on primary IDE channel (active low).
|
||||
- BCM GT694VA:
|
||||
- Bit 19: 80-conductor cable on secondary IDE channel (active low);
|
||||
- Bit 17: 80-conductor cable on primary IDE channel (active low).
|
||||
- ASUS CUV4X-LS:
|
||||
- Bit 2: 80-conductor cable on secondary IDE channel (active low);
|
||||
- Bit 1: 80-conductor cable on primary IDE channel (active low).
|
||||
- Acorp 6VIA90AP:
|
||||
- Bit 3: 80-conductor cable on secondary IDE channel (active low);
|
||||
- Bit 1: 80-conductor cable on primary IDE channel (active low).
|
||||
- FIC KA-6130:
|
||||
- Bit 19: password cleared (active low).
|
||||
*/
|
||||
dev->regs.gpi_val = 0xfff57fc1;
|
||||
if (!strcmp(machine_get_internal_name(), "ficva503a") || !strcmp(machine_get_internal_name(), "6via90ap"))
|
||||
dev->regs.gpi_val |= 0x00000004;
|
||||
else if (!strcmp(machine_get_internal_name(), "ficka6130"))
|
||||
dev->regs.gpi_val |= 0x00080000;
|
||||
/*
|
||||
TriGem Delhi-III second GPI word:
|
||||
- Bit 7 = Save CMOS (must be set);
|
||||
|
||||
@@ -23,6 +23,7 @@ add_library(cdrom OBJECT
|
||||
cdrom.c
|
||||
cdrom_image.c
|
||||
cdrom_image_viso.c
|
||||
cdrom_mke.c
|
||||
)
|
||||
target_link_libraries(86Box PkgConfig::SNDFILE)
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#ifdef USE_CDROM_MITSUMI
|
||||
#include <86box/cdrom_mitsumi.h>
|
||||
#endif
|
||||
#include <86box/cdrom_mke.h>
|
||||
#include <86box/log.h>
|
||||
#include <86box/plat.h>
|
||||
#include <86box/plat_cdrom_ioctl.h>
|
||||
@@ -121,8 +122,10 @@ static const struct {
|
||||
// clang-format off
|
||||
{ &cdrom_interface_none_device },
|
||||
#ifdef USE_CDROM_MITSUMI
|
||||
{ &mitsumi_cdrom_device },
|
||||
{ &mitsumi_cdrom_device },
|
||||
#endif
|
||||
{ &mke_cdrom_noncreative_device },
|
||||
{ &mke_cdrom_device },
|
||||
{ NULL }
|
||||
// clang-format on
|
||||
};
|
||||
@@ -292,10 +295,80 @@ msf_to_bcd(int *m, int *s, int *f)
|
||||
*f = bin2bcd(*f);
|
||||
}
|
||||
|
||||
static int
|
||||
read_data(cdrom_t *dev, const uint32_t lba)
|
||||
void
|
||||
cdrom_compute_ecc_block(cdrom_t *dev, uint8_t *parity, const uint8_t *data,
|
||||
uint32_t major_count, uint32_t minor_count,
|
||||
uint32_t major_mult, uint32_t minor_inc, int m2f1)
|
||||
{
|
||||
int ret = 1;
|
||||
uint32_t size = major_count * minor_count;
|
||||
|
||||
for (uint32_t major = 0; major < major_count; ++major) {
|
||||
uint32_t index = (major >> 1) * major_mult + (major & 1);
|
||||
|
||||
uint8_t ecc_a = 0;
|
||||
uint8_t ecc_b = 0;
|
||||
|
||||
for (uint32_t minor = 0; minor < minor_count; ++minor) {
|
||||
uint8_t temp = data[index];
|
||||
|
||||
if (m2f1 && (index < 4))
|
||||
temp = 0x00;
|
||||
|
||||
index += minor_inc;
|
||||
|
||||
if (index >= size)
|
||||
index -= size;
|
||||
|
||||
ecc_a ^= temp;
|
||||
ecc_b ^= temp;
|
||||
ecc_a = dev->_F_LUT[ecc_a];
|
||||
}
|
||||
|
||||
parity[major] = dev->_B_LUT[dev->_F_LUT[ecc_a] ^ ecc_b];
|
||||
parity[major + major_count] = parity[major] ^ ecc_b;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cdrom_generate_ecc_data(cdrom_t *dev, const uint8_t *data, int m2f1)
|
||||
{
|
||||
/* Compute ECC P code. */
|
||||
cdrom_compute_ecc_block(dev, dev->p_parity, data, 86, 24, 2, 86, m2f1);
|
||||
|
||||
/* Compute ECC Q code. */
|
||||
cdrom_compute_ecc_block(dev, dev->q_parity, data, 52, 43, 86, 88, m2f1);
|
||||
}
|
||||
|
||||
static int
|
||||
cdrom_is_sector_good(cdrom_t *dev, const uint8_t *b, const uint8_t mode2, const uint8_t form)
|
||||
{
|
||||
int ret = 1;
|
||||
|
||||
if (!mode2 || (form != 1)) {
|
||||
if (mode2 && (form == 1)) {
|
||||
const uint32_t crc = cdrom_crc32(0xffffffff, &(b[16]), 2056) ^ 0xffffffff;
|
||||
|
||||
ret = ret && (crc == (*(uint32_t *) &(b[2072])));
|
||||
} else if (!mode2) {
|
||||
const uint32_t crc = cdrom_crc32(0xffffffff, b, 2064) ^ 0xffffffff;
|
||||
|
||||
ret = ret && (crc == (*(uint32_t *) &(b[2064])));
|
||||
}
|
||||
|
||||
cdrom_generate_ecc_data(dev, &(b[12]), mode2 && (form == 1));
|
||||
|
||||
ret = ret && !memcmp(dev->p_parity, &(b[2076]), 172);
|
||||
ret = ret && !memcmp(dev->q_parity, &(b[2248]), 104);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
read_data(cdrom_t *dev, const uint32_t lba, int check)
|
||||
{
|
||||
int ret = 1;
|
||||
int form = 0;
|
||||
|
||||
if (dev->cached_sector != lba) {
|
||||
dev->cached_sector = lba;
|
||||
@@ -303,6 +376,25 @@ read_data(cdrom_t *dev, const uint32_t lba)
|
||||
ret = dev->ops->read_sector(dev->local,
|
||||
dev->raw_buffer[dev->cur_buf ^ 1], lba);
|
||||
|
||||
if ((ret > 0) && check) {
|
||||
if (dev->mode2) {
|
||||
if (dev->raw_buffer[dev->cur_buf ^ 1][0x000f] == 0x01)
|
||||
/*
|
||||
Use Mode 1, since evidently specification-violating
|
||||
discs exist.
|
||||
*/
|
||||
dev->mode2 = 0;
|
||||
else if (dev->raw_buffer[dev->cur_buf ^ 1][0x0012] ==
|
||||
dev->raw_buffer[dev->cur_buf ^ 1][0x0016])
|
||||
form = ((dev->raw_buffer[dev->cur_buf ^ 1][0x0012] &
|
||||
0x20) >> 5) + 1;
|
||||
} else if (dev->raw_buffer[dev->cur_buf ^ 1][0x000f] == 0x02)
|
||||
dev->mode2 = 1;
|
||||
|
||||
if (!cdrom_is_sector_good(dev, dev->raw_buffer[dev->cur_buf ^ 1], dev->mode2, form))
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
if (ret <= 0) {
|
||||
memset(dev->raw_buffer[dev->cur_buf ^ 1], 0x00, 2448);
|
||||
dev->cached_sector = -1;
|
||||
@@ -322,7 +414,7 @@ cdrom_get_subchannel(cdrom_t *dev, const uint32_t lba,
|
||||
if (lba != dev->cached_sector)
|
||||
dev->cached_sector = -1;
|
||||
|
||||
(void) read_data(dev, lba);
|
||||
(void) read_data(dev, lba, 0);
|
||||
|
||||
for (int i = 0; i < 12; i++)
|
||||
for (int j = 0; j < 8; j++)
|
||||
@@ -679,7 +771,7 @@ track_type_is_valid(UNUSED(const cdrom_t *dev), const int type, const int flags,
|
||||
static int
|
||||
read_audio(cdrom_t *dev, const uint32_t lba, uint8_t *b)
|
||||
{
|
||||
const int ret = read_data(dev, lba);
|
||||
const int ret = read_data(dev, lba, 0);
|
||||
|
||||
memcpy(b, dev->raw_buffer[dev->cur_buf], 2352);
|
||||
|
||||
@@ -1100,6 +1192,12 @@ cdrom_is_early(const int type)
|
||||
return (cdrom_drive_types[type].scsi_std == 1);
|
||||
}
|
||||
|
||||
int
|
||||
cdrom_is_dvd(const int type)
|
||||
{
|
||||
return (cdrom_drive_types[type].is_dvd == 1);
|
||||
}
|
||||
|
||||
int
|
||||
cdrom_is_generic(const int type)
|
||||
{
|
||||
@@ -1151,6 +1249,26 @@ cdrom_get_type_count(void)
|
||||
return count;
|
||||
}
|
||||
|
||||
void
|
||||
cdrom_generate_name_mke(const int type, char *name)
|
||||
{
|
||||
char elements[2][512] = { 0 };
|
||||
|
||||
memcpy(elements[0], cdrom_drive_types[type].model,
|
||||
strlen(cdrom_drive_types[type].model) + 1);
|
||||
char *s = strstr(elements[0], " ");
|
||||
if (s != NULL)
|
||||
s[0] = 0x00;
|
||||
|
||||
memcpy(elements[1], cdrom_drive_types[type].revision,
|
||||
strlen(cdrom_drive_types[type].revision) + 1);
|
||||
s = strstr(elements[1], " ");
|
||||
if (s != NULL)
|
||||
s[0] = 0x00;
|
||||
|
||||
sprintf(name, "%s%s", elements[0], elements[1]);
|
||||
}
|
||||
|
||||
void
|
||||
cdrom_get_identify_model(const int type, char *name, const int id)
|
||||
{
|
||||
@@ -1589,7 +1707,7 @@ cdrom_audio_track_search(cdrom_t *dev, const uint32_t pos,
|
||||
dev->seek_pos = MSFtoLBA(ti.m, ti.s, ti.f) - 150;
|
||||
else {
|
||||
cdrom_log(dev->log, "Unable to get the starting position for "
|
||||
"track %08X\n", ismsf & 0xff);
|
||||
"track %08X\n", pos2 & 0xff);
|
||||
cdrom_stop(dev);
|
||||
}
|
||||
break;
|
||||
@@ -1707,7 +1825,7 @@ cdrom_audio_play_toshiba(cdrom_t *dev, const uint32_t pos, const int type)
|
||||
dev->cd_end = MSFtoLBA(ti.m, ti.s, ti.f) - 150;
|
||||
else {
|
||||
cdrom_log(dev->log, "Unable to get the starting position for "
|
||||
"track %08X\n", ismsf & 0xff);
|
||||
"track %08X\n", pos2 & 0xff);
|
||||
cdrom_stop(dev);
|
||||
}
|
||||
break;
|
||||
@@ -1740,7 +1858,7 @@ cdrom_audio_scan(cdrom_t *dev, const uint32_t pos)
|
||||
uint8_t ret = 0;
|
||||
|
||||
if (dev->cd_status & CD_STATUS_HAS_AUDIO) {
|
||||
cdrom_log(dev->log, "Audio Scan: MSF = %06x, type = %02x\n", pos, type);
|
||||
cdrom_log(dev->log, "Audio Scan: MSF = %06x\n", pos);
|
||||
|
||||
if (pos == 0xffffffff) {
|
||||
cdrom_log(dev->log, "(Type 0) Search from current position\n");
|
||||
@@ -2009,9 +2127,10 @@ cdrom_get_current_subcodeq_playstatus(cdrom_t *dev, uint8_t *b)
|
||||
cdrom_get_current_subcodeq(dev, b);
|
||||
|
||||
switch (dev->cd_status) {
|
||||
default: case CD_STATUS_EMPTY:
|
||||
case CD_STATUS_DATA_ONLY: case CD_STATUS_DVD:
|
||||
case CD_STATUS_STOPPED: case CD_STATUS_PLAYING_COMPLETED:
|
||||
default: case CD_STATUS_EMPTY:
|
||||
case CD_STATUS_DATA_ONLY: case CD_STATUS_DVD:
|
||||
case CD_STATUS_STOPPED: case CD_STATUS_PLAYING_COMPLETED:
|
||||
case CD_STATUS_DVD_REJECTED:
|
||||
ret = 0x03;
|
||||
break;
|
||||
case CD_STATUS_HOLD:
|
||||
@@ -2360,7 +2479,7 @@ cdrom_readsector_raw(cdrom_t *dev, uint8_t *buffer, const int sector, const int
|
||||
ecc_diff = 0;
|
||||
}
|
||||
|
||||
if (dev->cd_status != CD_STATUS_EMPTY) {
|
||||
if ((dev->cd_status != CD_STATUS_EMPTY) && (dev->cd_status != CD_STATUS_DVD_REJECTED)) {
|
||||
uint8_t *temp_b;
|
||||
uint8_t *b = temp_b = buffer;
|
||||
int audio = 0;
|
||||
@@ -2379,6 +2498,8 @@ cdrom_readsector_raw(cdrom_t *dev, uint8_t *buffer, const int sector, const int
|
||||
if (dm != CD_TRACK_NORMAL)
|
||||
mode2 = 1;
|
||||
|
||||
dev->mode2 = mode2;
|
||||
|
||||
memset(dev->extra_buffer, 0, 296);
|
||||
|
||||
if ((cdrom_sector_flags & 0xf8) == 0x08) {
|
||||
@@ -2405,7 +2526,7 @@ cdrom_readsector_raw(cdrom_t *dev, uint8_t *buffer, const int sector, const int
|
||||
else
|
||||
ret = read_audio(dev, lba, temp_b);
|
||||
} else {
|
||||
ret = read_data(dev, lba);
|
||||
ret = read_data(dev, lba, 1);
|
||||
|
||||
/* Return with error if we had one. */
|
||||
if (ret > 0) {
|
||||
@@ -2800,7 +2921,7 @@ cdrom_read_track_information(cdrom_t *dev, const uint8_t *cdb, uint8_t *buffer)
|
||||
}
|
||||
|
||||
if (track->adr_ctl & 0x04) {
|
||||
ret = read_data(dev, start);
|
||||
ret = read_data(dev, start, 0);
|
||||
mode = dev->raw_buffer[dev->cur_buf][3];
|
||||
}
|
||||
} else if (track->point != 0xa2)
|
||||
@@ -2829,9 +2950,9 @@ uint8_t
|
||||
cdrom_get_current_mode(cdrom_t *dev)
|
||||
{
|
||||
if (dev->cached_sector == -1)
|
||||
(void) read_data(dev, dev->seek_pos);
|
||||
(void) read_data(dev, dev->seek_pos, 0);
|
||||
else
|
||||
(void) read_data(dev, dev->cached_sector);
|
||||
(void) read_data(dev, dev->cached_sector, 0);
|
||||
|
||||
return dev->raw_buffer[dev->cur_buf][3];
|
||||
}
|
||||
@@ -2864,7 +2985,7 @@ cdrom_update_status(cdrom_t *dev)
|
||||
dev->cached_sector = -1;
|
||||
dev->cdrom_capacity = dev->ops->get_last_block(dev->local);
|
||||
|
||||
if (dev->cd_status != CD_STATUS_EMPTY) {
|
||||
if ((dev->cd_status != CD_STATUS_EMPTY) && (dev->cd_status != CD_STATUS_DVD_REJECTED)) {
|
||||
/* Signal media change to the emulated machine. */
|
||||
cdrom_insert(dev->id);
|
||||
|
||||
@@ -2906,9 +3027,14 @@ cdrom_load(cdrom_t *dev, const char *fn, const int skip_insert)
|
||||
|
||||
if ((dev->ops->is_empty != NULL) && dev->ops->is_empty(dev->local))
|
||||
dev->cd_status = CD_STATUS_EMPTY;
|
||||
else if (dev->ops->is_dvd(dev->local))
|
||||
dev->cd_status = CD_STATUS_DVD;
|
||||
else
|
||||
else if (dev->ops->is_dvd(dev->local)) {
|
||||
if (cdrom_is_dvd(dev->type))
|
||||
dev->cd_status = CD_STATUS_DVD;
|
||||
else {
|
||||
warning("DVD image \"%s\" in a CD-only drive, reporting as empty\n", fn);
|
||||
dev->cd_status = CD_STATUS_DVD_REJECTED;
|
||||
}
|
||||
} else
|
||||
dev->cd_status = dev->ops->has_audio(dev->local) ? CD_STATUS_STOPPED :
|
||||
CD_STATUS_DATA_ONLY;
|
||||
|
||||
@@ -2922,7 +3048,7 @@ cdrom_load(cdrom_t *dev, const char *fn, const int skip_insert)
|
||||
cdrom_toc_dump(dev);
|
||||
#endif
|
||||
|
||||
if (!skip_insert && (dev->cd_status != CD_STATUS_EMPTY)) {
|
||||
if (!skip_insert && (dev->cd_status != CD_STATUS_EMPTY) && (dev->cd_status != CD_STATUS_DVD_REJECTED)) {
|
||||
/* Signal media change to the emulated machine. */
|
||||
cdrom_insert(dev->id);
|
||||
|
||||
@@ -3011,6 +3137,11 @@ cdrom_hard_reset(void)
|
||||
|
||||
cdrom_load(dev, dev->image_path, 0);
|
||||
}
|
||||
|
||||
for (uint32_t j = 0; j < _LUT_SIZE; ++j) {
|
||||
dev->_F_LUT[j] = (j << 1) ^ (j & 0x80 ? 0x11d : 0);
|
||||
dev->_B_LUT[j ^ dev->_F_LUT[j]] = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include <sys/stat.h>
|
||||
#ifndef _WIN32
|
||||
# include <libgen.h>
|
||||
@@ -84,17 +85,148 @@ typedef struct track_t {
|
||||
track_index_t idx[3];
|
||||
} track_t;
|
||||
|
||||
/*
|
||||
MDS for DVD has the disc structure table - 4 byte pointer to BCA,
|
||||
followed by the copyright, DMI, and layer pages.
|
||||
*/
|
||||
#pragma pack(push, 1)
|
||||
typedef struct
|
||||
{
|
||||
uint8_t f1[4];
|
||||
uint8_t f4[2048];
|
||||
uint8_t f0[2048];
|
||||
} layer_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
layer_t layers[2];
|
||||
} mds_disc_struct_t;
|
||||
#pragma pack(pop)
|
||||
|
||||
#define dstruct_t mds_disc_struct_t
|
||||
|
||||
typedef struct cd_image_t {
|
||||
cdrom_t *dev;
|
||||
void *log;
|
||||
int is_dvd;
|
||||
int has_audio;
|
||||
int has_dstruct;
|
||||
int32_t tracks_num;
|
||||
uint32_t bad_sectors_num;
|
||||
track_t *tracks;
|
||||
uint32_t *bad_sectors;
|
||||
dstruct_t dstruct;
|
||||
} cd_image_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CD = 0x00, /* CD-ROM */
|
||||
CD_R = 0x01, /* CD-R */
|
||||
CD_RW = 0x02, /* CD-RW */
|
||||
DVD = 0x10, /* DVD-ROM */
|
||||
DVD_MINUS_R = 0x12 /* DVD-R */
|
||||
} mds_medium_type_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
UNKNOWN = 0x00,
|
||||
AUDIO = 0xa9, /* sector size = 2352 */
|
||||
MODE1 = 0xaa, /* sector size = 2048 */
|
||||
MODE2 = 0xab, /* sector size = 2336 */
|
||||
MODE2_FORM1 = 0xac, /* sector size = 2048 */
|
||||
MODE2_FORM2 = 0xad /* sector size = 2324 (+4) */
|
||||
} mds_trk_mode_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NONE = 0x00, /* no subchannel */
|
||||
PW_INTERLEAVED = 0x08 /* 96-byte PW subchannel, interleaved */
|
||||
} mds_subch_mode_t;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
typedef struct
|
||||
{
|
||||
uint8_t file_sig[16];
|
||||
uint8_t file_ver[2];
|
||||
uint16_t medium_type;
|
||||
uint16_t sess_num;
|
||||
uint16_t pad[2];
|
||||
uint16_t bca_data_len;
|
||||
uint32_t pad0[2];
|
||||
uint32_t bca_data_offs_offs;
|
||||
uint32_t pad1[6];
|
||||
uint32_t disc_struct_offs;
|
||||
uint32_t pad2[3];
|
||||
uint32_t sess_blocks_offs;
|
||||
uint32_t dpm_blocks_offs;
|
||||
} mds_hdr_t; /* 88 bytes */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t sess_start;
|
||||
int32_t sess_end;
|
||||
uint16_t sess_id;
|
||||
uint8_t all_blocks_num;
|
||||
uint8_t non_track_blocks_num;
|
||||
uint16_t first_trk;
|
||||
uint16_t last_trk;
|
||||
uint32_t pad;
|
||||
uint32_t trk_blocks_offs;
|
||||
} mds_sess_block_t; /* 24 bytes */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t trk_mode;
|
||||
/* DiscImageCreator says this is the number of subchannels. */
|
||||
uint8_t subch_mode;
|
||||
uint8_t adr_ctl;
|
||||
uint8_t track_id;
|
||||
uint8_t point;
|
||||
uint8_t m;
|
||||
uint8_t s;
|
||||
uint8_t f;
|
||||
uint8_t zero;
|
||||
uint8_t pm;
|
||||
uint8_t ps;
|
||||
uint8_t pf;
|
||||
/* DiscImageCreator calls this the index offset. */
|
||||
uint32_t ex_offs;
|
||||
uint16_t sector_len;
|
||||
/* DiscImageCreator says unknown1 followed by 17x zero. */
|
||||
uint8_t pad0[18];
|
||||
uint32_t start_sect;
|
||||
uint64_t start_offs;
|
||||
uint32_t files_num;
|
||||
uint32_t footer_offs;
|
||||
uint8_t pad1[24];
|
||||
} mds_trk_block_t; /* 80 bytes */
|
||||
|
||||
/*
|
||||
DiscImageCreator's interpretation here makes sense and essentially
|
||||
matches libmirage's - Index 0 sectors followed by Index 1 sectors.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t pregap;
|
||||
uint32_t trk_sectors;
|
||||
} mds_trk_ex_block_t; /* 8 bytes */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t fn_offs;
|
||||
uint32_t fn_is_wide;
|
||||
uint32_t pad;
|
||||
uint32_t pad0;
|
||||
} mds_footer_t; /* 16 bytes */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t type;
|
||||
uint32_t pad[2];
|
||||
uint32_t entries;
|
||||
} mds_dpm_block_t;
|
||||
#pragma pack(pop)
|
||||
|
||||
#ifdef ENABLE_IMAGE_LOG
|
||||
int image_do_log = ENABLE_IMAGE_LOG;
|
||||
|
||||
@@ -284,6 +416,9 @@ bin_close(void *priv)
|
||||
|
||||
memset(tf->fn, 0x00, sizeof(tf->fn));
|
||||
|
||||
log_close(tf->log);
|
||||
tf->log = NULL;
|
||||
|
||||
free(priv);
|
||||
}
|
||||
|
||||
@@ -298,6 +433,11 @@ bin_init(const uint8_t id, const char *filename, int *error)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char n[1024] = { 0 };
|
||||
|
||||
sprintf(n, "CD-ROM %i Bin ", id + 1);
|
||||
tf->log = log_open(n);
|
||||
|
||||
memset(tf->fn, 0x00, sizeof(tf->fn));
|
||||
strncpy(tf->fn, filename, sizeof(tf->fn) - 1);
|
||||
tf->fp = plat_fopen64(tf->fn, "rb");
|
||||
@@ -314,11 +454,6 @@ bin_init(const uint8_t id, const char *filename, int *error)
|
||||
tf->read = bin_read;
|
||||
tf->get_length = bin_get_length;
|
||||
tf->close = bin_close;
|
||||
|
||||
char n[1024] = { 0 };
|
||||
|
||||
sprintf(n, "CD-ROM %i Bin ", id + 1);
|
||||
tf->log = log_open(n);
|
||||
} else {
|
||||
/* From the check above, error may still be non-zero if opening a directory.
|
||||
* The error is set for viso to try and open the directory following this function.
|
||||
@@ -326,8 +461,12 @@ bin_init(const uint8_t id, const char *filename, int *error)
|
||||
if ((tf->fp != NULL) && ((stats.st_mode & S_IFMT) == S_IFDIR)) {
|
||||
/* tf is freed by bin_close */
|
||||
bin_close(tf);
|
||||
} else
|
||||
} else {
|
||||
log_close(tf->log);
|
||||
tf->log = NULL;
|
||||
|
||||
free(tf);
|
||||
}
|
||||
tf = NULL;
|
||||
}
|
||||
|
||||
@@ -1183,7 +1322,7 @@ image_process(cd_image_t *img)
|
||||
ct->point, j,
|
||||
cit[ci->type + 2], ci->file_start * ct->sector_size);
|
||||
image_log(img->log, " TOC data: %02X %02X %02X "
|
||||
"%%02X %02X %02X %02X 02X %02X %02X %02X\n",
|
||||
"%02X %02X %02X %02X %02X %02X %02X %02X\n",
|
||||
ct->session, ct->attr, ct->tno, ct->point,
|
||||
ct->extra[0], ct->extra[1], ct->extra[2], ct->extra[3],
|
||||
(uint32_t) ((ci->start / 75) / 60),
|
||||
@@ -1208,12 +1347,12 @@ image_set_track_subch_type(track_t *ct)
|
||||
static int
|
||||
image_load_iso(cd_image_t *img, const char *filename)
|
||||
{
|
||||
track_t *ct = NULL;
|
||||
track_index_t *ci = NULL;
|
||||
track_file_t *tf = NULL;
|
||||
int success = 1;
|
||||
int error = 1;
|
||||
int is_viso = 0;
|
||||
track_t *ct = NULL;
|
||||
track_index_t *ci = NULL;
|
||||
track_file_t *tf = NULL;
|
||||
int success = 1;
|
||||
int error = 1;
|
||||
int is_viso = 0;
|
||||
int sector_sizes[8] = { 2448, 2368, RAW_SECTOR_SIZE, 2336,
|
||||
2332, 2328, 2324, COOKED_SECTOR_SIZE };
|
||||
|
||||
@@ -1308,8 +1447,12 @@ image_load_iso(cd_image_t *img, const char *filename)
|
||||
if (success)
|
||||
image_process(img);
|
||||
else {
|
||||
image_log(img->log, " [ISO ] Unable to open image or folder \"%s\"\n",
|
||||
filename);
|
||||
#ifdef ENABLE_IMAGE_LOG
|
||||
log_warning(img->log, "Unable to open image or folder \"%s\"\n",
|
||||
filename);
|
||||
#else
|
||||
warning("Unable to open image or folder \"%s\"\n", filename);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1446,9 +1589,9 @@ image_load_cue(cd_image_t *img, const char *cuefile)
|
||||
if (last_t != -1) {
|
||||
/*
|
||||
Important: This has to be done like this because pointers
|
||||
change due to realloc.
|
||||
change due to realloc.
|
||||
*/
|
||||
ct = &(img->tracks[t]);
|
||||
ct = &(img->tracks[img->tracks_num - 1]);
|
||||
|
||||
for (int i = 2; i >= 0; i--) {
|
||||
if (ct->idx[i].file == NULL)
|
||||
@@ -1654,11 +1797,436 @@ image_load_cue(cd_image_t *img, const char *cuefile)
|
||||
|
||||
if (success)
|
||||
image_process(img);
|
||||
else {
|
||||
image_log(img->log, " [CUE ] Unable to open Cue sheet \"%s\"\n", cuefile);
|
||||
else
|
||||
#ifdef ENABLE_IMAGE_LOG
|
||||
log_warning(img->log, " [CUE ] Unable to open Cue sheet \"%s\"\n", cuefile);
|
||||
#else
|
||||
warning("Unable to open Cue sheet \"%s\"\n", cuefile);
|
||||
#endif
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
// Converts UTF-16 string into UTF-8 string.
|
||||
// If destination string is NULL returns total number of symbols that would've
|
||||
// been written (without null terminator). However, when actually writing into
|
||||
// destination string, it does include it. So, be sure to allocate extra byte
|
||||
// for destination string.
|
||||
// Params:
|
||||
// u16_str - source UTF-16 string
|
||||
// u16_str_len - length of source UTF-16 string
|
||||
// u8_str - destination UTF-8 string
|
||||
// u8_str_size - size of destination UTF-8 string in bytes
|
||||
// Return value:
|
||||
// 0 on success, -1 if encountered invalid surrogate pair, -2 if
|
||||
// encountered buffer overflow or length of destination UTF-8 string in bytes
|
||||
// (without including the null terminator).
|
||||
long int utf16_to_utf8(const uint16_t *u16_str, size_t u16_str_len,
|
||||
uint8_t *u8_str, size_t u8_str_size)
|
||||
{
|
||||
size_t i = 0, j = 0;
|
||||
|
||||
if (!u8_str) {
|
||||
u8_str_size = u16_str_len * 4;
|
||||
}
|
||||
|
||||
while (i < u16_str_len) {
|
||||
uint32_t codepoint = u16_str[i++];
|
||||
|
||||
// check for surrogate pair
|
||||
if (codepoint >= 0xD800 && codepoint <= 0xDBFF) {
|
||||
uint16_t high_surr = codepoint;
|
||||
uint16_t low_surr = u16_str[i++];
|
||||
|
||||
if (low_surr < 0xDC00 || low_surr > 0xDFFF)
|
||||
return -1;
|
||||
|
||||
codepoint = ((high_surr - 0xD800) << 10) +
|
||||
(low_surr - 0xDC00) + 0x10000;
|
||||
}
|
||||
|
||||
if (codepoint < 0x80) {
|
||||
if (j + 1 > u8_str_size) return -2;
|
||||
|
||||
if (u8_str) u8_str[j] = (char)codepoint;
|
||||
|
||||
j++;
|
||||
} else if (codepoint < 0x800) {
|
||||
if (j + 2 > u8_str_size) return -2;
|
||||
|
||||
if (u8_str) {
|
||||
u8_str[j + 0] = 0xC0 | (codepoint >> 6);
|
||||
u8_str[j + 1] = 0x80 | (codepoint & 0x3F);
|
||||
}
|
||||
|
||||
j += 2;
|
||||
} else if (codepoint < 0x10000) {
|
||||
if (j + 3 > u8_str_size) return -2;
|
||||
|
||||
if (u8_str) {
|
||||
u8_str[j + 0] = 0xE0 | (codepoint >> 12);
|
||||
u8_str[j + 1] = 0x80 | ((codepoint >> 6) & 0x3F);
|
||||
u8_str[j + 2] = 0x80 | (codepoint & 0x3F);
|
||||
}
|
||||
|
||||
j += 3;
|
||||
} else {
|
||||
if (j + 4 > u8_str_size) return -2;
|
||||
|
||||
if (u8_str) {
|
||||
u8_str[j + 0] = 0xF0 | (codepoint >> 18);
|
||||
u8_str[j + 1] = 0x80 | ((codepoint >> 12) & 0x3F);
|
||||
u8_str[j + 2] = 0x80 | ((codepoint >> 6) & 0x3F);
|
||||
u8_str[j + 3] = 0x80 | (codepoint & 0x3F);
|
||||
}
|
||||
|
||||
j += 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (u8_str) {
|
||||
if (j >= u8_str_size) return -2;
|
||||
u8_str[j] = '\0';
|
||||
}
|
||||
|
||||
return (long int)j;
|
||||
}
|
||||
|
||||
static int
|
||||
image_load_mds(cd_image_t *img, const char *mdsfile)
|
||||
{
|
||||
track_t *ct = NULL;
|
||||
track_index_t *ci = NULL;
|
||||
track_file_t *tf = NULL;
|
||||
int is_viso = 0;
|
||||
int last_t = -1;
|
||||
int error;
|
||||
char pathname[MAX_FILENAME_LENGTH];
|
||||
char ofn[2048] = { 0 };
|
||||
|
||||
mds_hdr_t mds_hdr = { 0 };
|
||||
mds_sess_block_t mds_sess_block = { 0 };
|
||||
mds_trk_block_t mds_trk_block = { 0 };
|
||||
mds_trk_ex_block_t mds_trk_ex_block = { 0 };
|
||||
mds_footer_t mds_footer = { 0 };
|
||||
mds_dpm_block_t mds_dpm_block = { 0 };
|
||||
uint32_t mds_dpm_blocks_num = 0x00000000;
|
||||
uint32_t mds_dpm_block_offs = 0x00000000;
|
||||
|
||||
img->tracks = NULL;
|
||||
img->tracks_num = 0;
|
||||
|
||||
/* Get a copy of the filename into pathname, we need it later. */
|
||||
memset(pathname, 0, MAX_FILENAME_LENGTH * sizeof(char));
|
||||
path_get_dirname(pathname, mdsfile);
|
||||
|
||||
/* Open the file. */
|
||||
FILE *fp = plat_fopen(mdsfile, "rb");
|
||||
if (fp == NULL)
|
||||
return 0;
|
||||
|
||||
int success = 0;
|
||||
|
||||
/*
|
||||
Pass 1 - loading the MDS sheet.
|
||||
*/
|
||||
image_log(img->log, "Pass 1 (loading the Media Descriptor Sheet)...\n");
|
||||
img->tracks_num = 0;
|
||||
success = 2;
|
||||
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
fread(&mds_hdr, 1, sizeof(mds_hdr_t), fp);
|
||||
|
||||
if (memcmp(mds_hdr.file_sig, "MEDIA DESCRIPTOR", 16)) {
|
||||
#ifdef ENABLE_IMAGE_LOG
|
||||
log_warning(img->log, " [MDS ] \"%s\"\n is not an actual MDF file",
|
||||
mdsfile);
|
||||
#else
|
||||
warning("\"%s\"\n is not an actual MDF file", mdsfile);
|
||||
#endif
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mds_hdr.file_ver[0] == 0x02) {
|
||||
#ifdef ENABLE_IMAGE_LOG
|
||||
log_warning(img->log, " [MDS ] \"%s\" is a Daemon Tools encrypted MDS which is not supported\n",
|
||||
mdsfile);
|
||||
#else
|
||||
warning("\"%s\" is a Daemon Tools encrypted MDS which is not supported\n", mdsfile);
|
||||
#endif
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
img->is_dvd = (mds_hdr.medium_type >= 0x10);
|
||||
|
||||
if (img->is_dvd) {
|
||||
if (mds_hdr.disc_struct_offs != 0x00) {
|
||||
fseek(fp, mds_hdr.disc_struct_offs, SEEK_SET);
|
||||
fread(&(img->dstruct.layers[0]), 1, sizeof(layer_t), fp);
|
||||
img->has_dstruct = 1;
|
||||
|
||||
if (((img->dstruct.layers[0].f0[2] & 0x60) >> 4) == 0x01) {
|
||||
fseek(fp, mds_hdr.disc_struct_offs, SEEK_SET);
|
||||
fread(&(img->dstruct.layers[1]), 1, sizeof(layer_t), fp);
|
||||
img->has_dstruct++;
|
||||
}
|
||||
}
|
||||
|
||||
for (int t = 0; t < 3; t++) {
|
||||
ct = image_insert_track(img, 1, 0xa0 + t);
|
||||
|
||||
ct->attr = DATA_TRACK;
|
||||
ct->mode = 0;
|
||||
ct->form = 0;
|
||||
ct->tno = 0;
|
||||
ct->subch_type = 0;
|
||||
memset(ct->extra, 0x00, 4);
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
ci = &(ct->idx[i]);
|
||||
ci->type = INDEX_NONE;
|
||||
ci->start = 0;
|
||||
ci->length = 0;
|
||||
ci->file_start = 0;
|
||||
ci->file_length = 0;
|
||||
ci->file = NULL;
|
||||
}
|
||||
|
||||
ci = &(ct->idx[1]);
|
||||
|
||||
if (t < 2)
|
||||
ci->start = (0x01 * 60 * 75) + (0 * 75) + 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (mds_hdr.dpm_blocks_offs != 0x00) {
|
||||
fseek(fp, mds_hdr.dpm_blocks_offs, SEEK_SET);
|
||||
fread(&mds_dpm_blocks_num, 1, sizeof(uint32_t), fp);
|
||||
|
||||
if (mds_dpm_blocks_num > 0) for (int b = 0; b < mds_dpm_blocks_num; b++) {
|
||||
fseek(fp, mds_hdr.dpm_blocks_offs + 4 + (b * 4), SEEK_SET);
|
||||
fread(&mds_dpm_block_offs, 1, sizeof(uint32_t), fp);
|
||||
|
||||
fseek(fp, mds_dpm_block_offs, SEEK_SET);
|
||||
fread(&mds_dpm_block, 1, sizeof(mds_dpm_block_t), fp);
|
||||
|
||||
/* We currently only support the bad sectors block and not (yet) actual DPM. */
|
||||
if (mds_dpm_block.type == 0x00000002) {
|
||||
/* Bad sectors. */
|
||||
img->bad_sectors_num = mds_dpm_block.entries;
|
||||
img->bad_sectors = (uint32_t *) malloc(img->bad_sectors_num * sizeof(uint32_t));
|
||||
fseek(fp, mds_dpm_block_offs + sizeof(mds_dpm_block_t), SEEK_SET);
|
||||
fread(img->bad_sectors, 1, img->bad_sectors_num * sizeof(uint32_t), fp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int s = 0; s < mds_hdr.sess_num; s++) {
|
||||
fseek(fp, mds_hdr.sess_blocks_offs + (s * sizeof(mds_sess_block_t)), SEEK_SET);
|
||||
fread(&mds_sess_block, 1, sizeof(mds_sess_block_t), fp);
|
||||
|
||||
for (int t = 0; t < mds_sess_block.all_blocks_num; t++) {
|
||||
fseek(fp, mds_sess_block.trk_blocks_offs + (t * sizeof(mds_trk_block_t)), SEEK_SET);
|
||||
fread(&mds_trk_block, 1, sizeof(mds_trk_block_t), fp);
|
||||
|
||||
if (last_t != -1) {
|
||||
/*
|
||||
Important: This has to be done like this because pointers
|
||||
change due to realloc.
|
||||
*/
|
||||
ct = &(img->tracks[img->tracks_num - 1]);
|
||||
|
||||
for (int i = 2; i >= 0; i--) {
|
||||
if (ct->idx[i].file == NULL)
|
||||
ct->idx[i].file = tf;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
last_t = mds_trk_block.point;
|
||||
ct = image_insert_track(img, mds_sess_block.sess_id, mds_trk_block.point);
|
||||
|
||||
if (img->is_dvd) {
|
||||
/* DVD images have no extra block - the extra block offset is the track length. */
|
||||
memset(&mds_trk_ex_block, 0x00, sizeof(mds_trk_ex_block_t));
|
||||
mds_trk_ex_block.pregap = 0x00000000;
|
||||
mds_trk_ex_block.trk_sectors = mds_trk_block.ex_offs;
|
||||
} else if (mds_trk_block.ex_offs != 0ULL) {
|
||||
fseek(fp, mds_trk_block.ex_offs, SEEK_SET);
|
||||
fread(&mds_trk_ex_block, 1, sizeof(mds_trk_ex_block), fp);
|
||||
}
|
||||
|
||||
uint32_t astart = mds_trk_block.start_sect - mds_trk_ex_block.pregap;
|
||||
uint32_t aend = astart + mds_trk_ex_block.pregap;
|
||||
uint32_t aend2 = aend + mds_trk_ex_block.trk_sectors;
|
||||
uint32_t astart2 = mds_trk_block.start_sect + mds_trk_ex_block.trk_sectors;
|
||||
|
||||
if (mds_trk_block.footer_offs != 0ULL) for (uint32_t ff = 0; ff < mds_trk_block.files_num; ff++) {
|
||||
fseek(fp, mds_trk_block.footer_offs + (ff * sizeof(mds_footer_t)), SEEK_SET);
|
||||
fread(&mds_footer, 1, sizeof(mds_footer_t), fp);
|
||||
|
||||
uint16_t wfn[2048] = { 0 };
|
||||
char fn[2048] = { 0 };
|
||||
fseek(fp, mds_footer.fn_offs, SEEK_SET);
|
||||
if (mds_footer.fn_is_wide) {
|
||||
int len = 0;
|
||||
for (int i = 0; i < 256; i++) {
|
||||
fread(&(wfn[i]), 1, 2, fp);
|
||||
len++;
|
||||
if (wfn[i] == 0x0000)
|
||||
break;
|
||||
}
|
||||
(void) utf16_to_utf8(wfn, 2048, (uint8_t *) fn, 2048);
|
||||
} else for (int i = 0; i < 512; i++) {
|
||||
fread(&fn[i], 1, 1, fp);
|
||||
if (fn[i] == 0x00)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!stricmp(fn, "*.mdf")) {
|
||||
strcpy(fn, mdsfile);
|
||||
fn[strlen(mdsfile) - 3] = 'm';
|
||||
fn[strlen(mdsfile) - 2] = 'd';
|
||||
fn[strlen(mdsfile) - 1] = 'f';
|
||||
}
|
||||
|
||||
char filename[2048] = { 0 };
|
||||
if (!path_abs(fn))
|
||||
path_append_filename(filename, pathname, fn);
|
||||
else
|
||||
strcpy(filename, fn);
|
||||
|
||||
if (strcmp(ofn, filename) != 0) {
|
||||
tf = index_file_init(img->dev->id, filename, &error, &is_viso);
|
||||
strcpy(ofn, filename);
|
||||
}
|
||||
}
|
||||
|
||||
ct->sector_size = mds_trk_block.sector_len;
|
||||
ct->form = 0;
|
||||
ct->tno = mds_trk_block.track_id;
|
||||
ct->subch_type = mds_trk_block.subch_mode;
|
||||
ct->extra[0] = mds_trk_block.m;
|
||||
ct->extra[1] = mds_trk_block.s;
|
||||
ct->extra[2] = mds_trk_block.f;
|
||||
ct->extra[3] = mds_trk_block.zero;
|
||||
/*
|
||||
Note from DiscImageCreator:
|
||||
|
||||
I hexedited the track mode field with various values and fed it to Alchohol;
|
||||
it seemed that high part of byte had no effect at all; only the lower one
|
||||
affected the mode, in the following manner:
|
||||
00: Mode 2, 01: Audio, 02: Mode 1, 03: Mode 2, 04: Mode 2 Form 1,
|
||||
05: Mode 2 Form 2, 06: UKNONOWN, 07: Mode 2
|
||||
08: Mode 2, 09: Audio, 0A: Mode 1, 0B: Mode 2, 0C: Mode 2 Form 1,
|
||||
0D: Mode 2 Form 2, 0E: UKNONOWN, 0F: Mode 2
|
||||
*/
|
||||
ct->attr = ((mds_trk_block.trk_mode & 0x07) == 0x01) ?
|
||||
AUDIO_TRACK : DATA_TRACK;
|
||||
ct->mode = 0;
|
||||
ct->form = 0;
|
||||
if (((mds_trk_block.trk_mode & 0x07) != 0x01) &&
|
||||
((mds_trk_block.trk_mode & 0x07) != 0x06))
|
||||
ct->mode = ((mds_trk_block.trk_mode & 0x07) != 0x02) + 1;
|
||||
if ((mds_trk_block.trk_mode & 0x06) == 0x04)
|
||||
ct->form = (mds_trk_block.trk_mode & 0x07) - 0x03;
|
||||
if (ct->attr == AUDIO_TRACK)
|
||||
success = 1;
|
||||
|
||||
if (((ct->sector_size == 2336) || (ct->sector_size == 2332)) && (ct->mode == 2) && (ct->form == 1))
|
||||
ct->skip = 8;
|
||||
|
||||
ci = &(ct->idx[0]);
|
||||
if (ct->point < 0xa0) {
|
||||
ci->start = astart + 150;
|
||||
ci->length = mds_trk_ex_block.pregap;
|
||||
}
|
||||
ci->type = (ci->length > 0) ? INDEX_ZERO : INDEX_NONE;
|
||||
ci->file_start = 0;
|
||||
ci->file_length = 0;
|
||||
ci->file = NULL;
|
||||
|
||||
ci = &(ct->idx[1]);
|
||||
if ((mds_trk_block.point >= 1) && (mds_trk_block.point <= 99)) {
|
||||
ci->start = aend + 150;
|
||||
ci->length = mds_trk_ex_block.trk_sectors;
|
||||
ci->type = INDEX_NORMAL;
|
||||
ci->file_start = mds_trk_block.start_offs / ct->sector_size;
|
||||
ci->file_length = ci->length;
|
||||
ci->file = tf;
|
||||
} else {
|
||||
ci->start = (mds_trk_block.pm * 60 * 75) + (mds_trk_block.ps * 75) + mds_trk_block.pf;
|
||||
ci->type = INDEX_NONE;
|
||||
ci->file_start = 0;
|
||||
ci->file_length = 0;
|
||||
ci->file = NULL;
|
||||
}
|
||||
|
||||
ci = &(ct->idx[2]);
|
||||
if (ct->point < 0xa0) {
|
||||
ci->start = aend2 + 150;
|
||||
ci->length = astart2 - aend2;
|
||||
}
|
||||
ci->type = (ci->length > 0) ? INDEX_ZERO : INDEX_NONE;
|
||||
ci->file_start = 0;
|
||||
ci->file_length = 0;
|
||||
ci->file = NULL;
|
||||
|
||||
if (img->is_dvd) {
|
||||
ci = &(ct->idx[1]);
|
||||
uint32_t total = ci->start + ci->length;
|
||||
|
||||
ci = &(img->tracks[2].idx[1]);
|
||||
ci->start = total;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 2; i >= 0; i--) {
|
||||
if (ct->point >= 0xa0)
|
||||
ci->type = INDEX_SPECIAL;
|
||||
|
||||
if (ct->idx[i].file == NULL)
|
||||
ct->idx[i].file = tf;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
tf = NULL;
|
||||
|
||||
fclose(fp);
|
||||
|
||||
if (success) {
|
||||
#ifdef ENABLE_IMAGE_LOG
|
||||
image_log(img->log, "Final tracks list:\n");
|
||||
for (int i = 0; i < img->tracks_num; i++) {
|
||||
ct = &(img->tracks[i]);
|
||||
for (int j = 0; j < 3; j++) {
|
||||
ci = &(ct->idx[j]);
|
||||
image_log(img->log, " [TRACK ] %02X INDEX %02X: [%8s, %016" PRIX64 "]\n",
|
||||
ct->point, j,
|
||||
cit[ci->type + 2], ci->file_start * ct->sector_size);
|
||||
image_log(img->log, " TOC data: %02X %02X %02X "
|
||||
"%02X %02X %02X %02X %02X %02X %02X %02X\n",
|
||||
ct->session, ct->attr, ct->tno, ct->point,
|
||||
ct->extra[0], ct->extra[1], ct->extra[2], ct->extra[3],
|
||||
(uint32_t) ((ci->start / 75) / 60),
|
||||
(uint32_t) ((ci->start / 75) % 60),
|
||||
(uint32_t) (ci->start % 75));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else
|
||||
#ifdef ENABLE_IMAGE_LOG
|
||||
log_warning(img->log, " [MDS ] Unable to open MDS sheet \"%s\"\n", mdsfile);
|
||||
#else
|
||||
warning("Unable to open MDS sheet \"%s\"\n", mdsfile);
|
||||
#endif
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -1713,8 +2281,8 @@ image_get_track_info(const void *local, const uint32_t track,
|
||||
}
|
||||
|
||||
if (ct != NULL) {
|
||||
const uint32_t pos = end ? ct->idx[1].start :
|
||||
(ct->idx[1].start + ct->idx[1].length);
|
||||
const uint32_t pos = end ? (ct->idx[1].start + ct->idx[1].length) :
|
||||
ct->idx[1].start;
|
||||
|
||||
ti->number = ct->point;
|
||||
ti->attr = ct->attr;
|
||||
@@ -1784,6 +2352,7 @@ image_read_sector(const void *local, uint8_t *buffer,
|
||||
const uint32_t sector)
|
||||
{
|
||||
const cd_image_t *img = (const cd_image_t *) local;
|
||||
cdrom_t *dev = (cdrom_t *) img->dev;
|
||||
int m = 0;
|
||||
int s = 0;
|
||||
int f = 0;
|
||||
@@ -1792,6 +2361,7 @@ image_read_sector(const void *local, uint8_t *buffer,
|
||||
int track;
|
||||
int index;
|
||||
uint8_t q[16] = { 0x00 };
|
||||
uint8_t *buf = buffer;
|
||||
|
||||
if (sector == 0xffffffff)
|
||||
lba = img->dev->seek_pos;
|
||||
@@ -1851,6 +2421,26 @@ image_read_sector(const void *local, uint8_t *buffer,
|
||||
/* Index is not in the file, no read to fail here. */
|
||||
ret = 1;
|
||||
|
||||
if ((ret > 0) && (trk->attr & 0x04) && ((idx->type < INDEX_NORMAL) || !track_is_raw)) {
|
||||
uint32_t crc;
|
||||
|
||||
if ((trk->mode == 2) && (trk->form == 1)) {
|
||||
crc = cdrom_crc32(0xffffffff, &(buf[16]), 2056) ^ 0xffffffff;
|
||||
memcpy(&(buf[2072]), &crc, 4);
|
||||
} else {
|
||||
crc = cdrom_crc32(0xffffffff, buf, 2064) ^ 0xffffffff;
|
||||
memcpy(&(buf[2064]), &crc, 4);
|
||||
}
|
||||
|
||||
int m2f1 = (trk->mode == 2) && (trk->form == 1);
|
||||
|
||||
/* Compute ECC P code. */
|
||||
cdrom_compute_ecc_block(dev, &(buf[2076]), &(buf[12]), 86, 24, 2, 86, m2f1);
|
||||
|
||||
/* Compute ECC Q code. */
|
||||
cdrom_compute_ecc_block(dev, &(buf[2248]), &(buf[12]), 52, 43, 86, 88, m2f1);
|
||||
}
|
||||
|
||||
if ((ret > 0) && ((idx->type < INDEX_NORMAL) || (trk->subch_type != 0x08))) {
|
||||
buffer -= offset;
|
||||
|
||||
@@ -1945,7 +2535,27 @@ static int
|
||||
image_read_dvd_structure(const void *local, const uint8_t layer, const uint8_t format,
|
||||
uint8_t *buffer, uint32_t *info)
|
||||
{
|
||||
return 0;
|
||||
const cd_image_t *img = (const cd_image_t *) local;
|
||||
int ret = 0;
|
||||
|
||||
if ((img->has_dstruct > 0) && ((layer + 1) > img->has_dstruct)) {
|
||||
switch (format) {
|
||||
case 0x00:
|
||||
memcpy(buffer + 4, img->dstruct.layers[layer].f0, 2048);
|
||||
ret = 2048 + 2;
|
||||
break;
|
||||
case 0x01:
|
||||
memcpy(buffer + 4, img->dstruct.layers[layer].f1, 4);
|
||||
ret = 4 + 2;
|
||||
break;
|
||||
case 0x04:
|
||||
memcpy(buffer + 4, img->dstruct.layers[layer].f4, 2048);
|
||||
ret = 2048 + 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -1977,6 +2587,9 @@ image_close(void *local)
|
||||
log_close(img->log);
|
||||
img->log = NULL;
|
||||
|
||||
if (img->bad_sectors != NULL)
|
||||
free(img->bad_sectors);
|
||||
|
||||
free(img);
|
||||
}
|
||||
}
|
||||
@@ -2005,40 +2618,54 @@ image_open(cdrom_t *dev, const char *path)
|
||||
|
||||
if (img != NULL) {
|
||||
int ret;
|
||||
const int is_cue = ((ext == 4) && !stricmp(path + strlen(path) - ext + 1, "CUE"));
|
||||
const int is_cue = ((ext == 4) && !stricmp(path + strlen(path) - ext + 1, "CUE"));
|
||||
const int is_mds = ((ext == 4) && !stricmp(path + strlen(path) - ext + 1, "MDS"));
|
||||
char n[1024] = { 0 };
|
||||
|
||||
img->dev = dev;
|
||||
sprintf(n, "CD-ROM %i Image", dev->id + 1);
|
||||
img->log = log_open(n);
|
||||
|
||||
if (is_cue) {
|
||||
img->dev = dev;
|
||||
|
||||
if (is_mds) {
|
||||
ret = image_load_mds(img, path);
|
||||
|
||||
if (ret >= 2)
|
||||
img->has_audio = 0;
|
||||
else if (ret)
|
||||
img->has_audio = 1;
|
||||
} else if (is_cue) {
|
||||
ret = image_load_cue(img, path);
|
||||
|
||||
if (ret >= 2)
|
||||
img->has_audio = 0;
|
||||
else if (ret)
|
||||
img->has_audio = 1;
|
||||
else {
|
||||
image_close(img);
|
||||
img = NULL;
|
||||
}
|
||||
|
||||
if (ret >= 1)
|
||||
img->is_dvd = 2;
|
||||
} else {
|
||||
ret = image_load_iso(img, path);
|
||||
|
||||
if (!ret) {
|
||||
image_close(img);
|
||||
img = NULL;
|
||||
} else
|
||||
if (ret) {
|
||||
img->has_audio = 0;
|
||||
img->is_dvd = 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
char n[1024] = { 0 };
|
||||
|
||||
sprintf(n, "CD-ROM %i Image", dev->id + 1);
|
||||
img->log = log_open(n);
|
||||
if (ret > 0) {
|
||||
if (img->is_dvd == 2) {
|
||||
uint32_t lb = image_get_last_block(img); /* Should be safer than previous way of doing it? */
|
||||
img->is_dvd = (lb >= 524287); /* Minimum 1 GB total capacity as threshold for DVD. */
|
||||
}
|
||||
|
||||
dev->ops = &image_ops;
|
||||
} else
|
||||
warning("Unable to load CD-ROM image: %s\n", path);
|
||||
} else {
|
||||
log_warning(img->log, "Unable to load CD-ROM image: %s\n", path);
|
||||
|
||||
image_close(img);
|
||||
img = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return img;
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
*
|
||||
* Mitsumi CD-ROM emulation for the ISA bus.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Jasmine Iwanek, <jriwanek@gmail.com>
|
||||
*
|
||||
* Copyright 2022 Miran Grca.
|
||||
* Copyright 2022 Miran Grca.
|
||||
* Copyright 2024-2025 Jasmine Iwanek.
|
||||
*/
|
||||
#include <inttypes.h>
|
||||
#include <stdarg.h>
|
||||
@@ -33,10 +33,6 @@
|
||||
#include <86box/plat.h>
|
||||
#include <86box/sound.h>
|
||||
|
||||
#define MCD_DEFAULT_IOPORT 0x310
|
||||
#define MCD_DEFAULT_IRQ 5
|
||||
#define MCD_DEFAULT_DMA 5
|
||||
|
||||
#define RAW_SECTOR_SIZE 2352
|
||||
#define COOKED_SECTOR_SIZE 2048
|
||||
|
||||
@@ -116,6 +112,8 @@ typedef struct mcd_t {
|
||||
int cur_toc_track;
|
||||
int pos;
|
||||
int newstat;
|
||||
|
||||
cdrom_t *cdrom_dev;
|
||||
} mcd_t;
|
||||
|
||||
#define CD_BCD(x) (((x) % 10) | (((x) / 10) << 4))
|
||||
@@ -140,17 +138,15 @@ mitsumi_cdrom_log(const char *fmt, ...)
|
||||
#endif
|
||||
|
||||
static int
|
||||
mitsumi_cdrom_is_ready(const cdrom_t *dev)
|
||||
mitsumi_cdrom_is_ready(const mcd_t *dev)
|
||||
{
|
||||
return (dev->image_path[0] != 0x00);
|
||||
return (dev->cdrom_dev->image_path[0] != 0x00);
|
||||
}
|
||||
|
||||
static void
|
||||
mitsumi_cdrom_reset(mcd_t *dev)
|
||||
{
|
||||
cdrom_t *cdrom = calloc(1, sizeof(cdrom_t));
|
||||
|
||||
dev->stat = mitsumi_cdrom_is_ready(cdrom) ? (STAT_READY | STAT_CHANGE) : 0;
|
||||
dev->stat = mitsumi_cdrom_is_ready(dev) ? (STAT_READY | STAT_CHANGE) : 0;
|
||||
dev->cmdrd_count = 0;
|
||||
dev->cmdbuf_count = 0;
|
||||
dev->buf_count = 0;
|
||||
@@ -168,12 +164,11 @@ mitsumi_cdrom_reset(mcd_t *dev)
|
||||
static int
|
||||
mitsumi_cdrom_read_sector(mcd_t *dev, int first)
|
||||
{
|
||||
cdrom_t *cdrom = calloc(1, sizeof(cdrom_t));
|
||||
uint8_t status;
|
||||
int ret = 0;
|
||||
|
||||
if (dev->drvmode == DRV_MODE_CDDA) {
|
||||
status = cdrom_mitsumi_audio_play(cdrom, dev->readmsf, dev->readcount);
|
||||
status = cdrom_mitsumi_audio_play(dev->cdrom_dev, dev->readmsf, dev->readcount);
|
||||
if (status == 1)
|
||||
return status;
|
||||
else
|
||||
@@ -187,15 +182,15 @@ mitsumi_cdrom_read_sector(mcd_t *dev, int first)
|
||||
dev->data = 0;
|
||||
return 0;
|
||||
}
|
||||
cdrom_stop(cdrom);
|
||||
ret = cdrom_readsector_raw(cdrom, dev->buf, cdrom->seek_pos, 0, 2, 0x10, (int *) &dev->readcount, 0);
|
||||
cdrom_stop(dev->cdrom_dev);
|
||||
ret = cdrom_readsector_raw(dev->cdrom_dev, dev->buf, dev->cdrom_dev->seek_pos, 0, 2, 0x10, (int *) &dev->readcount, 0);
|
||||
if (ret <= 0)
|
||||
return 0;
|
||||
if (dev->mode & 0x40) {
|
||||
dev->buf[12] = CD_BCD((dev->readmsf >> 16) & 0xff);
|
||||
dev->buf[13] = CD_BCD((dev->readmsf >> 8) & 0xff);
|
||||
}
|
||||
dev->readmsf = cdrom_lba_to_msf_accurate(cdrom->seek_pos + 1);
|
||||
dev->readmsf = cdrom_lba_to_msf_accurate(dev->cdrom_dev->seek_pos + 1);
|
||||
dev->buf_count = dev->dmalen + 1;
|
||||
dev->buf_idx = 0;
|
||||
dev->data = 1;
|
||||
@@ -258,7 +253,6 @@ static void
|
||||
mitsumi_cdrom_out(uint16_t port, uint8_t val, void *priv)
|
||||
{
|
||||
mcd_t *dev = (mcd_t *) priv;
|
||||
cdrom_t *cdrom = calloc(1, sizeof(cdrom_t));
|
||||
|
||||
pclog("Mitsumi CD-ROM OUT=%03x, val=%02x\n", port, val);
|
||||
switch (port & 1) {
|
||||
@@ -340,19 +334,19 @@ mitsumi_cdrom_out(uint16_t port, uint8_t val, void *priv)
|
||||
break;
|
||||
}
|
||||
if (!dev->cmdrd_count)
|
||||
dev->stat = mitsumi_cdrom_is_ready(cdrom) ? (STAT_READY | (dev->change ? STAT_CHANGE : 0)) : 0;
|
||||
dev->stat = mitsumi_cdrom_is_ready(dev) ? (STAT_READY | (dev->change ? STAT_CHANGE : 0)) : 0;
|
||||
return;
|
||||
}
|
||||
dev->cmd = val;
|
||||
dev->cmdbuf_idx = 0;
|
||||
dev->cmdrd_count = 0;
|
||||
dev->cmdbuf_count = 1;
|
||||
dev->cmdbuf[0] = mitsumi_cdrom_is_ready(cdrom) ? (STAT_READY | (dev->change ? STAT_CHANGE : 0)) : 0;
|
||||
dev->cmdbuf[0] = mitsumi_cdrom_is_ready(dev) ? (STAT_READY | (dev->change ? STAT_CHANGE : 0)) : 0;
|
||||
dev->data = 0;
|
||||
switch (val) {
|
||||
case CMD_GET_INFO:
|
||||
if (mitsumi_cdrom_is_ready(cdrom)) {
|
||||
cdrom_get_track_buffer(cdrom, &(dev->cmdbuf[1]));
|
||||
if (mitsumi_cdrom_is_ready(dev)) {
|
||||
cdrom_get_track_buffer(dev->cdrom_dev, &(dev->cmdbuf[1]));
|
||||
dev->cmdbuf_count = 10;
|
||||
dev->readcount = 0;
|
||||
} else {
|
||||
@@ -361,7 +355,7 @@ mitsumi_cdrom_out(uint16_t port, uint8_t val, void *priv)
|
||||
}
|
||||
break;
|
||||
case CMD_GET_Q:
|
||||
if (mitsumi_cdrom_is_ready(cdrom)) {
|
||||
if (mitsumi_cdrom_is_ready(dev)) {
|
||||
cdrom_get_q(cdrom, &(dev->cmdbuf[1]), &dev->cur_toc_track, dev->mode & MODE_GET_TOC);
|
||||
dev->cmdbuf_count = 11;
|
||||
dev->readcount = 0;
|
||||
@@ -378,7 +372,7 @@ mitsumi_cdrom_out(uint16_t port, uint8_t val, void *priv)
|
||||
break;
|
||||
case CMD_STOPCDDA:
|
||||
case CMD_STOP:
|
||||
cdrom_stop(cdrom);
|
||||
cdrom_stop(dev->cdrom_dev);
|
||||
dev->drvmode = DRV_MODE_STOP;
|
||||
dev->cur_toc_track = 0;
|
||||
break;
|
||||
@@ -387,7 +381,7 @@ mitsumi_cdrom_out(uint16_t port, uint8_t val, void *priv)
|
||||
break;
|
||||
case CMD_READ1X:
|
||||
case CMD_READ2X:
|
||||
if (mitsumi_cdrom_is_ready(cdrom)) {
|
||||
if (mitsumi_cdrom_is_ready(dev)) {
|
||||
dev->readcount = 0;
|
||||
dev->drvmode = (val == CMD_READ1X) ? DRV_MODE_CDDA : DRV_MODE_READ;
|
||||
dev->cmdrd_count = 6;
|
||||
@@ -403,7 +397,7 @@ mitsumi_cdrom_out(uint16_t port, uint8_t val, void *priv)
|
||||
dev->cmdbuf_count = 3;
|
||||
break;
|
||||
case CMD_EJECT:
|
||||
cdrom_stop(cdrom);
|
||||
cdrom_stop(dev->cdrom_dev);
|
||||
cdrom_eject(0);
|
||||
dev->readcount = 0;
|
||||
break;
|
||||
@@ -434,10 +428,23 @@ mitsumi_cdrom_init(UNUSED(const device_t *info))
|
||||
{
|
||||
mcd_t *dev = calloc(1, sizeof(mcd_t));
|
||||
|
||||
dev->irq = MCD_DEFAULT_IRQ;
|
||||
dev->dma = MCD_DEFAULT_DMA;
|
||||
for (uint8_t i = 0; i < CDROM_NUM; i++) {
|
||||
if (cdrom[i].bus_type == CDROM_BUS_MITSUMI) {
|
||||
dev->cdrom_dev = &cdrom[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
io_sethandler(MCD_DEFAULT_IOPORT, 3,
|
||||
if (!dev->cdrom_dev)
|
||||
return NULL;
|
||||
|
||||
dev->cdrom_dev->priv = &dev;
|
||||
|
||||
uint16_t base = device_get_config_hex16("base");
|
||||
dev->irq = device_get_config_int("irq");
|
||||
dev->dma = device_get_config_int("dma");
|
||||
|
||||
io_sethandler(base, 3,
|
||||
mitsumi_cdrom_in, NULL, NULL, mitsumi_cdrom_out, NULL, NULL, dev);
|
||||
|
||||
mitsumi_cdrom_reset(dev);
|
||||
@@ -456,6 +463,64 @@ mitsumi_cdrom_close(void *priv)
|
||||
}
|
||||
}
|
||||
|
||||
static const device_config_t mitsumi_config[] = {
|
||||
// clang-format off
|
||||
{
|
||||
.name = "base",
|
||||
.description = "Address",
|
||||
.type = CONFIG_HEX16,
|
||||
.default_string = NULL,
|
||||
.default_int = 0x310,
|
||||
.file_filter = NULL,
|
||||
.spinner = { 0 },
|
||||
.selection = {
|
||||
{ .description = "300H", .value = 0x300 },
|
||||
{ .description = "310H", .value = 0x310 },
|
||||
{ .description = "320H", .value = 0x320 },
|
||||
{ .description = "340H", .value = 0x340 },
|
||||
{ .description = "350H", .value = 0x350 },
|
||||
{ NULL }
|
||||
},
|
||||
.bios = { { 0 } }
|
||||
},
|
||||
{
|
||||
.name = "irq",
|
||||
.description = "IRQ",
|
||||
.type = CONFIG_SELECTION,
|
||||
.default_string = NULL,
|
||||
.default_int = 5,
|
||||
.file_filter = NULL,
|
||||
.spinner = { 0 },
|
||||
.selection = {
|
||||
{ .description = "IRQ 3", .value = 3 },
|
||||
{ .description = "IRQ 5", .value = 5 },
|
||||
{ .description = "IRQ 9", .value = 9 },
|
||||
{ .description = "IRQ 10", .value = 10 },
|
||||
{ .description = "IRQ 11", .value = 11 },
|
||||
{ .description = "" }
|
||||
},
|
||||
.bios = { { 0 } }
|
||||
},
|
||||
{
|
||||
.name = "dma",
|
||||
.description = "DMA",
|
||||
.type = CONFIG_SELECTION,
|
||||
.default_string = NULL,
|
||||
.default_int = 5,
|
||||
.file_filter = NULL,
|
||||
.spinner = { 0 },
|
||||
.selection = {
|
||||
{ .description = "DMA 5", .value = 5 },
|
||||
{ .description = "DMA 6", .value = 6 },
|
||||
{ .description = "DMA 7", .value = 7 },
|
||||
{ .description = "" }
|
||||
},
|
||||
.bios = { { 0 } }
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
// clang-format off
|
||||
};
|
||||
|
||||
const device_t mitsumi_cdrom_device = {
|
||||
.name = "Mitsumi CD-ROM interface",
|
||||
.internal_name = "mcd",
|
||||
@@ -467,5 +532,5 @@ const device_t mitsumi_cdrom_device = {
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
.config = mitsumi_config
|
||||
};
|
||||
|
||||
1078
src/cdrom/cdrom_mke.c
Normal file
1078
src/cdrom/cdrom_mke.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -840,7 +840,7 @@ recalc_sltptr(scamp_t *dev)
|
||||
recalc_ems(dev);
|
||||
}
|
||||
} else {
|
||||
for (uint8_t i = 0; i < (sltptr / EMS_PGSIZE); i++)
|
||||
for (uint32_t i = 0; i < (sltptr / EMS_PGSIZE); i++)
|
||||
scamp_mem_update_state(dev, i * EMS_PGSIZE, EMS_PGSIZE, 0x00, MEM_FMASK_SLOTBUS);
|
||||
|
||||
for (uint8_t i = (sltptr / EMS_PGSIZE); i < 40; i++)
|
||||
|
||||
@@ -596,15 +596,6 @@ sis_85c4xx_out(uint16_t port, uint8_t val, void *priv)
|
||||
|
||||
switch (rel_reg) {
|
||||
case 0x00:
|
||||
if (dev->is_471) {
|
||||
if (val & 0x01) {
|
||||
kbc_at_set_fast_reset(0);
|
||||
cpu_cpurst_on_sr = 1;
|
||||
} else {
|
||||
kbc_at_set_fast_reset(1);
|
||||
cpu_cpurst_on_sr = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x01:
|
||||
|
||||
@@ -80,10 +80,12 @@ typedef struct stpc_serial_t {
|
||||
} stpc_serial_t;
|
||||
|
||||
typedef struct stpc_lpt_t {
|
||||
uint8_t unlocked;
|
||||
uint8_t offset;
|
||||
uint8_t reg1;
|
||||
uint8_t reg4;
|
||||
uint8_t unlocked;
|
||||
uint8_t offset;
|
||||
uint8_t reg1;
|
||||
uint8_t reg4;
|
||||
|
||||
lpt_t *lpt;
|
||||
} stpc_lpt_t;
|
||||
|
||||
#ifdef ENABLE_STPC_LOG
|
||||
@@ -977,22 +979,22 @@ stpc_lpt_handlers(stpc_lpt_t *dev, uint8_t val)
|
||||
{
|
||||
const uint8_t new_addr = (val & 0x03);
|
||||
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
|
||||
switch (new_addr) {
|
||||
case 0x1:
|
||||
stpc_log("STPC: Remapping parallel port to LPT3\n");
|
||||
lpt1_setup(LPT_MDA_ADDR);
|
||||
lpt_port_setup(dev->lpt, LPT_MDA_ADDR);
|
||||
break;
|
||||
|
||||
case 0x2:
|
||||
stpc_log("STPC: Remapping parallel port to LPT1\n");
|
||||
lpt1_setup(LPT1_ADDR);
|
||||
lpt_port_setup(dev->lpt, LPT1_ADDR);
|
||||
break;
|
||||
|
||||
case 0x3:
|
||||
stpc_log("STPC: Remapping parallel port to LPT2\n");
|
||||
lpt1_setup(LPT2_ADDR);
|
||||
lpt_port_setup(dev->lpt, LPT2_ADDR);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1063,6 +1065,8 @@ stpc_lpt_init(UNUSED(const device_t *info))
|
||||
|
||||
stpc_lpt_t *dev = (stpc_lpt_t *) calloc(1, sizeof(stpc_lpt_t));
|
||||
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
|
||||
stpc_lpt_reset(dev);
|
||||
|
||||
io_sethandler(0x3f0, 2,
|
||||
|
||||
@@ -113,9 +113,9 @@ typedef struct
|
||||
mem_mapping_t ram_mapping;
|
||||
|
||||
nvr_t *nvr;
|
||||
|
||||
fdc_t *fdc;
|
||||
serial_t *uart[2];
|
||||
fdc_t *fdc;
|
||||
serial_t *uart[2];
|
||||
lpt_t *lpt;
|
||||
} wd76c10_t;
|
||||
|
||||
static uint32_t bank_sizes[4] = { 0x00020000, /* 64 Kbit X 16 = 1024 Kbit = 128 kB, 8x 8 */
|
||||
@@ -841,7 +841,7 @@ wd76c10_pf_loc_recalc(wd76c10_t *dev)
|
||||
uint8_t ems_page;
|
||||
uint32_t base;
|
||||
|
||||
for (uint8_t i = (0x031 + pf_loc); i <= (0x037 + pf_loc); i++) {
|
||||
for (uint16_t i = (0x031 + pf_loc); i <= (0x037 + pf_loc); i++) {
|
||||
ems_page = (i - 0x10) & 0xf7;
|
||||
dev->mem_pages[i] = ems_page;
|
||||
base = ((uint32_t) i) << 14;
|
||||
@@ -911,19 +911,19 @@ wd76c10_ser_par_cs_recalc(wd76c10_t *dev)
|
||||
}
|
||||
|
||||
/* LPT */
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
switch ((dev->ser_par_cs >> 9) & 0x03) {
|
||||
case 1:
|
||||
lpt1_setup(LPT_MDA_ADDR);
|
||||
lpt1_irq(LPT1_IRQ);
|
||||
lpt_port_setup(dev->lpt, LPT_MDA_ADDR);
|
||||
lpt_port_irq(dev->lpt, LPT1_IRQ);
|
||||
break;
|
||||
case 2:
|
||||
lpt1_setup(LPT1_ADDR);
|
||||
lpt1_irq(LPT1_IRQ);
|
||||
lpt_port_setup(dev->lpt, LPT1_ADDR);
|
||||
lpt_port_irq(dev->lpt, LPT1_IRQ);
|
||||
break;
|
||||
case 3:
|
||||
lpt1_setup(LPT2_ADDR);
|
||||
lpt1_irq(LPT1_IRQ);
|
||||
lpt_port_setup(dev->lpt, LPT2_ADDR);
|
||||
lpt_port_irq(dev->lpt, LPT1_IRQ);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1173,8 +1173,8 @@ wd76c10_inw(uint16_t port, void *priv)
|
||||
case 0xd072:
|
||||
ret = (serial_read(0x0002, dev->uart[0]) & 0xc0) << 8;
|
||||
ret |= (serial_read(0x0002, dev->uart[1]) & 0xc0) << 6;
|
||||
ret |= (lpt_read_port(0, 0x0002) & 0x0f) << 8;
|
||||
ret |= lpt_read_port(0, 0x0000);
|
||||
ret |= (lpt_read_port(dev->lpt, 0x0002) & 0x0f) << 8;
|
||||
ret |= lpt_read_port(dev->lpt, 0x0000);
|
||||
break;
|
||||
|
||||
case 0xe072:
|
||||
@@ -1188,7 +1188,7 @@ wd76c10_inw(uint16_t port, void *priv)
|
||||
break;
|
||||
|
||||
case 0xfc72:
|
||||
ret = ((lpt_read_status(0) & 0x20) >> 2);
|
||||
ret = ((lpt_read_status(dev->lpt) & 0x20) >> 2);
|
||||
ret |= (((uint16_t) dma_m) << 4);
|
||||
ret |= dev->toggle;
|
||||
dev->toggle ^= 0x8000;
|
||||
@@ -1303,6 +1303,7 @@ wd76c10_init(UNUSED(const device_t *info))
|
||||
dev->nvr = device_add(&amstrad_megapc_nvr_device);
|
||||
dev->uart[0] = device_add_inst(&ns16450_device, 1);
|
||||
dev->uart[1] = device_add_inst(&ns16450_device, 2);
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
dev->fdc = device_add(&fdc_at_device);
|
||||
device_add(&ide_isa_device);
|
||||
|
||||
|
||||
@@ -3875,19 +3875,31 @@ FP_LOAD_IMM_Q(uint64_t v)
|
||||
static __inline void
|
||||
FP_FCHS(void)
|
||||
{
|
||||
addbyte(0x48); /* MOVABS RAX, 0x8000000000000000 */
|
||||
addbyte(0xb8);
|
||||
addquad(0x8000000000000000);
|
||||
addbyte(0x66); /* MOVQ XMM15, RAX */
|
||||
addbyte(0x4c);
|
||||
addbyte(0x0f);
|
||||
addbyte(0x6e);
|
||||
addbyte(0xf8);
|
||||
addbyte(0x48); /* XOR RAX, RAX */
|
||||
addbyte(0x31);
|
||||
addbyte(0xc0);
|
||||
addbyte(0x8b); /*MOV EAX, TOP*/
|
||||
addbyte(0x45);
|
||||
addbyte((uint8_t) cpu_state_offset(TOP));
|
||||
addbyte(0xf2); /*SUBSD XMM0, XMM0*/
|
||||
addbyte(0xf3); /*MOVQ XMM0, ST[EAX*8]*/
|
||||
addbyte(0x0f);
|
||||
addbyte(0x5c);
|
||||
addbyte(0xc0);
|
||||
addbyte(0xf2); /*SUBSD XMM0, ST[EAX*8]*/
|
||||
addbyte(0x0f);
|
||||
addbyte(0x5c);
|
||||
addbyte(0x7e);
|
||||
addbyte(0x44);
|
||||
addbyte(0xc5);
|
||||
addbyte((uint8_t) cpu_state_offset(ST));
|
||||
addbyte(0x66); /* PXOR XMM0, XMM15 */
|
||||
addbyte(0x41);
|
||||
addbyte(0x0F);
|
||||
addbyte(0xEF);
|
||||
addbyte(0xC7);
|
||||
addbyte(0x80); /*AND tag[EAX], ~TAG_UINT64*/
|
||||
addbyte(0x64);
|
||||
addbyte(0x05);
|
||||
|
||||
@@ -636,9 +636,10 @@ codegen_FCHS(codeblock_t *block, uop_t *uop)
|
||||
int src_size_a = IREG_GET_SIZE(uop->src_reg_a_real);
|
||||
|
||||
if (REG_IS_D(dest_size) && REG_IS_D(src_size_a)) {
|
||||
host_x86_MOVQ_XREG_XREG(block, REG_XMM_TEMP, src_reg_a);
|
||||
host_x86_PXOR_XREG_XREG(block, dest_reg, dest_reg);
|
||||
host_x86_SUBSD_XREG_XREG(block, dest_reg, REG_XMM_TEMP);
|
||||
host_x86_MOVQ_XREG_XREG(block, dest_reg, src_reg_a);
|
||||
host_x86_MOV64_REG_IMM(block, REG_RCX, 0x8000000000000000);
|
||||
host_x86_MOVQ_XREG_REG(block, REG_XMM_TEMP, REG_RCX);
|
||||
host_x86_PXOR_XREG_XREG(block, dest_reg, REG_XMM_TEMP);
|
||||
}
|
||||
# ifdef RECOMPILER_DEBUG
|
||||
else
|
||||
|
||||
875
src/config.c
875
src/config.c
File diff suppressed because it is too large
Load Diff
@@ -539,10 +539,9 @@ pfq_write(void)
|
||||
static uint8_t
|
||||
pfq_read(void)
|
||||
{
|
||||
uint8_t temp, i;
|
||||
uint8_t temp = pfq[0];
|
||||
|
||||
temp = pfq[0];
|
||||
for (i = 0; i < (pfq_size - 1); i++)
|
||||
for (int i = 0; i < (pfq_size - 1); i++)
|
||||
pfq[i] = pfq[i + 1];
|
||||
pfq_pos--;
|
||||
cpu_state.pc = (cpu_state.pc + 1) & 0xffff;
|
||||
|
||||
13
src/device.c
13
src/device.c
@@ -349,12 +349,6 @@ device_reset_all(uint32_t match_flags)
|
||||
devices[c]->reset(device_priv[c]);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef UNCOMMENT_LATER
|
||||
/* TODO: Actually convert the LPT devices to device_t's. */
|
||||
if ((match_flags == DEVICE_ALL) || (match_flags == DEVICE_PCI))
|
||||
lpt_reset();
|
||||
#endif
|
||||
}
|
||||
|
||||
void *
|
||||
@@ -469,7 +463,6 @@ device_get_bios_local(const device_t *dev, const char *internal_name)
|
||||
(bios->name != NULL) &&
|
||||
(bios->internal_name != NULL) &&
|
||||
(bios->files_no != 0)) {
|
||||
printf("Internal name was: %s", internal_name);
|
||||
if (!strcmp(internal_name, bios->internal_name))
|
||||
return bios->local;
|
||||
bios++;
|
||||
@@ -666,9 +659,9 @@ device_get_name(const device_t *dev, int bus, char *name)
|
||||
fbus = strstr(tname, sbus);
|
||||
if (fbus == tname)
|
||||
strcat(name, tname + strlen(sbus) + 1);
|
||||
/* Special case to not strip the "oPCI" from "Ensoniq AudioPCI" or
|
||||
the "-ISA" from "AMD PCnet-ISA". */
|
||||
else if ((fbus == NULL) || (*(fbus - 1) == 'o') || (*(fbus - 1) == '-') || (*(fbus - 2) == 'r'))
|
||||
/* Special case to not strip the "oPCI" from "Ensoniq AudioPCI",
|
||||
the "-ISA" from "AMD PCnet-ISA" or the " PCI" from "CMD PCI-064x". */
|
||||
else if ((fbus == NULL) || (*(fbus - 1) == 'o') || (*(fbus - 1) == '-') || (*(fbus - 2) == 'r') || ((fbus[0] == 'P') && (fbus[1] == 'C') && (fbus[2] == 'I') && (fbus[3] == '-')))
|
||||
strcat(name, tname);
|
||||
else {
|
||||
strncat(name, tname, fbus - tname - 1);
|
||||
|
||||
@@ -38,6 +38,7 @@ add_library(dev OBJECT
|
||||
isapnp.c
|
||||
kbc_at.c
|
||||
kbc_at_dev.c
|
||||
kbc_xt.c
|
||||
keyboard.c
|
||||
keyboard_at.c
|
||||
keyboard_xt.c
|
||||
@@ -47,6 +48,7 @@ add_library(dev OBJECT
|
||||
mouse_microtouch_touchscreen.c
|
||||
mouse_ps2.c
|
||||
mouse_serial.c
|
||||
mouse_upc.c
|
||||
nec_mate_unk.c
|
||||
novell_cardkey.c
|
||||
pci_bridge.c
|
||||
|
||||
@@ -152,10 +152,11 @@ pc_cas_del(pc_cassette_t *cas)
|
||||
}
|
||||
|
||||
int
|
||||
pc_cas_set_fname(pc_cassette_t *cas, const char *fname)
|
||||
pc_cas_set_fname(pc_cassette_t *cas, char *fname)
|
||||
{
|
||||
unsigned n;
|
||||
const char *ext;
|
||||
int offs = 0;
|
||||
|
||||
if (cas->close)
|
||||
fclose(cas->fp);
|
||||
@@ -176,6 +177,13 @@ pc_cas_set_fname(pc_cassette_t *cas, const char *fname)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strstr(fname, "wp://") == fname) {
|
||||
offs = 5;
|
||||
cassette_ui_writeprot = 1;
|
||||
}
|
||||
|
||||
fname += offs;
|
||||
|
||||
cas->fp = plat_fopen(fname, "r+b");
|
||||
|
||||
if (cas->fp == NULL)
|
||||
@@ -197,10 +205,10 @@ pc_cas_set_fname(pc_cassette_t *cas, const char *fname)
|
||||
|
||||
n = strlen(fname);
|
||||
|
||||
cas->fname = malloc((n + 1) * sizeof(char));
|
||||
cas->fname = malloc((n + offs + 1) * sizeof(char));
|
||||
|
||||
if (cas->fname != NULL)
|
||||
memcpy(cas->fname, fname, (n + 1) * sizeof(char));
|
||||
memcpy(cas->fname, fname - offs, (n + offs + 1) * sizeof(char));
|
||||
|
||||
if (n > 4) {
|
||||
ext = fname + (n - 4);
|
||||
@@ -216,6 +224,8 @@ pc_cas_set_fname(pc_cassette_t *cas, const char *fname)
|
||||
pc_cas_set_pcm(cas, 0);
|
||||
}
|
||||
|
||||
ui_sb_update_icon_wp(SB_CASSETTE, cassette_ui_writeprot);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
#define HAVE_STDARG_H
|
||||
#include <86box/86box.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/lpt.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/lpt.h>
|
||||
|
||||
#define HASP_BYTEARRAY(...) \
|
||||
{ \
|
||||
|
||||
@@ -107,6 +107,7 @@
|
||||
#define ISAMEM_BRAT_CARD 14
|
||||
#define ISAMEM_EV165A_CARD 15
|
||||
#define ISAMEM_LOTECH_EMS_CARD 16
|
||||
#define ISAMEM_MPLUS2_CARD 17
|
||||
|
||||
#define ISAMEM_DEBUG 0
|
||||
|
||||
@@ -495,6 +496,7 @@ isamem_init(const device_t *info)
|
||||
case ISAMEM_SYSTEMCARD_CARD: /* Microsoft SystemCard */
|
||||
case ISAMEM_P5PAK_CARD: /* Paradise Systems 5-PAK */
|
||||
case ISAMEM_A6PAK_CARD: /* AST SixPakPlus */
|
||||
case ISAMEM_MPLUS2_CARD: /* AST MegaPlus II */
|
||||
dev->total_size = device_get_config_int("size");
|
||||
dev->start_addr = device_get_config_int("start");
|
||||
tot = dev->total_size;
|
||||
@@ -1391,10 +1393,10 @@ static const device_config_t ems5150_config[] = {
|
||||
.spinner = { 0 },
|
||||
.selection = {
|
||||
{ .description = "Disabled", .value = 0x0000 },
|
||||
{ .description = "Board 1", .value = 0x0208 },
|
||||
{ .description = "Board 2", .value = 0x020a },
|
||||
{ .description = "Board 3", .value = 0x020c },
|
||||
{ .description = "Board 4", .value = 0x020e },
|
||||
{ .description = "208H", .value = 0x0208 },
|
||||
{ .description = "20AH", .value = 0x020a },
|
||||
{ .description = "20CH", .value = 0x020c },
|
||||
{ .description = "20EH", .value = 0x020e },
|
||||
{ .description = "" }
|
||||
},
|
||||
.bios = { { 0 } }
|
||||
@@ -2094,6 +2096,54 @@ static const device_t iab_device = {
|
||||
};
|
||||
#endif /* USE_ISAMEM_IAB */
|
||||
|
||||
static const device_config_t mplus2_config[] = {
|
||||
// clang-format off
|
||||
{
|
||||
.name = "size",
|
||||
.description = "Memory Size",
|
||||
.type = CONFIG_SPINNER,
|
||||
.default_string = "",
|
||||
.default_int = 64,
|
||||
.file_filter = "",
|
||||
.spinner = {
|
||||
.min = 0,
|
||||
.max = 512,
|
||||
.step = 64
|
||||
},
|
||||
.selection = { { 0 } }
|
||||
},
|
||||
{
|
||||
.name = "start",
|
||||
.description = "Start Address",
|
||||
.type = CONFIG_SPINNER,
|
||||
.default_string = "",
|
||||
.default_int = 256,
|
||||
.file_filter = "",
|
||||
.spinner = {
|
||||
.min = 64,
|
||||
.max = 576,
|
||||
.step = 64
|
||||
},
|
||||
.selection = { { 0 } }
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static const device_t mplus2_device = {
|
||||
.name = "AST MegaPlus II",
|
||||
.internal_name = "mplus2",
|
||||
.flags = DEVICE_ISA,
|
||||
.local = ISAMEM_MPLUS2_CARD,
|
||||
.init = isamem_init,
|
||||
.close = isamem_close,
|
||||
.reset = NULL,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = mplus2_config
|
||||
};
|
||||
|
||||
static const struct {
|
||||
const device_t *dev;
|
||||
} boards[] = {
|
||||
@@ -2127,6 +2177,7 @@ static const struct {
|
||||
{ &iab_device },
|
||||
#endif /* USE_ISAMEM_IAB */
|
||||
{ &lotech_ems_device },
|
||||
{ &mplus2_device },
|
||||
{ NULL }
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
@@ -1117,13 +1117,17 @@ isapnp_enable_card(void *priv, uint8_t enable)
|
||||
/* Enable or disable the card. */
|
||||
if (!!enable ^ !!card->enable)
|
||||
card->state = (enable == ISAPNP_CARD_FORCE_CONFIG) ? PNP_STATE_CONFIG : PNP_STATE_WAIT_FOR_KEY;
|
||||
int old_enable = card->enable;
|
||||
card->enable = enable;
|
||||
|
||||
/* Invalidate other references if we're disabling this card. */
|
||||
if (!card->enable) {
|
||||
if ((card->enable) && (dev->current_ld_card != NULL) && (dev->current_ld_card != card)) {
|
||||
dev->current_ld = NULL;
|
||||
dev->current_ld_card = NULL;
|
||||
} if (!card->enable) {
|
||||
if (dev->isolated_card == card)
|
||||
dev->isolated_card = NULL;
|
||||
if (dev->current_ld_card == card) {
|
||||
if ((dev->current_ld_card == card) && (old_enable != ISAPNP_CARD_FORCE_CONFIG)) {
|
||||
dev->current_ld = NULL;
|
||||
dev->current_ld_card = NULL;
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ static const device_config_t isarom_config[] = {
|
||||
},
|
||||
{
|
||||
.name = "bios_addr",
|
||||
.description = "BIOS Address",
|
||||
.description = "BIOS address",
|
||||
.type = CONFIG_HEX20,
|
||||
.default_string = NULL,
|
||||
.default_int = 0x00000,
|
||||
@@ -557,7 +557,7 @@ static const device_config_t isarom_quad_config[] = {
|
||||
static const device_config_t lba_enhancer_config[] = {
|
||||
{
|
||||
.name = "bios_addr",
|
||||
.description = "BIOS Address",
|
||||
.description = "BIOS address",
|
||||
.type = CONFIG_HEX20,
|
||||
.default_string = NULL,
|
||||
.default_int = 0xc8000,
|
||||
|
||||
@@ -89,10 +89,11 @@
|
||||
#define ISARTC_P5PAK 2
|
||||
#define ISARTC_A6PAK 3
|
||||
#define ISARTC_VENDEX 4
|
||||
#define ISARTC_MPLUS2 5
|
||||
#define ISARTC_MM58167 10
|
||||
|
||||
#define ISARTC_ROM_MM58167_1 "roms/rtc/glatick/GLaTICK_0.8.5_NS_RP.ROM"
|
||||
#define ISARTC_ROM_MM58167_2 "roms/rtc/glatick/GLaTICK_0.8.5_86B.ROM"
|
||||
#define ISARTC_ROM_MM58167_1 "roms/rtc/glatick/GLaTICK_0.8.8_NS_86B.ROM" /* Generic 58167, AST or EV-170 */
|
||||
#define ISARTC_ROM_MM58167_2 "roms/rtc/glatick/GLaTICK_0.8.8_NS_86B2.ROM" /* PII-147 */
|
||||
|
||||
#define ISARTC_DEBUG 0
|
||||
|
||||
@@ -409,6 +410,7 @@ mm67_read(uint16_t port, void *priv)
|
||||
break;
|
||||
|
||||
case MM67_AL_MSEC:
|
||||
case MM67_MSEC:
|
||||
ret = dev->nvr.regs[reg] & 0xf0;
|
||||
break;
|
||||
|
||||
@@ -416,6 +418,10 @@ mm67_read(uint16_t port, void *priv)
|
||||
ret = dev->nvr.regs[reg] & 0x0f;
|
||||
break;
|
||||
|
||||
case MM67_DOW:
|
||||
ret = dev->nvr.regs[reg] & 0x07;
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = dev->nvr.regs[reg];
|
||||
break;
|
||||
@@ -563,8 +569,9 @@ isartc_init(const device_t *info)
|
||||
dev->year = MM67_AL_HUNTEN; /* year, NON STANDARD */
|
||||
break;
|
||||
|
||||
case ISARTC_P5PAK: /* Paradise Systems 5PAK */
|
||||
case ISARTC_A6PAK: /* AST SixPakPlus */
|
||||
case ISARTC_P5PAK: /* Paradise Systems 5PAK */
|
||||
case ISARTC_A6PAK: /* AST SixPakPlus */
|
||||
case ISARTC_MPLUS2: /* AST MegaPlus II */
|
||||
dev->flags |= FLAG_YEAR80;
|
||||
dev->base_addr = 0x02c0;
|
||||
dev->base_addrsz = 32;
|
||||
@@ -786,6 +793,42 @@ static const device_t a6pak_device = {
|
||||
.config = a6pak_config
|
||||
};
|
||||
|
||||
static const device_config_t mplus2_config[] = {
|
||||
// clang-format off
|
||||
{
|
||||
.name = "irq",
|
||||
.description = "IRQ",
|
||||
.type = CONFIG_SELECTION,
|
||||
.default_string = "",
|
||||
.default_int = -1,
|
||||
.file_filter = "",
|
||||
.spinner = { 0 },
|
||||
.selection = {
|
||||
{ "Disabled", -1 },
|
||||
{ "IRQ2", 2 },
|
||||
{ "IRQ3", 3 },
|
||||
{ "IRQ5", 5 },
|
||||
{ "" }
|
||||
},
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static const device_t mplus2_device = {
|
||||
.name = "AST MegaPlus II",
|
||||
.internal_name = "mplus2",
|
||||
.flags = DEVICE_ISA,
|
||||
.local = ISARTC_MPLUS2,
|
||||
.init = isartc_init,
|
||||
.close = isartc_close,
|
||||
.reset = NULL,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = mplus2_config
|
||||
};
|
||||
|
||||
static const device_config_t mm58167_config[] = {
|
||||
// clang-format off
|
||||
{
|
||||
@@ -823,7 +866,7 @@ static const device_config_t mm58167_config[] = {
|
||||
},
|
||||
{
|
||||
.name = "bios_addr",
|
||||
.description = "BIOS Address",
|
||||
.description = "BIOS address",
|
||||
.type = CONFIG_HEX20,
|
||||
.default_string = NULL,
|
||||
.default_int = 0xcc000,
|
||||
@@ -897,6 +940,7 @@ static const struct {
|
||||
{ &pii147_device },
|
||||
{ &p5pak_device },
|
||||
{ &a6pak_device },
|
||||
{ &mplus2_device },
|
||||
{ &mm58167_device },
|
||||
{ NULL }
|
||||
// clang-format on
|
||||
|
||||
@@ -8,13 +8,11 @@
|
||||
*
|
||||
* Intel 8042 (AT keyboard controller) emulation.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* EngiNerd, <webmaster.crrc@yahoo.it>
|
||||
*
|
||||
* Copyright 2023 Miran Grca.
|
||||
* Copyright 2023 EngiNerd.
|
||||
* Copyright 2023-2025 Miran Grca.
|
||||
* Copyright 2023-2025 EngiNerd.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -29,24 +27,19 @@
|
||||
#include <86box/timer.h>
|
||||
#include <86box/io.h>
|
||||
#include <86box/pic.h>
|
||||
#include <86box/pit.h>
|
||||
#include <86box/plat_fallthrough.h>
|
||||
#include <86box/plat_unused.h>
|
||||
#include <86box/ppi.h>
|
||||
#include <86box/mem.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/dma.h>
|
||||
#include <86box/machine.h>
|
||||
#include <86box/m_at_t3100e.h>
|
||||
#include <86box/fdd.h>
|
||||
#include <86box/fdc.h>
|
||||
#include <86box/sound.h>
|
||||
#include <86box/snd_speaker.h>
|
||||
#include <86box/pci.h>
|
||||
#include <86box/video.h>
|
||||
#include <86box/keyboard.h>
|
||||
|
||||
#include <86box/dma.h>
|
||||
#include <86box/pci.h>
|
||||
|
||||
#define STAT_PARITY 0x80
|
||||
#define STAT_RTIMEOUT 0x40
|
||||
#define STAT_TTIMEOUT 0x20
|
||||
@@ -2668,7 +2661,15 @@ kbc_at_init(const device_t *info)
|
||||
dev->ports[1] = kbc_at_ports[1];
|
||||
|
||||
/* The actual keyboard. */
|
||||
device_add(&keyboard_at_generic_device);
|
||||
if (keyboard_type == KEYBOARD_TYPE_INTERNAL) {
|
||||
if (machine_has_flags(machine, MACHINE_KEYBOARD_JIS))
|
||||
device_add(((dev->flags & KBC_TYPE_MASK) >= KBC_TYPE_PS2_1) ? &keyboard_ps55_device :
|
||||
&keyboard_ax_device);
|
||||
else
|
||||
device_add_params(&keyboard_at_generic_device, (void *) (uintptr_t)
|
||||
(((dev->flags & KBC_TYPE_MASK) >= KBC_TYPE_PS2_1) ? FLAG_PS2_KBD : 0x00));
|
||||
} else
|
||||
keyboard_add_device();
|
||||
|
||||
fast_reset = 0x00;
|
||||
|
||||
@@ -2677,9 +2678,9 @@ kbc_at_init(const device_t *info)
|
||||
return dev;
|
||||
}
|
||||
|
||||
const device_t keyboard_at_device = {
|
||||
.name = "PC/AT Keyboard",
|
||||
.internal_name = "keyboard_at",
|
||||
const device_t kbc_at_device = {
|
||||
.name = "PC/AT Keyboard Controller",
|
||||
.internal_name = "kbc_at",
|
||||
.flags = DEVICE_KBC,
|
||||
.local = KBC_TYPE_ISA | KBC_VEN_GENERIC,
|
||||
.init = kbc_at_init,
|
||||
@@ -2691,9 +2692,9 @@ const device_t keyboard_at_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_at_siemens_device = {
|
||||
.name = "PC/AT Keyboard",
|
||||
.internal_name = "keyboard_at",
|
||||
const device_t kbc_at_siemens_device = {
|
||||
.name = "PC/AT Keyboard Controller",
|
||||
.internal_name = "kbc_at",
|
||||
.flags = DEVICE_KBC,
|
||||
.local = KBC_TYPE_ISA | KBC_VEN_SIEMENS,
|
||||
.init = kbc_at_init,
|
||||
@@ -2705,9 +2706,9 @@ const device_t keyboard_at_siemens_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_at_ami_device = {
|
||||
.name = "PC/AT Keyboard (AMI)",
|
||||
.internal_name = "keyboard_at_ami",
|
||||
const device_t kbc_at_ami_device = {
|
||||
.name = "PC/AT Keyboard Controller (AMI)",
|
||||
.internal_name = "kbc_at_ami",
|
||||
.flags = DEVICE_KBC,
|
||||
.local = KBC_TYPE_ISA | KBC_VEN_AMI,
|
||||
.init = kbc_at_init,
|
||||
@@ -2719,9 +2720,9 @@ const device_t keyboard_at_ami_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_at_tg_ami_device = {
|
||||
.name = "PC/AT Keyboard (TriGem AMI)",
|
||||
.internal_name = "keyboard_at_tg_ami",
|
||||
const device_t kbc_at_tg_ami_device = {
|
||||
.name = "PC/AT Keyboard Controller (TriGem AMI)",
|
||||
.internal_name = "kbc_at_tg_ami",
|
||||
.flags = DEVICE_KBC,
|
||||
.local = KBC_TYPE_ISA | KBC_VEN_TRIGEM_AMI,
|
||||
.init = kbc_at_init,
|
||||
@@ -2733,9 +2734,9 @@ const device_t keyboard_at_tg_ami_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_at_toshiba_device = {
|
||||
.name = "PC/AT Keyboard (Toshiba)",
|
||||
.internal_name = "keyboard_at_toshiba",
|
||||
const device_t kbc_at_toshiba_device = {
|
||||
.name = "PC/AT Keyboard Controller (Toshiba)",
|
||||
.internal_name = "kbc_at_toshiba",
|
||||
.flags = DEVICE_KBC,
|
||||
.local = KBC_TYPE_ISA | KBC_VEN_TOSHIBA,
|
||||
.init = kbc_at_init,
|
||||
@@ -2747,9 +2748,9 @@ const device_t keyboard_at_toshiba_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_at_olivetti_device = {
|
||||
.name = "PC/AT Keyboard (Olivetti)",
|
||||
.internal_name = "keyboard_at_olivetti",
|
||||
const device_t kbc_at_olivetti_device = {
|
||||
.name = "PC/AT Keyboard Controller (Olivetti)",
|
||||
.internal_name = "kbc_at_olivetti",
|
||||
.flags = DEVICE_KBC,
|
||||
.local = KBC_TYPE_ISA | KBC_VEN_OLIVETTI,
|
||||
.init = kbc_at_init,
|
||||
@@ -2761,9 +2762,9 @@ const device_t keyboard_at_olivetti_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_at_ncr_device = {
|
||||
.name = "PC/AT Keyboard (NCR)",
|
||||
.internal_name = "keyboard_at_ncr",
|
||||
const device_t kbc_at_ncr_device = {
|
||||
.name = "PC/AT Keyboard Controller (NCR)",
|
||||
.internal_name = "kbc_at_ncr",
|
||||
.flags = DEVICE_KBC,
|
||||
.local = KBC_TYPE_ISA | KBC_VEN_NCR,
|
||||
.init = kbc_at_init,
|
||||
@@ -2775,9 +2776,9 @@ const device_t keyboard_at_ncr_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_at_compaq_device = {
|
||||
.name = "PC/AT Keyboard (Compaq)",
|
||||
.internal_name = "keyboard_at_compaq",
|
||||
const device_t kbc_at_compaq_device = {
|
||||
.name = "PC/AT Keyboard Controller (Compaq)",
|
||||
.internal_name = "kbc_at_compaq",
|
||||
.flags = DEVICE_KBC,
|
||||
.local = KBC_TYPE_ISA | KBC_VEN_COMPAQ,
|
||||
.init = kbc_at_init,
|
||||
@@ -2789,9 +2790,9 @@ const device_t keyboard_at_compaq_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_at_phoenix_device = {
|
||||
.name = "PC/AT Keyboard (Phoenix)",
|
||||
.internal_name = "keyboard_at_phoenix",
|
||||
const device_t kbc_at_phoenix_device = {
|
||||
.name = "PC/AT Keyboard Controller (Phoenix)",
|
||||
.internal_name = "kbc_at_phoenix",
|
||||
.flags = DEVICE_KBC,
|
||||
.local = KBC_TYPE_ISA | KBC_VEN_PHOENIX,
|
||||
.init = kbc_at_init,
|
||||
@@ -2803,9 +2804,9 @@ const device_t keyboard_at_phoenix_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_ps2_device = {
|
||||
.name = "PS/2 Keyboard",
|
||||
.internal_name = "keyboard_ps2",
|
||||
const device_t kbc_ps2_device = {
|
||||
.name = "PS/2 Keyboard Controller",
|
||||
.internal_name = "kbc_ps2",
|
||||
.flags = DEVICE_KBC,
|
||||
.local = KBC_TYPE_PS2_1 | KBC_VEN_GENERIC,
|
||||
.init = kbc_at_init,
|
||||
@@ -2817,9 +2818,9 @@ const device_t keyboard_ps2_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_ps2_ps1_device = {
|
||||
.name = "PS/2 Keyboard (IBM PS/1)",
|
||||
.internal_name = "keyboard_ps2_ps1",
|
||||
const device_t kbc_ps2_ps1_device = {
|
||||
.name = "PS/2 Keyboard Controller (IBM PS/1)",
|
||||
.internal_name = "kbc_ps2_ps1",
|
||||
.flags = DEVICE_KBC,
|
||||
.local = KBC_TYPE_PS2_1 | KBC_VEN_IBM_PS1,
|
||||
.init = kbc_at_init,
|
||||
@@ -2831,9 +2832,9 @@ const device_t keyboard_ps2_ps1_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_ps2_ps1_pci_device = {
|
||||
.name = "PS/2 Keyboard (IBM PS/1)",
|
||||
.internal_name = "keyboard_ps2_ps1_pci",
|
||||
const device_t kbc_ps2_ps1_pci_device = {
|
||||
.name = "PS/2 Keyboard Controller (IBM PS/1)",
|
||||
.internal_name = "kbc_ps2_ps1_pci",
|
||||
.flags = DEVICE_KBC | DEVICE_PCI,
|
||||
.local = KBC_TYPE_PS2_1 | KBC_VEN_IBM_PS1,
|
||||
.init = kbc_at_init,
|
||||
@@ -2845,9 +2846,9 @@ const device_t keyboard_ps2_ps1_pci_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_ps2_xi8088_device = {
|
||||
.name = "PS/2 Keyboard (Xi8088)",
|
||||
.internal_name = "keyboard_ps2_xi8088",
|
||||
const device_t kbc_ps2_xi8088_device = {
|
||||
.name = "PS/2 Keyboard Controller (Xi8088)",
|
||||
.internal_name = "kbc_ps2_xi8088",
|
||||
.flags = DEVICE_KBC,
|
||||
.local = KBC_TYPE_PS2_1 | KBC_VEN_GENERIC,
|
||||
.init = kbc_at_init,
|
||||
@@ -2859,9 +2860,9 @@ const device_t keyboard_ps2_xi8088_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_ps2_ami_device = {
|
||||
.name = "PS/2 Keyboard (AMI)",
|
||||
.internal_name = "keyboard_ps2_ami",
|
||||
const device_t kbc_ps2_ami_device = {
|
||||
.name = "PS/2 Keyboard Controller (AMI)",
|
||||
.internal_name = "kbc_ps2_ami",
|
||||
.flags = DEVICE_KBC,
|
||||
.local = KBC_TYPE_PS2_1 | KBC_VEN_AMI,
|
||||
.init = kbc_at_init,
|
||||
@@ -2873,9 +2874,9 @@ const device_t keyboard_ps2_ami_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_ps2_compaq_device = {
|
||||
.name = "PS/2 Keyboard (Compaq)",
|
||||
.internal_name = "keyboard_at_compaq",
|
||||
const device_t kbc_ps2_compaq_device = {
|
||||
.name = "PS/2 Keyboard Controller (Compaq)",
|
||||
.internal_name = "kbc_at_compaq",
|
||||
.flags = DEVICE_KBC,
|
||||
.local = KBC_TYPE_PS2_1 | KBC_VEN_COMPAQ,
|
||||
.init = kbc_at_init,
|
||||
@@ -2887,9 +2888,9 @@ const device_t keyboard_ps2_compaq_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_ps2_holtek_device = {
|
||||
.name = "PS/2 Keyboard (Holtek)",
|
||||
.internal_name = "keyboard_ps2_holtek",
|
||||
const device_t kbc_ps2_holtek_device = {
|
||||
.name = "PS/2 Keyboard Controller (Holtek)",
|
||||
.internal_name = "kbc_ps2_holtek",
|
||||
.flags = DEVICE_KBC,
|
||||
.local = KBC_TYPE_PS2_1 | KBC_VEN_AMI | KBC_FLAG_IS_ASIC,
|
||||
.init = kbc_at_init,
|
||||
@@ -2901,9 +2902,9 @@ const device_t keyboard_ps2_holtek_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_ps2_phoenix_device = {
|
||||
.name = "PS/2 Keyboard (Phoenix)",
|
||||
.internal_name = "keyboard_ps2_phoenix",
|
||||
const device_t kbc_ps2_phoenix_device = {
|
||||
.name = "PS/2 Keyboard Controller (Phoenix)",
|
||||
.internal_name = "kbc_ps2_phoenix",
|
||||
.flags = DEVICE_KBC,
|
||||
.local = KBC_TYPE_PS2_1 | KBC_VEN_PHOENIX,
|
||||
.init = kbc_at_init,
|
||||
@@ -2915,9 +2916,9 @@ const device_t keyboard_ps2_phoenix_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_ps2_tg_ami_device = {
|
||||
.name = "PS/2 Keyboard (TriGem AMI)",
|
||||
.internal_name = "keyboard_ps2_tg_ami",
|
||||
const device_t kbc_ps2_tg_ami_device = {
|
||||
.name = "PS/2 Keyboard Controller (TriGem AMI)",
|
||||
.internal_name = "kbc_ps2_tg_ami",
|
||||
.flags = DEVICE_KBC,
|
||||
.local = KBC_TYPE_PS2_1 | KBC_VEN_TRIGEM_AMI,
|
||||
.init = kbc_at_init,
|
||||
@@ -2929,9 +2930,9 @@ const device_t keyboard_ps2_tg_ami_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_ps2_mca_1_device = {
|
||||
.name = "PS/2 Keyboard (IBM PS/2 MCA Type 1)",
|
||||
.internal_name = "keyboard_ps2_mca_1",
|
||||
const device_t kbc_ps2_mca_1_device = {
|
||||
.name = "PS/2 Keyboard Controller (IBM PS/2 MCA Type 1)",
|
||||
.internal_name = "kbc_ps2_mca_1",
|
||||
.flags = DEVICE_KBC,
|
||||
.local = KBC_TYPE_PS2_1 | KBC_VEN_IBM,
|
||||
.init = kbc_at_init,
|
||||
@@ -2943,9 +2944,9 @@ const device_t keyboard_ps2_mca_1_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_ps2_mca_2_device = {
|
||||
.name = "PS/2 Keyboard (IBM PS/2 MCA Type 2)",
|
||||
.internal_name = "keyboard_ps2_mca_2",
|
||||
const device_t kbc_ps2_mca_2_device = {
|
||||
.name = "PS/2 Keyboard Controller (IBM PS/2 MCA Type 2)",
|
||||
.internal_name = "kbc_ps2_mca_2",
|
||||
.flags = DEVICE_KBC,
|
||||
.local = KBC_TYPE_PS2_2 | KBC_VEN_IBM,
|
||||
.init = kbc_at_init,
|
||||
@@ -2957,9 +2958,9 @@ const device_t keyboard_ps2_mca_2_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_ps2_quadtel_device = {
|
||||
.name = "PS/2 Keyboard (Quadtel/MegaPC)",
|
||||
.internal_name = "keyboard_ps2_quadtel",
|
||||
const device_t kbc_ps2_quadtel_device = {
|
||||
.name = "PS/2 Keyboard Controller (Quadtel/MegaPC)",
|
||||
.internal_name = "kbc_ps2_quadtel",
|
||||
.flags = DEVICE_KBC,
|
||||
.local = KBC_TYPE_PS2_1 | KBC_VEN_QUADTEL,
|
||||
.init = kbc_at_init,
|
||||
@@ -2971,9 +2972,9 @@ const device_t keyboard_ps2_quadtel_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_ps2_pci_device = {
|
||||
.name = "PS/2 Keyboard",
|
||||
.internal_name = "keyboard_ps2_pci",
|
||||
const device_t kbc_ps2_pci_device = {
|
||||
.name = "PS/2 Keyboard Controller (PCI)",
|
||||
.internal_name = "kbc_ps2_pci",
|
||||
.flags = DEVICE_KBC | DEVICE_PCI,
|
||||
.local = KBC_TYPE_PS2_1 | KBC_VEN_GENERIC,
|
||||
.init = kbc_at_init,
|
||||
@@ -2985,9 +2986,9 @@ const device_t keyboard_ps2_pci_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_ps2_ami_pci_device = {
|
||||
.name = "PS/2 Keyboard (AMI)",
|
||||
.internal_name = "keyboard_ps2_ami_pci",
|
||||
const device_t kbc_ps2_ami_pci_device = {
|
||||
.name = "PS/2 Keyboard Controller (PCI) (AMI)",
|
||||
.internal_name = "kbc_ps2_ami_pci",
|
||||
.flags = DEVICE_KBC | DEVICE_PCI,
|
||||
.local = KBC_TYPE_PS2_1 | KBC_VEN_AMI,
|
||||
.init = kbc_at_init,
|
||||
@@ -2999,9 +3000,9 @@ const device_t keyboard_ps2_ami_pci_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_ps2_ali_pci_device = {
|
||||
.name = "PS/2 Keyboard (ALi M5123/M1543C)",
|
||||
.internal_name = "keyboard_ps2_ali_pci",
|
||||
const device_t kbc_ps2_ali_pci_device = {
|
||||
.name = "PS/2 Keyboard Controller (PCI) (ALi M5123/M1543C)",
|
||||
.internal_name = "kbc_ps2_ali_pci",
|
||||
.flags = DEVICE_KBC | DEVICE_PCI,
|
||||
.local = KBC_TYPE_PS2_1 | KBC_VEN_ALI,
|
||||
.init = kbc_at_init,
|
||||
@@ -3013,9 +3014,9 @@ const device_t keyboard_ps2_ali_pci_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_ps2_intel_ami_pci_device = {
|
||||
.name = "PS/2 Keyboard (AMI)",
|
||||
.internal_name = "keyboard_ps2_intel_ami_pci",
|
||||
const device_t kbc_ps2_intel_ami_pci_device = {
|
||||
.name = "PS/2 Keyboard Controller (PCI) (AMI)",
|
||||
.internal_name = "kbc_ps2_intel_ami_pci",
|
||||
.flags = DEVICE_KBC | DEVICE_PCI,
|
||||
.local = KBC_TYPE_GREEN | KBC_VEN_AMI,
|
||||
.init = kbc_at_init,
|
||||
@@ -3027,9 +3028,9 @@ const device_t keyboard_ps2_intel_ami_pci_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_ps2_tg_ami_pci_device = {
|
||||
.name = "PS/2 Keyboard (TriGem AMI)",
|
||||
.internal_name = "keyboard_ps2_tg_ami_pci",
|
||||
const device_t kbc_ps2_tg_ami_pci_device = {
|
||||
.name = "PS/2 Keyboard Controller (PCI) (TriGem AMI)",
|
||||
.internal_name = "kbc_ps2_tg_ami_pci",
|
||||
.flags = DEVICE_KBC | DEVICE_PCI,
|
||||
.local = KBC_TYPE_PS2_1 | KBC_VEN_TRIGEM_AMI,
|
||||
.init = kbc_at_init,
|
||||
@@ -3041,9 +3042,9 @@ const device_t keyboard_ps2_tg_ami_pci_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_ps2_acer_pci_device = {
|
||||
.name = "PS/2 Keyboard (Acer 90M002A)",
|
||||
.internal_name = "keyboard_ps2_acer_pci",
|
||||
const device_t kbc_ps2_acer_pci_device = {
|
||||
.name = "PS/2 Keyboard Controller (PCI) (Acer 90M002A)",
|
||||
.internal_name = "kbc_ps2_acer_pci",
|
||||
.flags = DEVICE_KBC | DEVICE_PCI,
|
||||
.local = KBC_TYPE_PS2_1 | KBC_VEN_ACER,
|
||||
.init = kbc_at_init,
|
||||
@@ -3055,9 +3056,9 @@ const device_t keyboard_ps2_acer_pci_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_ps2_phoenix_pci_device = {
|
||||
.name = "PS/2 Keyboard (Phoenix)",
|
||||
.internal_name = "keyboard_ps2_phoenix_pci",
|
||||
const device_t kbc_ps2_phoenix_pci_device = {
|
||||
.name = "PS/2 Keyboard Controller (PCI) (Phoenix)",
|
||||
.internal_name = "kbc_ps2_phoenix_pci",
|
||||
.flags = DEVICE_KBC | DEVICE_PCI,
|
||||
.local = KBC_TYPE_PS2_1 | KBC_VEN_PHOENIX,
|
||||
.init = kbc_at_init,
|
||||
|
||||
@@ -8,11 +8,9 @@
|
||||
*
|
||||
* AT / PS/2 attached device emulation.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
* Copyright 2023 Miran Grca.
|
||||
* Copyright 2023-2025 Miran Grca.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -22,23 +20,9 @@
|
||||
#define HAVE_STDARG_H
|
||||
#include <wchar.h>
|
||||
#include <86box/86box.h>
|
||||
#include "cpu.h"
|
||||
#include <86box/timer.h>
|
||||
#include <86box/io.h>
|
||||
#include <86box/pic.h>
|
||||
#include <86box/pit.h>
|
||||
#include <86box/ppi.h>
|
||||
#include <86box/mem.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/machine.h>
|
||||
#include <86box/m_at_t3100e.h>
|
||||
#include <86box/fdd.h>
|
||||
#include <86box/fdc.h>
|
||||
#include <86box/sound.h>
|
||||
#include <86box/snd_speaker.h>
|
||||
#include <86box/video.h>
|
||||
#include <86box/keyboard.h>
|
||||
#include <86box/plat_fallthrough.h>
|
||||
#include <86box/keyboard.h>
|
||||
|
||||
#ifdef ENABLE_KBC_AT_DEV_LOG
|
||||
int kbc_at_dev_do_log = ENABLE_KBC_AT_DEV_LOG;
|
||||
|
||||
903
src/device/kbc_xt.c
Normal file
903
src/device/kbc_xt.c
Normal file
@@ -0,0 +1,903 @@
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Implementation of the XT-style keyboard.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Authors: Sarah Walker, <https://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* EngiNerd, <webmaster.crrc@yahoo.it>
|
||||
*
|
||||
* Copyright 2008-2019 Sarah Walker.
|
||||
* Copyright 2016-2019 Miran Grca.
|
||||
* Copyright 2017-2019 Fred N. van kempen.
|
||||
* Copyright 2020 EngiNerd.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#define HAVE_STDARG_H
|
||||
#include <wchar.h>
|
||||
#include <86box/86box.h>
|
||||
#include <86box/device.h>
|
||||
#include "cpu.h"
|
||||
#include <86box/timer.h>
|
||||
#include <86box/fdd.h>
|
||||
#include <86box/machine.h>
|
||||
#include <86box/m_xt_t1000.h>
|
||||
#include <86box/cassette.h>
|
||||
#include <86box/io.h>
|
||||
#include <86box/pic.h>
|
||||
#include <86box/pit.h>
|
||||
#include <86box/ppi.h>
|
||||
#include <86box/mem.h>
|
||||
#include <86box/rom.h>
|
||||
#include <86box/sound.h>
|
||||
#include <86box/snd_speaker.h>
|
||||
#include <86box/video.h>
|
||||
#include <86box/keyboard.h>
|
||||
|
||||
#define STAT_PARITY 0x80
|
||||
#define STAT_RTIMEOUT 0x40
|
||||
#define STAT_TTIMEOUT 0x20
|
||||
#define STAT_LOCK 0x10
|
||||
#define STAT_CD 0x08
|
||||
#define STAT_SYSFLAG 0x04
|
||||
#define STAT_IFULL 0x02
|
||||
#define STAT_OFULL 0x01
|
||||
|
||||
/* Keyboard Types */
|
||||
enum {
|
||||
KBD_TYPE_PC81 = 0,
|
||||
KBD_TYPE_PC82,
|
||||
KBD_TYPE_XT82,
|
||||
KBD_TYPE_XT86,
|
||||
KBD_TYPE_COMPAQ,
|
||||
KBD_TYPE_TANDY,
|
||||
KBD_TYPE_TOSHIBA,
|
||||
KBD_TYPE_VTECH,
|
||||
KBD_TYPE_OLIVETTI,
|
||||
KBD_TYPE_ZENITH,
|
||||
KBD_TYPE_PRAVETZ,
|
||||
KBD_TYPE_HYUNDAI,
|
||||
KBD_TYPE_FE2010,
|
||||
KBD_TYPE_XTCLONE
|
||||
};
|
||||
|
||||
typedef struct xtkbd_t {
|
||||
int want_irq;
|
||||
int blocked;
|
||||
int tandy;
|
||||
|
||||
uint8_t pa;
|
||||
uint8_t pb;
|
||||
uint8_t pd;
|
||||
uint8_t cfg;
|
||||
uint8_t clock;
|
||||
uint8_t key_waiting;
|
||||
uint8_t type;
|
||||
uint8_t pravetz_flags;
|
||||
uint8_t cpu_speed;
|
||||
|
||||
pc_timer_t send_delay_timer;
|
||||
} xtkbd_t;
|
||||
|
||||
static uint8_t key_queue[16];
|
||||
static int key_queue_start = 0;
|
||||
static int key_queue_end = 0;
|
||||
static int is_tandy = 0;
|
||||
static int is_t1x00 = 0;
|
||||
static int is_amstrad = 0;
|
||||
|
||||
#ifdef ENABLE_KEYBOARD_XT_LOG
|
||||
int keyboard_xt_do_log = ENABLE_KEYBOARD_XT_LOG;
|
||||
|
||||
static void
|
||||
kbd_log(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (keyboard_xt_do_log) {
|
||||
va_start(ap, fmt);
|
||||
pclog_ex(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define kbd_log(fmt, ...)
|
||||
#endif
|
||||
|
||||
static uint8_t
|
||||
get_fdd_switch_settings(void)
|
||||
{
|
||||
|
||||
uint8_t fdd_count = 0;
|
||||
|
||||
for (uint8_t i = 0; i < FDD_NUM; i++) {
|
||||
if (fdd_get_flags(i))
|
||||
fdd_count++;
|
||||
}
|
||||
|
||||
if (!fdd_count)
|
||||
return 0x00;
|
||||
else
|
||||
return ((fdd_count - 1) << 6) | 0x01;
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
get_videomode_switch_settings(void)
|
||||
{
|
||||
|
||||
if (video_is_mda())
|
||||
return 0x30;
|
||||
else if (video_is_cga())
|
||||
return 0x20; /* 0x10 would be 40x25 */
|
||||
else
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
static void
|
||||
kbd_poll(void *priv)
|
||||
{
|
||||
xtkbd_t *kbd = (xtkbd_t *) priv;
|
||||
|
||||
timer_advance_u64(&kbd->send_delay_timer, 1000 * TIMER_USEC);
|
||||
|
||||
if (!(kbd->pb & 0x40) && (kbd->type != KBD_TYPE_TANDY))
|
||||
return;
|
||||
|
||||
if (kbd->want_irq) {
|
||||
kbd->want_irq = 0;
|
||||
kbd->pa = kbd->key_waiting;
|
||||
kbd->blocked = 1;
|
||||
picint(2);
|
||||
#ifdef ENABLE_KEYBOARD_XT_LOG
|
||||
kbd_log("XTkbd: kbd_poll(): keyboard_xt : take IRQ\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
if ((key_queue_start != key_queue_end) && !kbd->blocked) {
|
||||
kbd->key_waiting = key_queue[key_queue_start];
|
||||
kbd_log("XTkbd: reading %02X from the key queue at %i\n",
|
||||
kbd->key_waiting, key_queue_start);
|
||||
key_queue_start = (key_queue_start + 1) & 0x0f;
|
||||
kbd->want_irq = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
kbd_adddata(uint16_t val)
|
||||
{
|
||||
/* Test for T1000 'Fn' key (Right Alt / Right Ctrl) */
|
||||
if (is_t1x00) {
|
||||
if (keyboard_recv(0x138) || keyboard_recv(0x11d)) { /* 'Fn' pressed */
|
||||
t1000_syskey(0x00, 0x04, 0x00); /* Set 'Fn' indicator */
|
||||
switch (val) {
|
||||
case 0x45: /* Num Lock => toggle numpad */
|
||||
t1000_syskey(0x00, 0x00, 0x10);
|
||||
break;
|
||||
case 0x47: /* Home => internal display */
|
||||
t1000_syskey(0x40, 0x00, 0x00);
|
||||
break;
|
||||
case 0x49: /* PgDn => turbo on */
|
||||
t1000_syskey(0x80, 0x00, 0x00);
|
||||
break;
|
||||
case 0x4D: /* Right => toggle LCD font */
|
||||
t1000_syskey(0x00, 0x00, 0x20);
|
||||
break;
|
||||
case 0x4F: /* End => external display */
|
||||
t1000_syskey(0x00, 0x40, 0x00);
|
||||
break;
|
||||
case 0x51: /* PgDn => turbo off */
|
||||
t1000_syskey(0x00, 0x80, 0x00);
|
||||
break;
|
||||
case 0x54: /* SysRQ => toggle window */
|
||||
t1000_syskey(0x00, 0x00, 0x08);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else
|
||||
t1000_syskey(0x04, 0x00, 0x00); /* Reset 'Fn' indicator */
|
||||
}
|
||||
|
||||
key_queue[key_queue_end] = val;
|
||||
kbd_log("XTkbd: %02X added to key queue at %i\n",
|
||||
val, key_queue_end);
|
||||
key_queue_end = (key_queue_end + 1) & 0x0f;
|
||||
}
|
||||
|
||||
void
|
||||
kbd_adddata_process(uint16_t val, void (*adddata)(uint16_t val))
|
||||
{
|
||||
uint8_t num_lock = 0;
|
||||
uint8_t shift_states = 0;
|
||||
|
||||
if (!adddata)
|
||||
return;
|
||||
|
||||
keyboard_get_states(NULL, &num_lock, NULL, NULL);
|
||||
shift_states = keyboard_get_shift() & STATE_LSHIFT;
|
||||
|
||||
if (is_amstrad)
|
||||
num_lock = !num_lock;
|
||||
|
||||
/* If NumLock is on, invert the left shift state so we can always check for
|
||||
the the same way flag being set (and with NumLock on that then means it
|
||||
is actually *NOT* set). */
|
||||
if (num_lock)
|
||||
shift_states ^= STATE_LSHIFT;
|
||||
|
||||
switch (val) {
|
||||
case FAKE_LSHIFT_ON:
|
||||
/* If NumLock is on, fake shifts are sent when shift is *NOT* presed,
|
||||
if NumLock is off, fake shifts are sent when shift is pressed. */
|
||||
if (shift_states) {
|
||||
/* Send fake shift. */
|
||||
adddata(num_lock ? 0x2a : 0xaa);
|
||||
}
|
||||
break;
|
||||
case FAKE_LSHIFT_OFF:
|
||||
if (shift_states) {
|
||||
/* Send fake shift. */
|
||||
adddata(num_lock ? 0xaa : 0x2a);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
adddata(val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
kbd_adddata_ex(uint16_t val)
|
||||
{
|
||||
kbd_adddata_process(val, kbd_adddata);
|
||||
}
|
||||
|
||||
static void
|
||||
kbd_write(uint16_t port, uint8_t val, void *priv)
|
||||
{
|
||||
xtkbd_t *kbd = (xtkbd_t *) priv;
|
||||
uint8_t bit;
|
||||
uint8_t set;
|
||||
uint8_t new_clock;
|
||||
|
||||
switch (port) {
|
||||
case 0x61: /* Keyboard Control Register (aka Port B) */
|
||||
if (!(val & 0x80) || (kbd->type == KBD_TYPE_HYUNDAI)) {
|
||||
new_clock = !!(val & 0x40);
|
||||
if (!kbd->clock && new_clock) {
|
||||
key_queue_start = key_queue_end = 0;
|
||||
kbd->want_irq = 0;
|
||||
kbd->blocked = 0;
|
||||
kbd_adddata(0xaa);
|
||||
}
|
||||
}
|
||||
|
||||
kbd->pb = val;
|
||||
if (!(kbd->pb & 0x80) || (kbd->type == KBD_TYPE_HYUNDAI))
|
||||
kbd->clock = !!(kbd->pb & 0x40);
|
||||
ppi.pb = val;
|
||||
|
||||
timer_process();
|
||||
|
||||
if (((kbd->type == KBD_TYPE_PC81) || (kbd->type == KBD_TYPE_PC82) ||
|
||||
(kbd->type == KBD_TYPE_PRAVETZ)) && (cassette != NULL))
|
||||
pc_cas_set_motor(cassette, (kbd->pb & 0x08) == 0);
|
||||
|
||||
speaker_update();
|
||||
|
||||
speaker_gated = val & 1;
|
||||
speaker_enable = val & 2;
|
||||
|
||||
if (speaker_enable)
|
||||
was_speaker_enable = 1;
|
||||
pit_devs[0].set_gate(pit_devs[0].data, 2, val & 1);
|
||||
|
||||
if (val & 0x80) {
|
||||
kbd->pa = 0;
|
||||
kbd->blocked = 0;
|
||||
picintc(2);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_KEYBOARD_XT_LOG
|
||||
if ((kbd->type == KBD_TYPE_PC81) || (kbd->type == KBD_TYPE_PC82) || (kbd->type == KBD_TYPE_PRAVETZ))
|
||||
kbd_log("XTkbd: Cassette motor is %s\n", !(val & 0x08) ? "ON" : "OFF");
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 0x62: /* Switch Register (aka Port C) */
|
||||
#ifdef ENABLE_KEYBOARD_XT_LOG
|
||||
if ((kbd->type == KBD_TYPE_PC81) || (kbd->type == KBD_TYPE_PC82) || (kbd->type == KBD_TYPE_PRAVETZ))
|
||||
kbd_log("XTkbd: Cassette IN is %i\n", !!(val & 0x10));
|
||||
#endif
|
||||
if (kbd->type == KBD_TYPE_FE2010) {
|
||||
kbd_log("XTkbd: Switch register in is %02X\n", val);
|
||||
if (!(kbd->cfg & 0x08))
|
||||
kbd->pd = (kbd->pd & 0x30) | (val & 0xcf);
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x63:
|
||||
if (kbd->type == KBD_TYPE_FE2010) {
|
||||
kbd_log("XTkbd: Configuration register in is %02X\n", val);
|
||||
if (!(kbd->cfg & 0x08))
|
||||
kbd->cfg = val;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0xc0 ... 0xcf: /* Pravetz Flags */
|
||||
kbd_log("XTkbd: Port %02X out: %02X\n", port, val);
|
||||
if (kbd->type == KBD_TYPE_PRAVETZ) {
|
||||
bit = (port >> 1) & 0x07;
|
||||
set = (port & 0x01) << bit;
|
||||
kbd->pravetz_flags = (kbd->pravetz_flags & ~(1 << bit)) | set;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x1f0:
|
||||
kbd_log("XTkbd: Port %04X out: %02X\n", port, val);
|
||||
if (kbd->type == KBD_TYPE_VTECH) {
|
||||
kbd->cpu_speed = val;
|
||||
cpu_dynamic_switch(kbd->cpu_speed >> 7);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
kbd_read(uint16_t port, void *priv)
|
||||
{
|
||||
const xtkbd_t *kbd = (xtkbd_t *) priv;
|
||||
uint8_t ret = 0xff;
|
||||
|
||||
switch (port) {
|
||||
case 0x60: /* Keyboard Data Register (aka Port A) */
|
||||
if ((kbd->pb & 0x80) && ((kbd->type == KBD_TYPE_PC81) ||
|
||||
(kbd->type == KBD_TYPE_PC82) || (kbd->type == KBD_TYPE_PRAVETZ) ||
|
||||
(kbd->type == KBD_TYPE_XT82) || (kbd->type == KBD_TYPE_XT86) ||
|
||||
(kbd->type == KBD_TYPE_XTCLONE) || (kbd->type == KBD_TYPE_COMPAQ) ||
|
||||
(kbd->type == KBD_TYPE_ZENITH) || (kbd->type == KBD_TYPE_HYUNDAI) ||
|
||||
(kbd->type == KBD_TYPE_VTECH))) {
|
||||
if ((kbd->type == KBD_TYPE_PC81) || (kbd->type == KBD_TYPE_PC82) ||
|
||||
(kbd->type == KBD_TYPE_XTCLONE) || (kbd->type == KBD_TYPE_COMPAQ) ||
|
||||
(kbd->type == KBD_TYPE_PRAVETZ) || (kbd->type == KBD_TYPE_HYUNDAI))
|
||||
ret = (kbd->pd & ~0x02) | (hasfpu ? 0x02 : 0x00);
|
||||
else if ((kbd->type == KBD_TYPE_XT82) || (kbd->type == KBD_TYPE_XT86) ||
|
||||
(kbd->type == KBD_TYPE_VTECH))
|
||||
/* According to Ruud on the PCem forum, this is supposed to
|
||||
return 0xFF on the XT. */
|
||||
ret = 0xff;
|
||||
else if (kbd->type == KBD_TYPE_ZENITH) {
|
||||
/* Zenith Data Systems Z-151
|
||||
* SW1 switch settings:
|
||||
* bits 6-7: floppy drive number
|
||||
* bits 4-5: video mode
|
||||
* bit 2-3: base memory size
|
||||
* bit 1: fpu enable
|
||||
* bit 0: fdc enable
|
||||
*/
|
||||
ret = get_fdd_switch_settings();
|
||||
|
||||
ret |= get_videomode_switch_settings();
|
||||
|
||||
/* Base memory size should always be 64k */
|
||||
ret |= 0x0c;
|
||||
|
||||
if (hasfpu)
|
||||
ret |= 0x02;
|
||||
}
|
||||
} else
|
||||
ret = kbd->pa;
|
||||
break;
|
||||
|
||||
case 0x61: /* Keyboard Control Register (aka Port B) */
|
||||
ret = kbd->pb;
|
||||
break;
|
||||
|
||||
case 0x62: /* Switch Register (aka Port C) */
|
||||
if (kbd->type == KBD_TYPE_FE2010) {
|
||||
if (kbd->pb & 0x04) /* PB2 */
|
||||
ret = (kbd->pd & 0x0d) | (hasfpu ? 0x02 : 0x00);
|
||||
else
|
||||
ret = kbd->pd >> 4;
|
||||
} else if ((kbd->type == KBD_TYPE_PC81) || (kbd->type == KBD_TYPE_PC82) ||
|
||||
(kbd->type == KBD_TYPE_PRAVETZ)) {
|
||||
if (kbd->pb & 0x04) /* PB2 */
|
||||
switch (mem_size + isa_mem_size) {
|
||||
case 64:
|
||||
case 48:
|
||||
case 32:
|
||||
case 16:
|
||||
ret = 0x00;
|
||||
break;
|
||||
default:
|
||||
ret = (((mem_size + isa_mem_size) - 64) / 32) & 0x0f;
|
||||
break;
|
||||
}
|
||||
else
|
||||
ret = (((mem_size + isa_mem_size) - 64) / 32) >> 4;
|
||||
} else if ((kbd->type == KBD_TYPE_OLIVETTI) ||
|
||||
(kbd->type == KBD_TYPE_ZENITH)) {
|
||||
/* Olivetti M19 or Zenith Data Systems Z-151 */
|
||||
if (kbd->pb & 0x04) /* PB2 */
|
||||
ret = kbd->pd & 0xbf;
|
||||
else
|
||||
ret = kbd->pd >> 4;
|
||||
} else {
|
||||
if (kbd->pb & 0x08) /* PB3 */
|
||||
ret = kbd->pd >> 4;
|
||||
else
|
||||
ret = (kbd->pd & 0x0d) | (hasfpu ? 0x02 : 0x00);
|
||||
}
|
||||
ret |= (ppispeakon ? 0x20 : 0);
|
||||
|
||||
/* This is needed to avoid error 131 (cassette error).
|
||||
This is serial read: bit 5 = clock, bit 4 = data, cassette header is 256 x 0xff. */
|
||||
if ((kbd->type == KBD_TYPE_PC81) || (kbd->type == KBD_TYPE_PC82) ||
|
||||
(kbd->type == KBD_TYPE_PRAVETZ)) {
|
||||
if (cassette == NULL)
|
||||
ret |= (ppispeakon ? 0x10 : 0);
|
||||
else
|
||||
ret |= (pc_cas_get_inp(cassette) ? 0x10 : 0);
|
||||
}
|
||||
|
||||
if (kbd->type == KBD_TYPE_TANDY)
|
||||
ret |= (tandy1k_eeprom_read() ? 0x10 : 0);
|
||||
break;
|
||||
|
||||
case 0x63: /* Keyboard Configuration Register (aka Port D) */
|
||||
if ((kbd->type == KBD_TYPE_XT82) || (kbd->type == KBD_TYPE_XT86) ||
|
||||
(kbd->type == KBD_TYPE_XTCLONE) || (kbd->type == KBD_TYPE_COMPAQ) ||
|
||||
(kbd->type == KBD_TYPE_TOSHIBA) || (kbd->type == KBD_TYPE_HYUNDAI) ||
|
||||
(kbd->type == KBD_TYPE_VTECH))
|
||||
ret = kbd->pd;
|
||||
break;
|
||||
|
||||
case 0xc0: /* Pravetz Flags */
|
||||
if (kbd->type == KBD_TYPE_PRAVETZ)
|
||||
ret = kbd->pravetz_flags;
|
||||
kbd_log("XTkbd: Port %02X in : %02X\n", port, ret);
|
||||
break;
|
||||
|
||||
case 0x1f0:
|
||||
if (kbd->type == KBD_TYPE_VTECH)
|
||||
ret = kbd->cpu_speed;
|
||||
kbd_log("XTkbd: Port %04X in : %02X\n", port, ret);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
kbd_reset(void *priv)
|
||||
{
|
||||
xtkbd_t *kbd = (xtkbd_t *) priv;
|
||||
|
||||
kbd->want_irq = 0;
|
||||
kbd->blocked = 0;
|
||||
kbd->pa = 0x00;
|
||||
kbd->pb = 0x00;
|
||||
kbd->pravetz_flags = 0x00;
|
||||
|
||||
keyboard_scan = 1;
|
||||
|
||||
key_queue_start = 0;
|
||||
key_queue_end = 0;
|
||||
}
|
||||
|
||||
void
|
||||
keyboard_set_is_amstrad(int ams)
|
||||
{
|
||||
is_amstrad = ams;
|
||||
}
|
||||
|
||||
static void *
|
||||
kbd_init(const device_t *info)
|
||||
{
|
||||
xtkbd_t *kbd;
|
||||
|
||||
kbd = (xtkbd_t *) calloc(1, sizeof(xtkbd_t));
|
||||
|
||||
io_sethandler(0x0060, 4,
|
||||
kbd_read, NULL, NULL, kbd_write, NULL, NULL, kbd);
|
||||
keyboard_send = kbd_adddata_ex;
|
||||
kbd->type = info->local;
|
||||
if (kbd->type == KBD_TYPE_VTECH)
|
||||
kbd->cpu_speed = (!!cpu) << 2;
|
||||
kbd_reset(kbd);
|
||||
if (kbd->type == KBD_TYPE_PRAVETZ)
|
||||
io_sethandler(0x00c0, 16,
|
||||
kbd_read, NULL, NULL, kbd_write, NULL, NULL, kbd);
|
||||
if (kbd->type == KBD_TYPE_VTECH)
|
||||
io_sethandler(0x01f0, 1,
|
||||
kbd_read, NULL, NULL, kbd_write, NULL, NULL, kbd);
|
||||
|
||||
key_queue_start = key_queue_end = 0;
|
||||
|
||||
video_reset(gfxcard[0]);
|
||||
|
||||
if ((kbd->type == KBD_TYPE_PC81) || (kbd->type == KBD_TYPE_PC82) ||
|
||||
(kbd->type == KBD_TYPE_PRAVETZ) || (kbd->type == KBD_TYPE_XT82) ||
|
||||
(kbd->type <= KBD_TYPE_XT86) || (kbd->type == KBD_TYPE_XTCLONE) ||
|
||||
(kbd->type == KBD_TYPE_COMPAQ) || (kbd->type == KBD_TYPE_TOSHIBA) ||
|
||||
(kbd->type == KBD_TYPE_OLIVETTI) || (kbd->type == KBD_TYPE_HYUNDAI) ||
|
||||
(kbd->type == KBD_TYPE_VTECH) || (kbd->type == KBD_TYPE_FE2010)) {
|
||||
/* DIP switch readout: bit set = OFF, clear = ON. */
|
||||
if (kbd->type == KBD_TYPE_OLIVETTI)
|
||||
/* Olivetti M19
|
||||
* Jumpers J1, J2 - monitor type.
|
||||
* 01 - mono (high-res)
|
||||
* 10 - color (low-res, disables 640x400x2 mode)
|
||||
* 00 - autoswitching
|
||||
*/
|
||||
kbd->pd |= 0x00;
|
||||
else
|
||||
/* Switches 7, 8 - floppy drives. */
|
||||
kbd->pd = get_fdd_switch_settings();
|
||||
|
||||
/* Switches 5, 6 - video card type */
|
||||
kbd->pd |= get_videomode_switch_settings();
|
||||
|
||||
/* Switches 3, 4 - memory size. */
|
||||
if ((kbd->type == KBD_TYPE_XT86) || (kbd->type == KBD_TYPE_XTCLONE) ||
|
||||
(kbd->type == KBD_TYPE_HYUNDAI) || (kbd->type == KBD_TYPE_COMPAQ) ||
|
||||
(kbd->type == KBD_TYPE_TOSHIBA) || (kbd->type == KBD_TYPE_FE2010)) {
|
||||
switch (mem_size) {
|
||||
case 256:
|
||||
kbd->pd |= 0x00;
|
||||
break;
|
||||
case 512:
|
||||
kbd->pd |= 0x04;
|
||||
break;
|
||||
case 576:
|
||||
kbd->pd |= 0x08;
|
||||
break;
|
||||
case 640:
|
||||
default:
|
||||
kbd->pd |= 0x0c;
|
||||
break;
|
||||
}
|
||||
} else if ((kbd->type == KBD_TYPE_XT82) || (kbd->type == KBD_TYPE_VTECH)) {
|
||||
switch (mem_size) {
|
||||
case 64: /* 1x64k */
|
||||
kbd->pd |= 0x00;
|
||||
break;
|
||||
case 128: /* 2x64k */
|
||||
kbd->pd |= 0x04;
|
||||
break;
|
||||
case 192: /* 3x64k */
|
||||
kbd->pd |= 0x08;
|
||||
break;
|
||||
case 256: /* 4x64k */
|
||||
default:
|
||||
kbd->pd |= 0x0c;
|
||||
break;
|
||||
}
|
||||
} else if (kbd->type == KBD_TYPE_PC82) {
|
||||
switch (mem_size) {
|
||||
#ifdef PC82_192K_3BANK
|
||||
case 192: /* 3x64k, not supported by stock BIOS due to bugs */
|
||||
kbd->pd |= 0x08;
|
||||
break;
|
||||
#else
|
||||
case 192: /* 2x64k + 2x32k */
|
||||
#endif
|
||||
case 64: /* 4x16k */
|
||||
case 96: /* 2x32k + 2x16k */
|
||||
case 128: /* 4x32k */
|
||||
case 160: /* 2x64k + 2x16k */
|
||||
case 224: /* 3x64k + 1x32k */
|
||||
case 256: /* 4x64k */
|
||||
default:
|
||||
kbd->pd |= 0x0c;
|
||||
break;
|
||||
}
|
||||
} else { /* really just the PC '81 */
|
||||
switch (mem_size) {
|
||||
case 16: /* 1x16k */
|
||||
kbd->pd |= 0x00;
|
||||
break;
|
||||
case 32: /* 2x16k */
|
||||
kbd->pd |= 0x04;
|
||||
break;
|
||||
case 48: /* 3x16k */
|
||||
kbd->pd |= 0x08;
|
||||
break;
|
||||
case 64: /* 4x16k */
|
||||
default:
|
||||
kbd->pd |= 0x0c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Switch 2 - 8087 FPU. */
|
||||
if (hasfpu)
|
||||
kbd->pd |= 0x02;
|
||||
} else if (kbd->type == KBD_TYPE_ZENITH) {
|
||||
/* Zenith Data Systems Z-151
|
||||
* SW2 switch settings:
|
||||
* bit 7: monitor frequency
|
||||
* bits 5-6: autoboot (00-11 resident monitor, 10 hdd, 01 fdd)
|
||||
* bits 0-4: installed memory
|
||||
*/
|
||||
kbd->pd = 0x20;
|
||||
switch (mem_size) {
|
||||
case 128:
|
||||
kbd->pd |= 0x02;
|
||||
break;
|
||||
case 192:
|
||||
kbd->pd |= 0x04;
|
||||
break;
|
||||
case 256:
|
||||
kbd->pd |= 0x06;
|
||||
break;
|
||||
case 320:
|
||||
kbd->pd |= 0x08;
|
||||
break;
|
||||
case 384:
|
||||
kbd->pd |= 0x0a;
|
||||
break;
|
||||
case 448:
|
||||
kbd->pd |= 0x0c;
|
||||
break;
|
||||
case 512:
|
||||
kbd->pd |= 0x0e;
|
||||
break;
|
||||
case 576:
|
||||
kbd->pd |= 0x10;
|
||||
break;
|
||||
case 640:
|
||||
default:
|
||||
kbd->pd |= 0x12;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
timer_add(&kbd->send_delay_timer, kbd_poll, kbd, 1);
|
||||
|
||||
is_tandy = (kbd->type == KBD_TYPE_TANDY);
|
||||
is_t1x00 = (kbd->type == KBD_TYPE_TOSHIBA);
|
||||
|
||||
if (keyboard_type == KEYBOARD_TYPE_INTERNAL)
|
||||
keyboard_set_table(scancode_xt);
|
||||
else
|
||||
keyboard_add_device();
|
||||
|
||||
is_amstrad = 0;
|
||||
|
||||
return kbd;
|
||||
}
|
||||
|
||||
static void
|
||||
kbd_close(void *priv)
|
||||
{
|
||||
xtkbd_t *kbd = (xtkbd_t *) priv;
|
||||
|
||||
/* Stop the timer. */
|
||||
timer_disable(&kbd->send_delay_timer);
|
||||
|
||||
/* Disable scanning. */
|
||||
keyboard_scan = 0;
|
||||
|
||||
keyboard_send = NULL;
|
||||
|
||||
io_removehandler(0x0060, 4,
|
||||
kbd_read, NULL, NULL, kbd_write, NULL, NULL, kbd);
|
||||
|
||||
free(kbd);
|
||||
}
|
||||
|
||||
const device_t kbc_pc_device = {
|
||||
.name = "IBM PC Keyboard Controller (1981)",
|
||||
.internal_name = "kbc_pc",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_PC81,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t kbc_pc82_device = {
|
||||
.name = "IBM PC Keyboard Controller (1982)",
|
||||
.internal_name = "kbc_pc82",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_PC82,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t kbc_pravetz_device = {
|
||||
.name = "Pravetz Keyboard Controller",
|
||||
.internal_name = "kbc_pravetz",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_PRAVETZ,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t kbc_xt_device = {
|
||||
.name = "XT (1982) Keyboard Controller",
|
||||
.internal_name = "kbc_xt",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_XT82,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t kbc_xt86_device = {
|
||||
.name = "XT (1986) Keyboard Controller",
|
||||
.internal_name = "kbc_xt86",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_XT86,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t kbc_xt_compaq_device = {
|
||||
.name = "Compaq Portable Keyboard Controller",
|
||||
.internal_name = "kbc_xt_compaq",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_COMPAQ,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t kbc_tandy_device = {
|
||||
.name = "Tandy 1000 Keyboard Controller",
|
||||
.internal_name = "kbc_tandy",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_TANDY,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t kbc_xt_t1x00_device = {
|
||||
.name = "Toshiba T1x00 Keyboard Controller",
|
||||
.internal_name = "kbc_xt_t1x00",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_TOSHIBA,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t kbc_xt_lxt3_device = {
|
||||
.name = "VTech Laser Turbo XT Keyboard Controller",
|
||||
.internal_name = "kbc_xt_lxt",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_VTECH,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t kbc_xt_olivetti_device = {
|
||||
.name = "Olivetti XT Keyboard Controller",
|
||||
.internal_name = "kbc_xt_olivetti",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_OLIVETTI,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t kbc_xt_zenith_device = {
|
||||
.name = "Zenith XT Keyboard Controller",
|
||||
.internal_name = "kbc_xt_zenith",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_ZENITH,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t kbc_xt_hyundai_device = {
|
||||
.name = "Hyundai XT Keyboard Controller",
|
||||
.internal_name = "kbc_xt_hyundai",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_HYUNDAI,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t kbc_xt_fe2010_device = {
|
||||
.name = "Faraday FE2010 XT Keyboard Controller",
|
||||
.internal_name = "kbc_xt_fe2010",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_FE2010,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t kbc_xtclone_device = {
|
||||
.name = "XT (Clone) Keyboard Controller",
|
||||
.internal_name = "kbc_xtclone",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_XTCLONE,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
@@ -27,6 +27,7 @@
|
||||
#define HAVE_STDARG_H
|
||||
#include <86box/86box.h>
|
||||
#include <86box/machine.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/keyboard.h>
|
||||
#include <86box/plat.h>
|
||||
|
||||
@@ -36,6 +37,38 @@ uint16_t scancode_map[768] = { 0 };
|
||||
|
||||
int keyboard_scan;
|
||||
|
||||
typedef struct keyboard_t {
|
||||
const device_t *device;
|
||||
} keyboard_t;
|
||||
|
||||
int keyboard_type = 0;
|
||||
|
||||
static const device_t keyboard_internal_device = {
|
||||
.name = "Internal",
|
||||
.internal_name = "internal",
|
||||
.flags = 0,
|
||||
.local = KEYBOARD_TYPE_INTERNAL,
|
||||
.init = NULL,
|
||||
.close = NULL,
|
||||
.reset = NULL,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
static keyboard_t keyboard_devices[] = {
|
||||
// clang-format off
|
||||
{ &keyboard_internal_device },
|
||||
{ &keyboard_pc_xt_device },
|
||||
{ &keyboard_at_device },
|
||||
{ &keyboard_ax_device },
|
||||
{ &keyboard_ps2_device },
|
||||
{ &keyboard_ps55_device },
|
||||
{ NULL }
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
#ifdef ENABLE_KBC_AT_LOG
|
||||
int kbc_at_do_log = ENABLE_KBC_AT_LOG;
|
||||
|
||||
@@ -516,3 +549,57 @@ convert_scan_code(uint16_t scan_code)
|
||||
|
||||
return scan_code;
|
||||
}
|
||||
|
||||
const char *
|
||||
keyboard_get_name(int keyboard)
|
||||
{
|
||||
return (keyboard_devices[keyboard].device->name);
|
||||
}
|
||||
|
||||
const char *
|
||||
keyboard_get_internal_name(int keyboard)
|
||||
{
|
||||
return device_get_internal_name(keyboard_devices[keyboard].device);
|
||||
}
|
||||
|
||||
int
|
||||
keyboard_get_from_internal_name(char *s)
|
||||
{
|
||||
int c = 0;
|
||||
|
||||
while (keyboard_devices[c].device != NULL) {
|
||||
if (!strcmp((char *) keyboard_devices[c].device->internal_name, s))
|
||||
return c;
|
||||
c++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
keyboard_has_config(int keyboard)
|
||||
{
|
||||
if (keyboard_devices[keyboard].device == NULL)
|
||||
return 0;
|
||||
|
||||
return (keyboard_devices[keyboard].device->config ? 1 : 0);
|
||||
}
|
||||
|
||||
const device_t *
|
||||
keyboard_get_device(int keyboard)
|
||||
{
|
||||
return (keyboard_devices[keyboard].device);
|
||||
}
|
||||
|
||||
/* Return number of MOUSE types we know about. */
|
||||
int
|
||||
keyboard_get_ndev(void)
|
||||
{
|
||||
return ((sizeof(keyboard_devices) / sizeof(keyboard_t)) - 1);
|
||||
}
|
||||
|
||||
void
|
||||
keyboard_add_device(void)
|
||||
{
|
||||
device_add(keyboard_devices[keyboard_type].device);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -35,62 +35,8 @@
|
||||
#include <86box/machine.h>
|
||||
#include <86box/m_xt_t1000.h>
|
||||
#include <86box/cassette.h>
|
||||
#include <86box/io.h>
|
||||
#include <86box/pic.h>
|
||||
#include <86box/pit.h>
|
||||
#include <86box/ppi.h>
|
||||
#include <86box/mem.h>
|
||||
#include <86box/rom.h>
|
||||
#include <86box/sound.h>
|
||||
#include <86box/snd_speaker.h>
|
||||
#include <86box/video.h>
|
||||
#include <86box/keyboard.h>
|
||||
|
||||
#define STAT_PARITY 0x80
|
||||
#define STAT_RTIMEOUT 0x40
|
||||
#define STAT_TTIMEOUT 0x20
|
||||
#define STAT_LOCK 0x10
|
||||
#define STAT_CD 0x08
|
||||
#define STAT_SYSFLAG 0x04
|
||||
#define STAT_IFULL 0x02
|
||||
#define STAT_OFULL 0x01
|
||||
|
||||
/* Keyboard Types */
|
||||
enum {
|
||||
KBD_TYPE_PC81 = 0,
|
||||
KBD_TYPE_PC82,
|
||||
KBD_TYPE_XT82,
|
||||
KBD_TYPE_XT86,
|
||||
KBD_TYPE_COMPAQ,
|
||||
KBD_TYPE_TANDY,
|
||||
KBD_TYPE_TOSHIBA,
|
||||
KBD_TYPE_VTECH,
|
||||
KBD_TYPE_OLIVETTI,
|
||||
KBD_TYPE_ZENITH,
|
||||
KBD_TYPE_PRAVETZ,
|
||||
KBD_TYPE_HYUNDAI,
|
||||
KBD_TYPE_FE2010,
|
||||
KBD_TYPE_XTCLONE
|
||||
};
|
||||
|
||||
typedef struct xtkbd_t {
|
||||
int want_irq;
|
||||
int blocked;
|
||||
int tandy;
|
||||
|
||||
uint8_t pa;
|
||||
uint8_t pb;
|
||||
uint8_t pd;
|
||||
uint8_t cfg;
|
||||
uint8_t clock;
|
||||
uint8_t key_waiting;
|
||||
uint8_t type;
|
||||
uint8_t pravetz_flags;
|
||||
uint8_t cpu_speed;
|
||||
|
||||
pc_timer_t send_delay_timer;
|
||||
} xtkbd_t;
|
||||
|
||||
/*XT keyboard has no escape scancodes, and no scancodes beyond 53*/
|
||||
const scancode scancode_xt[512] = {
|
||||
// clang-format off
|
||||
@@ -609,810 +555,66 @@ const scancode scancode_xt[512] = {
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static uint8_t key_queue[16];
|
||||
static int key_queue_start = 0;
|
||||
static int key_queue_end = 0;
|
||||
static int is_tandy = 0;
|
||||
static int is_t1x00 = 0;
|
||||
static int is_amstrad = 0;
|
||||
|
||||
#ifdef ENABLE_KEYBOARD_XT_LOG
|
||||
int keyboard_xt_do_log = ENABLE_KEYBOARD_XT_LOG;
|
||||
|
||||
static void
|
||||
kbd_log(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (keyboard_xt_do_log) {
|
||||
va_start(ap, fmt);
|
||||
pclog_ex(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define kbd_log(fmt, ...)
|
||||
#endif
|
||||
|
||||
static uint8_t
|
||||
get_fdd_switch_settings(void)
|
||||
{
|
||||
|
||||
uint8_t fdd_count = 0;
|
||||
|
||||
for (uint8_t i = 0; i < FDD_NUM; i++) {
|
||||
if (fdd_get_flags(i))
|
||||
fdd_count++;
|
||||
}
|
||||
|
||||
if (!fdd_count)
|
||||
return 0x00;
|
||||
else
|
||||
return ((fdd_count - 1) << 6) | 0x01;
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
get_videomode_switch_settings(void)
|
||||
{
|
||||
|
||||
if (video_is_mda())
|
||||
return 0x30;
|
||||
else if (video_is_cga())
|
||||
return 0x20; /* 0x10 would be 40x25 */
|
||||
else
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
static void
|
||||
kbd_poll(void *priv)
|
||||
{
|
||||
xtkbd_t *kbd = (xtkbd_t *) priv;
|
||||
|
||||
timer_advance_u64(&kbd->send_delay_timer, 1000 * TIMER_USEC);
|
||||
|
||||
if (!(kbd->pb & 0x40) && (kbd->type != KBD_TYPE_TANDY))
|
||||
return;
|
||||
|
||||
if (kbd->want_irq) {
|
||||
kbd->want_irq = 0;
|
||||
kbd->pa = kbd->key_waiting;
|
||||
kbd->blocked = 1;
|
||||
picint(2);
|
||||
#ifdef ENABLE_KEYBOARD_XT_LOG
|
||||
kbd_log("XTkbd: kbd_poll(): keyboard_xt : take IRQ\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
if ((key_queue_start != key_queue_end) && !kbd->blocked) {
|
||||
kbd->key_waiting = key_queue[key_queue_start];
|
||||
kbd_log("XTkbd: reading %02X from the key queue at %i\n",
|
||||
kbd->key_waiting, key_queue_start);
|
||||
key_queue_start = (key_queue_start + 1) & 0x0f;
|
||||
kbd->want_irq = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
kbd_adddata(uint16_t val)
|
||||
{
|
||||
/* Test for T1000 'Fn' key (Right Alt / Right Ctrl) */
|
||||
if (is_t1x00) {
|
||||
if (keyboard_recv(0x138) || keyboard_recv(0x11d)) { /* 'Fn' pressed */
|
||||
t1000_syskey(0x00, 0x04, 0x00); /* Set 'Fn' indicator */
|
||||
switch (val) {
|
||||
case 0x45: /* Num Lock => toggle numpad */
|
||||
t1000_syskey(0x00, 0x00, 0x10);
|
||||
break;
|
||||
case 0x47: /* Home => internal display */
|
||||
t1000_syskey(0x40, 0x00, 0x00);
|
||||
break;
|
||||
case 0x49: /* PgDn => turbo on */
|
||||
t1000_syskey(0x80, 0x00, 0x00);
|
||||
break;
|
||||
case 0x4D: /* Right => toggle LCD font */
|
||||
t1000_syskey(0x00, 0x00, 0x20);
|
||||
break;
|
||||
case 0x4F: /* End => external display */
|
||||
t1000_syskey(0x00, 0x40, 0x00);
|
||||
break;
|
||||
case 0x51: /* PgDn => turbo off */
|
||||
t1000_syskey(0x00, 0x80, 0x00);
|
||||
break;
|
||||
case 0x54: /* SysRQ => toggle window */
|
||||
t1000_syskey(0x00, 0x00, 0x08);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else
|
||||
t1000_syskey(0x04, 0x00, 0x00); /* Reset 'Fn' indicator */
|
||||
}
|
||||
|
||||
key_queue[key_queue_end] = val;
|
||||
kbd_log("XTkbd: %02X added to key queue at %i\n",
|
||||
val, key_queue_end);
|
||||
key_queue_end = (key_queue_end + 1) & 0x0f;
|
||||
}
|
||||
|
||||
void
|
||||
kbd_adddata_process(uint16_t val, void (*adddata)(uint16_t val))
|
||||
{
|
||||
uint8_t num_lock = 0;
|
||||
uint8_t shift_states = 0;
|
||||
|
||||
if (!adddata)
|
||||
return;
|
||||
|
||||
keyboard_get_states(NULL, &num_lock, NULL, NULL);
|
||||
shift_states = keyboard_get_shift() & STATE_LSHIFT;
|
||||
|
||||
if (is_amstrad)
|
||||
num_lock = !num_lock;
|
||||
|
||||
/* If NumLock is on, invert the left shift state so we can always check for
|
||||
the the same way flag being set (and with NumLock on that then means it
|
||||
is actually *NOT* set). */
|
||||
if (num_lock)
|
||||
shift_states ^= STATE_LSHIFT;
|
||||
|
||||
switch (val) {
|
||||
case FAKE_LSHIFT_ON:
|
||||
/* If NumLock is on, fake shifts are sent when shift is *NOT* presed,
|
||||
if NumLock is off, fake shifts are sent when shift is pressed. */
|
||||
if (shift_states) {
|
||||
/* Send fake shift. */
|
||||
adddata(num_lock ? 0x2a : 0xaa);
|
||||
}
|
||||
break;
|
||||
case FAKE_LSHIFT_OFF:
|
||||
if (shift_states) {
|
||||
/* Send fake shift. */
|
||||
adddata(num_lock ? 0xaa : 0x2a);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
adddata(val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
kbd_adddata_ex(uint16_t val)
|
||||
{
|
||||
kbd_adddata_process(val, kbd_adddata);
|
||||
}
|
||||
|
||||
static void
|
||||
kbd_write(uint16_t port, uint8_t val, void *priv)
|
||||
{
|
||||
xtkbd_t *kbd = (xtkbd_t *) priv;
|
||||
uint8_t bit;
|
||||
uint8_t set;
|
||||
uint8_t new_clock;
|
||||
|
||||
switch (port) {
|
||||
case 0x61: /* Keyboard Control Register (aka Port B) */
|
||||
if (!(val & 0x80) || (kbd->type == KBD_TYPE_HYUNDAI)) {
|
||||
new_clock = !!(val & 0x40);
|
||||
if (!kbd->clock && new_clock) {
|
||||
key_queue_start = key_queue_end = 0;
|
||||
kbd->want_irq = 0;
|
||||
kbd->blocked = 0;
|
||||
kbd_adddata(0xaa);
|
||||
}
|
||||
}
|
||||
|
||||
kbd->pb = val;
|
||||
if (!(kbd->pb & 0x80) || (kbd->type == KBD_TYPE_HYUNDAI))
|
||||
kbd->clock = !!(kbd->pb & 0x40);
|
||||
ppi.pb = val;
|
||||
|
||||
timer_process();
|
||||
|
||||
if (((kbd->type == KBD_TYPE_PC81) || (kbd->type == KBD_TYPE_PC82) ||
|
||||
(kbd->type == KBD_TYPE_PRAVETZ)) && (cassette != NULL))
|
||||
pc_cas_set_motor(cassette, (kbd->pb & 0x08) == 0);
|
||||
|
||||
speaker_update();
|
||||
|
||||
speaker_gated = val & 1;
|
||||
speaker_enable = val & 2;
|
||||
|
||||
if (speaker_enable)
|
||||
was_speaker_enable = 1;
|
||||
pit_devs[0].set_gate(pit_devs[0].data, 2, val & 1);
|
||||
|
||||
if (val & 0x80) {
|
||||
kbd->pa = 0;
|
||||
kbd->blocked = 0;
|
||||
picintc(2);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_KEYBOARD_XT_LOG
|
||||
if ((kbd->type == KBD_TYPE_PC81) || (kbd->type == KBD_TYPE_PC82) || (kbd->type == KBD_TYPE_PRAVETZ))
|
||||
kbd_log("XTkbd: Cassette motor is %s\n", !(val & 0x08) ? "ON" : "OFF");
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 0x62: /* Switch Register (aka Port C) */
|
||||
#ifdef ENABLE_KEYBOARD_XT_LOG
|
||||
if ((kbd->type == KBD_TYPE_PC81) || (kbd->type == KBD_TYPE_PC82) || (kbd->type == KBD_TYPE_PRAVETZ))
|
||||
kbd_log("XTkbd: Cassette IN is %i\n", !!(val & 0x10));
|
||||
#endif
|
||||
if (kbd->type == KBD_TYPE_FE2010) {
|
||||
kbd_log("XTkbd: Switch register in is %02X\n", val);
|
||||
if (!(kbd->cfg & 0x08))
|
||||
kbd->pd = (kbd->pd & 0x30) | (val & 0xcf);
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x63:
|
||||
if (kbd->type == KBD_TYPE_FE2010) {
|
||||
kbd_log("XTkbd: Configuration register in is %02X\n", val);
|
||||
if (!(kbd->cfg & 0x08))
|
||||
kbd->cfg = val;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0xc0 ... 0xcf: /* Pravetz Flags */
|
||||
kbd_log("XTkbd: Port %02X out: %02X\n", port, val);
|
||||
if (kbd->type == KBD_TYPE_PRAVETZ) {
|
||||
bit = (port >> 1) & 0x07;
|
||||
set = (port & 0x01) << bit;
|
||||
kbd->pravetz_flags = (kbd->pravetz_flags & ~(1 << bit)) | set;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x1f0:
|
||||
kbd_log("XTkbd: Port %04X out: %02X\n", port, val);
|
||||
if (kbd->type == KBD_TYPE_VTECH) {
|
||||
kbd->cpu_speed = val;
|
||||
cpu_dynamic_switch(kbd->cpu_speed >> 7);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
kbd_read(uint16_t port, void *priv)
|
||||
{
|
||||
const xtkbd_t *kbd = (xtkbd_t *) priv;
|
||||
uint8_t ret = 0xff;
|
||||
|
||||
switch (port) {
|
||||
case 0x60: /* Keyboard Data Register (aka Port A) */
|
||||
if ((kbd->pb & 0x80) && ((kbd->type == KBD_TYPE_PC81) ||
|
||||
(kbd->type == KBD_TYPE_PC82) || (kbd->type == KBD_TYPE_PRAVETZ) ||
|
||||
(kbd->type == KBD_TYPE_XT82) || (kbd->type == KBD_TYPE_XT86) ||
|
||||
(kbd->type == KBD_TYPE_XTCLONE) || (kbd->type == KBD_TYPE_COMPAQ) ||
|
||||
(kbd->type == KBD_TYPE_ZENITH) || (kbd->type == KBD_TYPE_HYUNDAI) ||
|
||||
(kbd->type == KBD_TYPE_VTECH))) {
|
||||
if ((kbd->type == KBD_TYPE_PC81) || (kbd->type == KBD_TYPE_PC82) ||
|
||||
(kbd->type == KBD_TYPE_XTCLONE) || (kbd->type == KBD_TYPE_COMPAQ) ||
|
||||
(kbd->type == KBD_TYPE_PRAVETZ) || (kbd->type == KBD_TYPE_HYUNDAI))
|
||||
ret = (kbd->pd & ~0x02) | (hasfpu ? 0x02 : 0x00);
|
||||
else if ((kbd->type == KBD_TYPE_XT82) || (kbd->type == KBD_TYPE_XT86) ||
|
||||
(kbd->type == KBD_TYPE_VTECH))
|
||||
/* According to Ruud on the PCem forum, this is supposed to
|
||||
return 0xFF on the XT. */
|
||||
ret = 0xff;
|
||||
else if (kbd->type == KBD_TYPE_ZENITH) {
|
||||
/* Zenith Data Systems Z-151
|
||||
* SW1 switch settings:
|
||||
* bits 6-7: floppy drive number
|
||||
* bits 4-5: video mode
|
||||
* bit 2-3: base memory size
|
||||
* bit 1: fpu enable
|
||||
* bit 0: fdc enable
|
||||
*/
|
||||
ret = get_fdd_switch_settings();
|
||||
|
||||
ret |= get_videomode_switch_settings();
|
||||
|
||||
/* Base memory size should always be 64k */
|
||||
ret |= 0x0c;
|
||||
|
||||
if (hasfpu)
|
||||
ret |= 0x02;
|
||||
}
|
||||
} else
|
||||
ret = kbd->pa;
|
||||
break;
|
||||
|
||||
case 0x61: /* Keyboard Control Register (aka Port B) */
|
||||
ret = kbd->pb;
|
||||
break;
|
||||
|
||||
case 0x62: /* Switch Register (aka Port C) */
|
||||
if (kbd->type == KBD_TYPE_FE2010) {
|
||||
if (kbd->pb & 0x04) /* PB2 */
|
||||
ret = (kbd->pd & 0x0d) | (hasfpu ? 0x02 : 0x00);
|
||||
else
|
||||
ret = kbd->pd >> 4;
|
||||
} else if ((kbd->type == KBD_TYPE_PC81) || (kbd->type == KBD_TYPE_PC82) ||
|
||||
(kbd->type == KBD_TYPE_PRAVETZ)) {
|
||||
if (kbd->pb & 0x04) /* PB2 */
|
||||
switch (mem_size + isa_mem_size) {
|
||||
case 64:
|
||||
case 48:
|
||||
case 32:
|
||||
case 16:
|
||||
ret = 0x00;
|
||||
break;
|
||||
default:
|
||||
ret = (((mem_size + isa_mem_size) - 64) / 32) & 0x0f;
|
||||
break;
|
||||
}
|
||||
else
|
||||
ret = (((mem_size + isa_mem_size) - 64) / 32) >> 4;
|
||||
} else if ((kbd->type == KBD_TYPE_OLIVETTI) ||
|
||||
(kbd->type == KBD_TYPE_ZENITH)) {
|
||||
/* Olivetti M19 or Zenith Data Systems Z-151 */
|
||||
if (kbd->pb & 0x04) /* PB2 */
|
||||
ret = kbd->pd & 0xbf;
|
||||
else
|
||||
ret = kbd->pd >> 4;
|
||||
} else {
|
||||
if (kbd->pb & 0x08) /* PB3 */
|
||||
ret = kbd->pd >> 4;
|
||||
else
|
||||
ret = (kbd->pd & 0x0d) | (hasfpu ? 0x02 : 0x00);
|
||||
}
|
||||
ret |= (ppispeakon ? 0x20 : 0);
|
||||
|
||||
/* This is needed to avoid error 131 (cassette error).
|
||||
This is serial read: bit 5 = clock, bit 4 = data, cassette header is 256 x 0xff. */
|
||||
if ((kbd->type == KBD_TYPE_PC81) || (kbd->type == KBD_TYPE_PC82) ||
|
||||
(kbd->type == KBD_TYPE_PRAVETZ)) {
|
||||
if (cassette == NULL)
|
||||
ret |= (ppispeakon ? 0x10 : 0);
|
||||
else
|
||||
ret |= (pc_cas_get_inp(cassette) ? 0x10 : 0);
|
||||
}
|
||||
|
||||
if (kbd->type == KBD_TYPE_TANDY)
|
||||
ret |= (tandy1k_eeprom_read() ? 0x10 : 0);
|
||||
break;
|
||||
|
||||
case 0x63: /* Keyboard Configuration Register (aka Port D) */
|
||||
if ((kbd->type == KBD_TYPE_XT82) || (kbd->type == KBD_TYPE_XT86) ||
|
||||
(kbd->type == KBD_TYPE_XTCLONE) || (kbd->type == KBD_TYPE_COMPAQ) ||
|
||||
(kbd->type == KBD_TYPE_TOSHIBA) || (kbd->type == KBD_TYPE_HYUNDAI) ||
|
||||
(kbd->type == KBD_TYPE_VTECH))
|
||||
ret = kbd->pd;
|
||||
break;
|
||||
|
||||
case 0xc0: /* Pravetz Flags */
|
||||
if (kbd->type == KBD_TYPE_PRAVETZ)
|
||||
ret = kbd->pravetz_flags;
|
||||
kbd_log("XTkbd: Port %02X in : %02X\n", port, ret);
|
||||
break;
|
||||
|
||||
case 0x1f0:
|
||||
if (kbd->type == KBD_TYPE_VTECH)
|
||||
ret = kbd->cpu_speed;
|
||||
kbd_log("XTkbd: Port %04X in : %02X\n", port, ret);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
kbd_reset(void *priv)
|
||||
{
|
||||
xtkbd_t *kbd = (xtkbd_t *) priv;
|
||||
|
||||
kbd->want_irq = 0;
|
||||
kbd->blocked = 0;
|
||||
kbd->pa = 0x00;
|
||||
kbd->pb = 0x00;
|
||||
kbd->pravetz_flags = 0x00;
|
||||
|
||||
keyboard_scan = 1;
|
||||
|
||||
key_queue_start = 0;
|
||||
key_queue_end = 0;
|
||||
}
|
||||
|
||||
void
|
||||
keyboard_set_is_amstrad(int ams)
|
||||
{
|
||||
is_amstrad = ams;
|
||||
}
|
||||
typedef struct {
|
||||
int type;
|
||||
} kbd_t;
|
||||
|
||||
static void *
|
||||
kbd_init(const device_t *info)
|
||||
{
|
||||
xtkbd_t *kbd;
|
||||
kbd_t *dev = (kbd_t *) calloc(1, sizeof(kbd_t));
|
||||
|
||||
kbd = (xtkbd_t *) calloc(1, sizeof(xtkbd_t));
|
||||
dev->type = info->local;
|
||||
|
||||
io_sethandler(0x0060, 4,
|
||||
kbd_read, NULL, NULL, kbd_write, NULL, NULL, kbd);
|
||||
keyboard_send = kbd_adddata_ex;
|
||||
kbd->type = info->local;
|
||||
if (kbd->type == KBD_TYPE_VTECH)
|
||||
kbd->cpu_speed = (!!cpu) << 2;
|
||||
kbd_reset(kbd);
|
||||
if (kbd->type == KBD_TYPE_PRAVETZ)
|
||||
io_sethandler(0x00c0, 16,
|
||||
kbd_read, NULL, NULL, kbd_write, NULL, NULL, kbd);
|
||||
if (kbd->type == KBD_TYPE_VTECH)
|
||||
io_sethandler(0x01f0, 1,
|
||||
kbd_read, NULL, NULL, kbd_write, NULL, NULL, kbd);
|
||||
if (dev->type == KBD_83_KEY)
|
||||
keyboard_set_table(scancode_xt);
|
||||
else
|
||||
keyboard_set_table(scancode_set1);
|
||||
|
||||
key_queue_start = key_queue_end = 0;
|
||||
|
||||
video_reset(gfxcard[0]);
|
||||
|
||||
if ((kbd->type == KBD_TYPE_PC81) || (kbd->type == KBD_TYPE_PC82) ||
|
||||
(kbd->type == KBD_TYPE_PRAVETZ) || (kbd->type == KBD_TYPE_XT82) ||
|
||||
(kbd->type <= KBD_TYPE_XT86) || (kbd->type == KBD_TYPE_XTCLONE) ||
|
||||
(kbd->type == KBD_TYPE_COMPAQ) || (kbd->type == KBD_TYPE_TOSHIBA) ||
|
||||
(kbd->type == KBD_TYPE_OLIVETTI) || (kbd->type == KBD_TYPE_HYUNDAI) ||
|
||||
(kbd->type == KBD_TYPE_VTECH) || (kbd->type == KBD_TYPE_FE2010)) {
|
||||
/* DIP switch readout: bit set = OFF, clear = ON. */
|
||||
if (kbd->type == KBD_TYPE_OLIVETTI)
|
||||
/* Olivetti M19
|
||||
* Jumpers J1, J2 - monitor type.
|
||||
* 01 - mono (high-res)
|
||||
* 10 - color (low-res, disables 640x400x2 mode)
|
||||
* 00 - autoswitching
|
||||
*/
|
||||
kbd->pd |= 0x00;
|
||||
else
|
||||
/* Switches 7, 8 - floppy drives. */
|
||||
kbd->pd = get_fdd_switch_settings();
|
||||
|
||||
/* Switches 5, 6 - video card type */
|
||||
kbd->pd |= get_videomode_switch_settings();
|
||||
|
||||
/* Switches 3, 4 - memory size. */
|
||||
if ((kbd->type == KBD_TYPE_XT86) || (kbd->type == KBD_TYPE_XTCLONE) ||
|
||||
(kbd->type == KBD_TYPE_HYUNDAI) || (kbd->type == KBD_TYPE_COMPAQ) ||
|
||||
(kbd->type == KBD_TYPE_TOSHIBA) || (kbd->type == KBD_TYPE_FE2010)) {
|
||||
switch (mem_size) {
|
||||
case 256:
|
||||
kbd->pd |= 0x00;
|
||||
break;
|
||||
case 512:
|
||||
kbd->pd |= 0x04;
|
||||
break;
|
||||
case 576:
|
||||
kbd->pd |= 0x08;
|
||||
break;
|
||||
case 640:
|
||||
default:
|
||||
kbd->pd |= 0x0c;
|
||||
break;
|
||||
}
|
||||
} else if ((kbd->type == KBD_TYPE_XT82) || (kbd->type == KBD_TYPE_VTECH)) {
|
||||
switch (mem_size) {
|
||||
case 64: /* 1x64k */
|
||||
kbd->pd |= 0x00;
|
||||
break;
|
||||
case 128: /* 2x64k */
|
||||
kbd->pd |= 0x04;
|
||||
break;
|
||||
case 192: /* 3x64k */
|
||||
kbd->pd |= 0x08;
|
||||
break;
|
||||
case 256: /* 4x64k */
|
||||
default:
|
||||
kbd->pd |= 0x0c;
|
||||
break;
|
||||
}
|
||||
} else if (kbd->type == KBD_TYPE_PC82) {
|
||||
switch (mem_size) {
|
||||
#ifdef PC82_192K_3BANK
|
||||
case 192: /* 3x64k, not supported by stock BIOS due to bugs */
|
||||
kbd->pd |= 0x08;
|
||||
break;
|
||||
#else
|
||||
case 192: /* 2x64k + 2x32k */
|
||||
#endif
|
||||
case 64: /* 4x16k */
|
||||
case 96: /* 2x32k + 2x16k */
|
||||
case 128: /* 4x32k */
|
||||
case 160: /* 2x64k + 2x16k */
|
||||
case 224: /* 3x64k + 1x32k */
|
||||
case 256: /* 4x64k */
|
||||
default:
|
||||
kbd->pd |= 0x0c;
|
||||
break;
|
||||
}
|
||||
} else { /* really just the PC '81 */
|
||||
switch (mem_size) {
|
||||
case 16: /* 1x16k */
|
||||
kbd->pd |= 0x00;
|
||||
break;
|
||||
case 32: /* 2x16k */
|
||||
kbd->pd |= 0x04;
|
||||
break;
|
||||
case 48: /* 3x16k */
|
||||
kbd->pd |= 0x08;
|
||||
break;
|
||||
case 64: /* 4x16k */
|
||||
default:
|
||||
kbd->pd |= 0x0c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Switch 2 - 8087 FPU. */
|
||||
if (hasfpu)
|
||||
kbd->pd |= 0x02;
|
||||
} else if (kbd->type == KBD_TYPE_ZENITH) {
|
||||
/* Zenith Data Systems Z-151
|
||||
* SW2 switch settings:
|
||||
* bit 7: monitor frequency
|
||||
* bits 5-6: autoboot (00-11 resident monitor, 10 hdd, 01 fdd)
|
||||
* bits 0-4: installed memory
|
||||
*/
|
||||
kbd->pd = 0x20;
|
||||
switch (mem_size) {
|
||||
case 128:
|
||||
kbd->pd |= 0x02;
|
||||
break;
|
||||
case 192:
|
||||
kbd->pd |= 0x04;
|
||||
break;
|
||||
case 256:
|
||||
kbd->pd |= 0x06;
|
||||
break;
|
||||
case 320:
|
||||
kbd->pd |= 0x08;
|
||||
break;
|
||||
case 384:
|
||||
kbd->pd |= 0x0a;
|
||||
break;
|
||||
case 448:
|
||||
kbd->pd |= 0x0c;
|
||||
break;
|
||||
case 512:
|
||||
kbd->pd |= 0x0e;
|
||||
break;
|
||||
case 576:
|
||||
kbd->pd |= 0x10;
|
||||
break;
|
||||
case 640:
|
||||
default:
|
||||
kbd->pd |= 0x12;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
timer_add(&kbd->send_delay_timer, kbd_poll, kbd, 1);
|
||||
|
||||
keyboard_set_table(scancode_xt);
|
||||
|
||||
is_tandy = (kbd->type == KBD_TYPE_TANDY);
|
||||
is_t1x00 = (kbd->type == KBD_TYPE_TOSHIBA);
|
||||
|
||||
is_amstrad = 0;
|
||||
|
||||
return kbd;
|
||||
return dev;
|
||||
}
|
||||
|
||||
static void
|
||||
kbd_close(void *priv)
|
||||
{
|
||||
xtkbd_t *kbd = (xtkbd_t *) priv;
|
||||
|
||||
/* Stop the timer. */
|
||||
timer_disable(&kbd->send_delay_timer);
|
||||
|
||||
/* Disable scanning. */
|
||||
keyboard_scan = 0;
|
||||
|
||||
keyboard_send = NULL;
|
||||
|
||||
io_removehandler(0x0060, 4,
|
||||
kbd_read, NULL, NULL, kbd_write, NULL, NULL, kbd);
|
||||
kbd_t *kbd = (kbd_t *) priv;
|
||||
|
||||
free(kbd);
|
||||
}
|
||||
|
||||
const device_t keyboard_pc_device = {
|
||||
.name = "IBM PC Keyboard (1981)",
|
||||
.internal_name = "keyboard_pc",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_PC81,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
static const device_config_t keyboard_pc_xt_config[] = {
|
||||
// clang-format off
|
||||
{
|
||||
.name = "keys",
|
||||
.description = "Keys",
|
||||
.type = CONFIG_SELECTION,
|
||||
.default_string = NULL,
|
||||
.default_int = KBD_83_KEY,
|
||||
.file_filter = NULL,
|
||||
.spinner = { 0 },
|
||||
.selection = {
|
||||
{ .description = "83", .value = KBD_83_KEY },
|
||||
{ .description = "101 (ANSI)", .value = KBD_101_KEY },
|
||||
{ .description = "102 (ISO)", .value = KBD_102_KEY }
|
||||
},
|
||||
.bios = { { 0 } }
|
||||
},
|
||||
{
|
||||
.name = "", .description = "", .type = CONFIG_END
|
||||
}
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
const device_t keyboard_pc82_device = {
|
||||
.name = "IBM PC Keyboard (1982)",
|
||||
.internal_name = "keyboard_pc82",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_PC82,
|
||||
const device_t keyboard_pc_xt_device = {
|
||||
.name = "PC/XT Keyboard",
|
||||
.internal_name = "keyboard_pc_xt",
|
||||
.flags = DEVICE_XT_KBC,
|
||||
.local = 0,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.reset = NULL,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_pravetz_device = {
|
||||
.name = "Pravetz Keyboard",
|
||||
.internal_name = "keyboard_pravetz",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_PRAVETZ,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_xt_device = {
|
||||
.name = "XT (1982) Keyboard",
|
||||
.internal_name = "keyboard_xt",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_XT82,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_xt86_device = {
|
||||
.name = "XT (1986) Keyboard",
|
||||
.internal_name = "keyboard_xt86",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_XT86,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_xt_compaq_device = {
|
||||
.name = "Compaq Portable Keyboard",
|
||||
.internal_name = "keyboard_xt_compaq",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_COMPAQ,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_tandy_device = {
|
||||
.name = "Tandy 1000 Keyboard",
|
||||
.internal_name = "keyboard_tandy",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_TANDY,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_xt_t1x00_device = {
|
||||
.name = "Toshiba T1x00 Keyboard",
|
||||
.internal_name = "keyboard_xt_t1x00",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_TOSHIBA,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_xt_lxt3_device = {
|
||||
.name = "VTech Laser Turbo XT Keyboard",
|
||||
.internal_name = "keyboard_xt_lxt",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_VTECH,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_xt_olivetti_device = {
|
||||
.name = "Olivetti XT Keyboard",
|
||||
.internal_name = "keyboard_xt_olivetti",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_OLIVETTI,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_xt_zenith_device = {
|
||||
.name = "Zenith XT Keyboard",
|
||||
.internal_name = "keyboard_xt_zenith",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_ZENITH,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_xt_hyundai_device = {
|
||||
.name = "Hyundai XT Keyboard",
|
||||
.internal_name = "keyboard_xt_hyundai",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_HYUNDAI,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_xt_fe2010_device = {
|
||||
.name = "Faraday FE2010 XT Keyboard",
|
||||
.internal_name = "keyboard_xt_fe2010",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_FE2010,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_xtclone_device = {
|
||||
.name = "XT (Clone) Keyboard",
|
||||
.internal_name = "keyboard_xtclone",
|
||||
.flags = 0,
|
||||
.local = KBD_TYPE_XTCLONE,
|
||||
.init = kbd_init,
|
||||
.close = kbd_close,
|
||||
.reset = kbd_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
.config = keyboard_pc_xt_config
|
||||
};
|
||||
|
||||
551
src/device/lpt.c
551
src/device/lpt.c
@@ -2,15 +2,18 @@
|
||||
see COPYING for more details
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#define HAVE_STDARG_H
|
||||
#include <86box/86box.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/io.h>
|
||||
#include <86box/fifo.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/dma.h>
|
||||
#include <86box/lpt.h>
|
||||
#include <86box/pic.h>
|
||||
@@ -21,7 +24,12 @@
|
||||
#include <86box/machine.h>
|
||||
#include <86box/network.h>
|
||||
|
||||
lpt_port_t lpt_ports[PARALLEL_MAX];
|
||||
static int next_inst = 0;
|
||||
int lpt_3bc_used = 0;
|
||||
|
||||
lpt_port_t lpt_ports[PARALLEL_MAX];
|
||||
|
||||
lpt_device_t lpt_devs[PARALLEL_MAX];
|
||||
|
||||
const lpt_device_t lpt_none_device = {
|
||||
.name = "None",
|
||||
@@ -35,23 +43,22 @@ const lpt_device_t lpt_none_device = {
|
||||
};
|
||||
|
||||
static const struct {
|
||||
const char *internal_name;
|
||||
const lpt_device_t *device;
|
||||
} lpt_devices[] = {
|
||||
// clang-format off
|
||||
{"none", &lpt_none_device },
|
||||
{"dss", &dss_device },
|
||||
{"lpt_dac", &lpt_dac_device },
|
||||
{"lpt_dac_stereo", &lpt_dac_stereo_device },
|
||||
{"text_prt", &lpt_prt_text_device },
|
||||
{"dot_matrix", &lpt_prt_escp_device },
|
||||
{"postscript", &lpt_prt_ps_device },
|
||||
{ &lpt_none_device },
|
||||
{ &dss_device },
|
||||
{ &lpt_dac_device },
|
||||
{ &lpt_dac_stereo_device },
|
||||
{ &lpt_prt_text_device },
|
||||
{ &lpt_prt_escp_device },
|
||||
{ &lpt_prt_ps_device },
|
||||
#ifdef USE_PCL
|
||||
{"pcl", &lpt_prt_pcl_device },
|
||||
{ &lpt_prt_pcl_device },
|
||||
#endif
|
||||
{"plip", &lpt_plip_device },
|
||||
{"dongle_savquest", &lpt_hasp_savquest_device },
|
||||
{"", NULL }
|
||||
{ &lpt_plip_device },
|
||||
{ &lpt_hasp_savquest_device },
|
||||
{ NULL }
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
@@ -73,31 +80,59 @@ lpt_log(const char *fmt, ...)
|
||||
# define lpt_log(fmt, ...)
|
||||
#endif
|
||||
|
||||
const device_t *
|
||||
lpt_device_getdevice(const int id)
|
||||
{
|
||||
return (device_t *) lpt_devices[id].device->cfgdevice;
|
||||
}
|
||||
|
||||
int
|
||||
lpt_device_has_config(const int id)
|
||||
{
|
||||
int c = 0;
|
||||
const device_t *dev = (device_t *) lpt_devices[id].device->cfgdevice;
|
||||
const device_config_t *config;
|
||||
if (dev == NULL)
|
||||
return 0;
|
||||
|
||||
if (dev->config == NULL)
|
||||
return 0;
|
||||
|
||||
config = dev->config;
|
||||
|
||||
while (config->type != CONFIG_END) {
|
||||
c++;
|
||||
config++;
|
||||
}
|
||||
|
||||
return (c > 0) ? 1 : 0;
|
||||
}
|
||||
|
||||
const char *
|
||||
lpt_device_get_name(const int id)
|
||||
{
|
||||
if (strlen(lpt_devices[id].internal_name) == 0)
|
||||
return NULL;
|
||||
if (lpt_devices[id].device == NULL)
|
||||
return "None";
|
||||
return NULL;
|
||||
|
||||
return lpt_devices[id].device->name;
|
||||
}
|
||||
|
||||
const char *
|
||||
lpt_device_get_internal_name(const int id)
|
||||
{
|
||||
if (strlen(lpt_devices[id].internal_name) == 0)
|
||||
if (lpt_devices[id].device == NULL)
|
||||
return NULL;
|
||||
return lpt_devices[id].internal_name;
|
||||
|
||||
return lpt_devices[id].device->internal_name;
|
||||
}
|
||||
|
||||
int
|
||||
lpt_device_get_from_internal_name(const char *s)
|
||||
lpt_device_get_from_internal_name(const char *str)
|
||||
{
|
||||
int c = 0;
|
||||
|
||||
while (strlen(lpt_devices[c].internal_name) != 0) {
|
||||
if (strcmp(lpt_devices[c].internal_name, s) == 0)
|
||||
while (lpt_devices[c].device != NULL) {
|
||||
if (!strcmp(lpt_devices[c].device->internal_name, str))
|
||||
return c;
|
||||
c++;
|
||||
}
|
||||
@@ -109,10 +144,17 @@ void
|
||||
lpt_devices_init(void)
|
||||
{
|
||||
for (uint8_t i = 0; i < PARALLEL_MAX; i++) {
|
||||
lpt_ports[i].dt = (lpt_device_t *) lpt_devices[lpt_ports[i].device].device;
|
||||
lpt_t *dev = lpt_devs[i].lpt;
|
||||
|
||||
if (lpt_ports[i].dt && lpt_ports[i].dt->init)
|
||||
lpt_ports[i].priv = lpt_ports[i].dt->init(&lpt_ports[i]);
|
||||
if (lpt_devices[lpt_ports[i].device].device != NULL) {
|
||||
memcpy(&(lpt_devs[i]), (lpt_device_t *) lpt_devices[lpt_ports[i].device].device, sizeof(lpt_device_t));
|
||||
|
||||
if (lpt_devs[i].init)
|
||||
lpt_devs[i].priv = lpt_devs[i].init(dev);
|
||||
} else
|
||||
memset(&(lpt_devs[i]), 0x00, sizeof(lpt_device_t));
|
||||
|
||||
lpt_devs[i].lpt = dev;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,22 +162,20 @@ void
|
||||
lpt_devices_close(void)
|
||||
{
|
||||
for (uint8_t i = 0; i < PARALLEL_MAX; i++) {
|
||||
lpt_port_t *dev = &lpt_ports[i];
|
||||
if (lpt_devs[i].close)
|
||||
lpt_devs[i].close(lpt_devs[i].priv);
|
||||
|
||||
if (lpt_ports[i].dt && lpt_ports[i].dt->close)
|
||||
dev->dt->close(dev->priv);
|
||||
|
||||
dev->dt = NULL;
|
||||
memset(&(lpt_devs[i]), 0x00, sizeof(lpt_device_t));
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
lpt_get_ctrl_raw(const lpt_port_t *dev)
|
||||
lpt_get_ctrl_raw(const lpt_t *dev)
|
||||
{
|
||||
uint8_t ret;
|
||||
|
||||
if (dev->dt && dev->dt->read_ctrl && dev->priv)
|
||||
ret = (dev->dt->read_ctrl(dev->priv) & 0xef) | dev->enable_irq;
|
||||
if (dev->dt && dev->dt->read_ctrl && dev->dt->priv)
|
||||
ret = (dev->dt->read_ctrl(dev->dt->priv) & 0xef) | dev->enable_irq;
|
||||
else
|
||||
ret = 0xc0 | dev->ctrl | dev->enable_irq;
|
||||
|
||||
@@ -143,13 +183,13 @@ lpt_get_ctrl_raw(const lpt_port_t *dev)
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
lpt_is_epp(const lpt_port_t *dev)
|
||||
lpt_is_epp(const lpt_t *dev)
|
||||
{
|
||||
return (dev->epp || ((dev->ecp) && ((dev->ecr & 0xe0) == 0x80)));
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
lpt_get_ctrl(const lpt_port_t *dev)
|
||||
lpt_get_ctrl(const lpt_t *dev)
|
||||
{
|
||||
uint8_t ret = lpt_get_ctrl_raw(dev);
|
||||
|
||||
@@ -160,7 +200,7 @@ lpt_get_ctrl(const lpt_port_t *dev)
|
||||
}
|
||||
|
||||
static void
|
||||
lpt_write_fifo(lpt_port_t *dev, const uint8_t val, const uint8_t tag)
|
||||
lpt_write_fifo(lpt_t *dev, const uint8_t val, const uint8_t tag)
|
||||
{
|
||||
if (!fifo_get_full(dev->fifo)) {
|
||||
fifo_write_evt_tagged(tag, val, dev->fifo);
|
||||
@@ -171,7 +211,7 @@ lpt_write_fifo(lpt_port_t *dev, const uint8_t val, const uint8_t tag)
|
||||
}
|
||||
|
||||
static void
|
||||
lpt_ecp_update_irq(lpt_port_t *dev)
|
||||
lpt_ecp_update_irq(lpt_t *dev)
|
||||
{
|
||||
if (!(dev->ecr & 0x04) && ((dev->fifo_stat | dev->dma_stat) & 0x04))
|
||||
picintlevel(1 << dev->irq, &dev->irq_state);
|
||||
@@ -180,19 +220,19 @@ lpt_ecp_update_irq(lpt_port_t *dev)
|
||||
}
|
||||
|
||||
static void
|
||||
lpt_autofeed(lpt_port_t *dev, const uint8_t val)
|
||||
lpt_autofeed(lpt_t *dev, const uint8_t val)
|
||||
{
|
||||
if (dev->dt && dev->dt->autofeed && dev->priv)
|
||||
dev->dt->autofeed(val, dev->priv);
|
||||
if (dev->dt && dev->dt->autofeed && dev->dt->priv)
|
||||
dev->dt->autofeed(val, dev->dt->priv);
|
||||
|
||||
dev->autofeed = val;
|
||||
}
|
||||
|
||||
static void
|
||||
lpt_strobe(lpt_port_t *dev, const uint8_t val)
|
||||
lpt_strobe(lpt_t *dev, const uint8_t val)
|
||||
{
|
||||
if (dev->dt && dev->dt->strobe && dev->priv)
|
||||
dev->dt->strobe(dev->strobe, val, dev->priv);
|
||||
if (dev->dt && dev->dt->strobe && dev->dt->priv)
|
||||
dev->dt->strobe(dev->strobe, val, dev->dt->priv);
|
||||
|
||||
dev->strobe = val;
|
||||
}
|
||||
@@ -200,7 +240,7 @@ lpt_strobe(lpt_port_t *dev, const uint8_t val)
|
||||
static void
|
||||
lpt_fifo_out_callback(void *priv)
|
||||
{
|
||||
lpt_port_t *dev = (lpt_port_t *) priv;
|
||||
lpt_t *dev = (lpt_t *) priv;
|
||||
|
||||
switch (dev->state) {
|
||||
default:
|
||||
@@ -241,8 +281,8 @@ lpt_fifo_out_callback(void *priv)
|
||||
|
||||
/* We do not currently support sending commands. */
|
||||
if (tag == 0x01) {
|
||||
if (dev->dt && dev->dt->write_data && dev->priv)
|
||||
dev->dt->write_data(val, dev->priv);
|
||||
if (dev->dt && dev->dt->write_data && dev->dt->priv)
|
||||
dev->dt->write_data(val, dev->dt->priv);
|
||||
|
||||
lpt_strobe(dev, 1);
|
||||
lpt_strobe(dev, 0);
|
||||
@@ -278,7 +318,7 @@ lpt_fifo_out_callback(void *priv)
|
||||
void
|
||||
lpt_write(const uint16_t port, const uint8_t val, void *priv)
|
||||
{
|
||||
lpt_port_t *dev = (lpt_port_t *) priv;
|
||||
lpt_t *dev = (lpt_t *) priv;
|
||||
uint16_t mask = 0x0407;
|
||||
|
||||
lpt_log("[W] %04X = %02X\n", port, val);
|
||||
@@ -294,15 +334,15 @@ lpt_write(const uint16_t port, const uint8_t val, void *priv)
|
||||
/* AFIFO */
|
||||
lpt_write_fifo(dev, val, 0x00);
|
||||
else if (!(dev->ecr & 0xc0) && (!(dev->ecr & 0x20) || !(lpt_get_ctrl_raw(dev) & 0x20)) &&
|
||||
dev->dt && dev->dt->write_data && dev->priv)
|
||||
dev->dt && dev->dt->write_data && dev->dt->priv)
|
||||
/* DATAR */
|
||||
dev->dt->write_data(val, dev->priv);
|
||||
dev->dt->write_data(val, dev->dt->priv);
|
||||
dev->dat = val;
|
||||
} else {
|
||||
/* DTR */
|
||||
if ((!dev->ext || !(lpt_get_ctrl_raw(dev) & 0x20)) && dev->dt &&
|
||||
dev->dt->write_data && dev->priv)
|
||||
dev->dt->write_data(val, dev->priv);
|
||||
dev->dt->write_data && dev->dt->priv)
|
||||
dev->dt->write_data(val, dev->dt->priv);
|
||||
dev->dat = val;
|
||||
}
|
||||
break;
|
||||
@@ -311,11 +351,11 @@ lpt_write(const uint16_t port, const uint8_t val, void *priv)
|
||||
break;
|
||||
|
||||
case 0x0002:
|
||||
if (dev->dt && dev->dt->write_ctrl && dev->priv) {
|
||||
if (dev->dt && dev->dt->write_ctrl && dev->dt->priv) {
|
||||
if (dev->ecp)
|
||||
dev->dt->write_ctrl((val & 0xfc) | dev->autofeed | dev->strobe, dev->priv);
|
||||
dev->dt->write_ctrl((val & 0xfc) | dev->autofeed | dev->strobe, dev->dt->priv);
|
||||
else
|
||||
dev->dt->write_ctrl(val, dev->priv);
|
||||
dev->dt->write_ctrl(val, dev->dt->priv);
|
||||
}
|
||||
dev->ctrl = val;
|
||||
dev->enable_irq = val & 0x10;
|
||||
@@ -326,15 +366,15 @@ lpt_write(const uint16_t port, const uint8_t val, void *priv)
|
||||
|
||||
case 0x0003:
|
||||
if (lpt_is_epp(dev)) {
|
||||
if (dev->dt && dev->dt->epp_write_data && dev->priv)
|
||||
dev->dt->epp_write_data(1, val, dev->priv);
|
||||
if (dev->dt && dev->dt->epp_write_data && dev->dt->priv)
|
||||
dev->dt->epp_write_data(1, val, dev->dt->priv);
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x0004 ... 0x0007:
|
||||
if (lpt_is_epp(dev)) {
|
||||
if (dev->dt && dev->dt->epp_write_data && dev->priv)
|
||||
dev->dt->epp_write_data(0, val, dev->priv);
|
||||
if (dev->dt && dev->dt->epp_write_data && dev->dt->priv)
|
||||
dev->dt->epp_write_data(0, val, dev->dt->priv);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -396,7 +436,7 @@ lpt_write(const uint16_t port, const uint8_t val, void *priv)
|
||||
static void
|
||||
lpt_fifo_d_ready_evt(void *priv)
|
||||
{
|
||||
lpt_port_t *dev = (lpt_port_t *) priv;
|
||||
lpt_t *dev = (lpt_t *) priv;
|
||||
|
||||
if (!(dev->ecr & 0x08)) {
|
||||
if (lpt_get_ctrl_raw(dev) & 0x20)
|
||||
@@ -411,7 +451,7 @@ lpt_fifo_d_ready_evt(void *priv)
|
||||
void
|
||||
lpt_write_to_fifo(void *priv, const uint8_t val)
|
||||
{
|
||||
lpt_port_t *dev = (lpt_port_t *) priv;
|
||||
lpt_t *dev = (lpt_t *) priv;
|
||||
|
||||
if (dev->ecp) {
|
||||
if (((dev->ecr & 0xe0) == 0x20) && (lpt_get_ctrl_raw(dev) & 0x20))
|
||||
@@ -435,13 +475,13 @@ lpt_write_to_fifo(void *priv, const uint8_t val)
|
||||
void
|
||||
lpt_write_to_dat(void *priv, const uint8_t val)
|
||||
{
|
||||
lpt_port_t *dev = (lpt_port_t *) priv;
|
||||
lpt_t *dev = (lpt_t *) priv;
|
||||
|
||||
dev->dat = val;
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
lpt_read_fifo(const lpt_port_t *dev)
|
||||
lpt_read_fifo(const lpt_t *dev)
|
||||
{
|
||||
uint8_t ret = 0xff;
|
||||
|
||||
@@ -452,9 +492,8 @@ lpt_read_fifo(const lpt_port_t *dev)
|
||||
}
|
||||
|
||||
uint8_t
|
||||
lpt_read_status(const int port)
|
||||
lpt_read_status(lpt_t *dev)
|
||||
{
|
||||
lpt_port_t *dev = &lpt_ports[port];
|
||||
uint8_t low_bits = 0x07;
|
||||
uint8_t ret;
|
||||
|
||||
@@ -472,8 +511,8 @@ lpt_read_status(const int port)
|
||||
low_bits |= 0x04;
|
||||
}
|
||||
|
||||
if (dev->dt && dev->dt->read_status && dev->priv)
|
||||
ret = (dev->dt->read_status(dev->priv) & 0xf8) | low_bits;
|
||||
if (dev->dt && dev->dt->read_status && dev->dt->priv)
|
||||
ret = (dev->dt->read_status(dev->dt->priv) & 0xf8) | low_bits;
|
||||
else
|
||||
ret = 0xd8 | low_bits;
|
||||
|
||||
@@ -483,9 +522,9 @@ lpt_read_status(const int port)
|
||||
uint8_t
|
||||
lpt_read(const uint16_t port, void *priv)
|
||||
{
|
||||
const lpt_port_t *dev = (lpt_port_t *) priv;
|
||||
uint16_t mask = 0x0407;
|
||||
uint8_t ret = 0xff;
|
||||
lpt_t *dev = (lpt_t *) priv;
|
||||
uint16_t mask = 0x0407;
|
||||
uint8_t ret = 0xff;
|
||||
|
||||
/* This is needed so the parallel port at 3BC works. */
|
||||
if (dev->addr & 0x0004)
|
||||
@@ -503,7 +542,7 @@ lpt_read(const uint16_t port, void *priv)
|
||||
break;
|
||||
|
||||
case 0x0001:
|
||||
ret = lpt_read_status(dev->id);
|
||||
ret = lpt_read_status(dev);
|
||||
break;
|
||||
|
||||
case 0x0002:
|
||||
@@ -514,16 +553,16 @@ lpt_read(const uint16_t port, void *priv)
|
||||
|
||||
case 0x0003:
|
||||
if (lpt_is_epp(dev)) {
|
||||
if (dev->dt && dev->dt->epp_request_read && dev->priv)
|
||||
dev->dt->epp_request_read(1, dev->priv);
|
||||
if (dev->dt && dev->dt->epp_request_read && dev->dt->priv)
|
||||
dev->dt->epp_request_read(1, dev->dt->priv);
|
||||
ret = dev->dat;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x0004 ... 0x0007:
|
||||
if (lpt_is_epp(dev)) {
|
||||
if (dev->dt && dev->dt->epp_request_read && dev->priv)
|
||||
dev->dt->epp_request_read(0, dev->priv);
|
||||
if (dev->dt && dev->dt->epp_request_read && dev->dt->priv)
|
||||
dev->dt->epp_request_read(0, dev->dt->priv);
|
||||
ret = dev->dat;
|
||||
}
|
||||
break;
|
||||
@@ -543,7 +582,7 @@ lpt_read(const uint16_t port, void *priv)
|
||||
break;
|
||||
case 7:
|
||||
/* CNFGA */
|
||||
ret = 0x14;
|
||||
ret = dev->cnfga_readout;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -575,17 +614,15 @@ lpt_read(const uint16_t port, void *priv)
|
||||
}
|
||||
|
||||
uint8_t
|
||||
lpt_read_port(const int port, const uint16_t reg)
|
||||
lpt_read_port(lpt_t *dev, const uint16_t reg)
|
||||
{
|
||||
lpt_port_t *dev = &(lpt_ports[port]);
|
||||
|
||||
return lpt_read(reg, dev);
|
||||
}
|
||||
|
||||
void
|
||||
lpt_irq(void *priv, const int raise)
|
||||
{
|
||||
lpt_port_t *dev = (lpt_port_t *) priv;
|
||||
lpt_t *dev = (lpt_t *) priv;
|
||||
|
||||
if (dev->enable_irq) {
|
||||
if (dev->irq != 0xff) {
|
||||
@@ -617,79 +654,142 @@ lpt_irq(void *priv, const int raise)
|
||||
}
|
||||
|
||||
void
|
||||
lpt_set_ext(const int port, const uint8_t ext)
|
||||
lpt_set_ext(lpt_t *dev, const uint8_t ext)
|
||||
{
|
||||
if (lpt_ports[port].enabled)
|
||||
lpt_ports[port].ext = ext;
|
||||
if (lpt_ports[dev->id].enabled)
|
||||
dev->ext = ext;
|
||||
}
|
||||
|
||||
void
|
||||
lpt_set_ecp(const int port, const uint8_t ecp)
|
||||
lpt_set_ecp(lpt_t *dev, const uint8_t ecp)
|
||||
{
|
||||
if (lpt_ports[port].enabled)
|
||||
lpt_ports[port].ecp = ecp;
|
||||
if (lpt_ports[dev->id].enabled)
|
||||
dev->ecp = ecp;
|
||||
}
|
||||
|
||||
void
|
||||
lpt_set_epp(const int port, const uint8_t epp)
|
||||
lpt_set_epp(lpt_t *dev, const uint8_t epp)
|
||||
{
|
||||
if (lpt_ports[port].enabled)
|
||||
lpt_ports[port].epp = epp;
|
||||
if (lpt_ports[dev->id].enabled)
|
||||
dev->epp = epp;
|
||||
}
|
||||
|
||||
void
|
||||
lpt_set_lv2(const int port, const uint8_t lv2)
|
||||
lpt_set_lv2(lpt_t *dev, const uint8_t lv2)
|
||||
{
|
||||
if (lpt_ports[port].enabled)
|
||||
lpt_ports[port].lv2 = lv2;
|
||||
if (lpt_ports[dev->id].enabled)
|
||||
dev->lv2 = lv2;
|
||||
}
|
||||
|
||||
void
|
||||
lpt_set_fifo_threshold(const int port, const int threshold)
|
||||
lpt_set_fifo_threshold(lpt_t *dev, const int threshold)
|
||||
{
|
||||
if (lpt_ports[port].enabled)
|
||||
fifo_set_trigger_len(lpt_ports[port].fifo, threshold);
|
||||
if (lpt_ports[dev->id].enabled)
|
||||
fifo_set_trigger_len(dev->fifo, threshold);
|
||||
}
|
||||
|
||||
void
|
||||
lpt_close(void)
|
||||
lpt_set_cnfga_readout(lpt_t *dev, const uint8_t cnfga_readout)
|
||||
{
|
||||
for (uint8_t i = 0; i < PARALLEL_MAX; i++) {
|
||||
if (lpt_ports[i].enabled) {
|
||||
fifo_close(lpt_ports[i].fifo);
|
||||
lpt_ports[i].fifo = NULL;
|
||||
if (lpt_ports[dev->id].enabled)
|
||||
dev->cnfga_readout = cnfga_readout;
|
||||
}
|
||||
|
||||
timer_disable(&lpt_ports[i].fifo_out_timer);
|
||||
void
|
||||
lpt_port_setup(lpt_t *dev, const uint16_t port)
|
||||
{
|
||||
if (lpt_ports[dev->id].enabled) {
|
||||
if ((dev->addr != 0x0000) && (dev->addr != 0xffff)) {
|
||||
io_removehandler(dev->addr, 0x0007, lpt_read, NULL, NULL, lpt_write, NULL, NULL, dev);
|
||||
io_removehandler(dev->addr + 0x0400, 0x0007, lpt_read, NULL, NULL, lpt_write, NULL, NULL, dev);
|
||||
}
|
||||
if ((port != 0x0000) && (port != 0xffff)) {
|
||||
lpt_log("Set handler: %04X-%04X\n", port, port + 0x0003);
|
||||
io_sethandler(port, 0x0003, lpt_read, NULL, NULL, lpt_write, NULL, NULL, dev);
|
||||
if (dev->epp)
|
||||
io_sethandler(port + 0x0003, 0x0005, lpt_read, NULL, NULL, lpt_write, NULL, NULL, dev);
|
||||
if (dev->ecp || dev->lv2) {
|
||||
io_sethandler(port + 0x0400, 0x0003, lpt_read, NULL, NULL, lpt_write, NULL, NULL, dev);
|
||||
if (dev->epp)
|
||||
io_sethandler(port + 0x0404, 0x0003, lpt_read, NULL, NULL, lpt_write, NULL, NULL, dev);
|
||||
}
|
||||
}
|
||||
dev->addr = port;
|
||||
} else
|
||||
dev->addr = 0xffff;
|
||||
}
|
||||
|
||||
void
|
||||
lpt_port_irq(lpt_t *dev, const uint8_t irq)
|
||||
{
|
||||
if (lpt_ports[dev->id].enabled)
|
||||
dev->irq = irq;
|
||||
else
|
||||
dev->irq = 0xff;
|
||||
|
||||
lpt_log("Port %i IRQ = %02X\n", dev->id, irq);
|
||||
}
|
||||
|
||||
void
|
||||
lpt_port_dma(lpt_t *dev, const uint8_t dma)
|
||||
{
|
||||
if (lpt_ports[dev->id].enabled)
|
||||
dev->dma = dma;
|
||||
else
|
||||
dev->dma = 0xff;
|
||||
|
||||
lpt_log("Port %i DMA = %02X\n", dev->id, dma);
|
||||
}
|
||||
|
||||
void
|
||||
lpt_port_remove(lpt_t *dev)
|
||||
{
|
||||
if (lpt_ports[dev->id].enabled && (dev->addr != 0xffff)) {
|
||||
io_removehandler(dev->addr, 0x0007, lpt_read, NULL, NULL, lpt_write, NULL, NULL, dev);
|
||||
io_removehandler(dev->addr + 0x0400, 0x0007, lpt_read, NULL, NULL, lpt_write, NULL, NULL, dev);
|
||||
|
||||
dev->addr = 0xffff;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
lpt_port_zero(lpt_port_t *dev)
|
||||
lpt1_remove_ams(lpt_t *dev)
|
||||
{
|
||||
lpt_port_t temp = { 0 };
|
||||
if (dev->enabled)
|
||||
io_removehandler(dev->addr + 1, 0x0002, lpt_read, NULL, NULL, lpt_write, NULL, NULL, dev);
|
||||
}
|
||||
|
||||
void
|
||||
lpt_speed_changed(void *priv)
|
||||
{
|
||||
lpt_t *dev = (lpt_t *) priv;
|
||||
|
||||
if (timer_is_enabled(&dev->fifo_out_timer)) {
|
||||
timer_disable(&dev->fifo_out_timer);
|
||||
timer_set_delay_u64(&dev->fifo_out_timer, (uint64_t) ((1000000.0 / 2500000.0) * (double) TIMER_USEC));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
lpt_port_zero(lpt_t *dev)
|
||||
{
|
||||
lpt_t temp = { 0 };
|
||||
|
||||
temp.irq = dev->irq;
|
||||
temp.id = dev->id;
|
||||
temp.device = dev->device;
|
||||
temp.dt = dev->dt;
|
||||
temp.priv = dev->priv;
|
||||
temp.enabled = dev->enabled;
|
||||
temp.fifo = dev->fifo;
|
||||
temp.fifo_out_timer = dev->fifo_out_timer;
|
||||
|
||||
if (dev->enabled)
|
||||
lpt_port_remove(dev->id);
|
||||
if (lpt_ports[dev->id].enabled)
|
||||
lpt_port_remove(dev);
|
||||
|
||||
memset(dev, 0x00, sizeof(lpt_port_t));
|
||||
memset(dev, 0x00, sizeof(lpt_t));
|
||||
|
||||
dev->addr = 0xffff;
|
||||
dev->irq = temp.irq;
|
||||
dev->id = temp.id;
|
||||
dev->device = temp.device;
|
||||
dev->dt = temp.dt;
|
||||
dev->priv = temp.priv;
|
||||
dev->enabled = temp.enabled;
|
||||
dev->fifo = temp.fifo;
|
||||
dev->fifo_out_timer = temp.fifo_out_timer;
|
||||
|
||||
@@ -697,138 +797,149 @@ lpt_port_zero(lpt_port_t *dev)
|
||||
dev->ext = 1;
|
||||
}
|
||||
|
||||
void
|
||||
lpt_reset(void)
|
||||
static void
|
||||
lpt_close(void *priv)
|
||||
{
|
||||
for (uint8_t i = 0; i < PARALLEL_MAX; i++) {
|
||||
if (lpt_ports[i].enabled)
|
||||
if (timer_is_enabled(&lpt_ports[i].fifo_out_timer))
|
||||
timer_disable(&lpt_ports[i].fifo_out_timer);
|
||||
lpt_t *dev = (lpt_t *) priv;
|
||||
|
||||
lpt_port_zero(&(lpt_ports[i]));
|
||||
if (lpt_ports[dev->id].enabled) {
|
||||
fifo_close(dev->fifo);
|
||||
dev->fifo = NULL;
|
||||
|
||||
if (lpt_ports[i].enabled) {
|
||||
if (lpt_ports[i].irq_state) {
|
||||
if (lpt_ports[i].irq == 0xff)
|
||||
lpt_ports[i].irq_state = 0x00;
|
||||
else {
|
||||
picintclevel(lpt_ports[i].irq, &lpt_ports[i].irq_state);
|
||||
picintc(lpt_ports[i].irq);
|
||||
}
|
||||
timer_disable(&dev->fifo_out_timer);
|
||||
|
||||
}
|
||||
|
||||
free(dev);
|
||||
}
|
||||
|
||||
static void
|
||||
lpt_reset(void *priv)
|
||||
{
|
||||
lpt_t *dev = (lpt_t *) priv;
|
||||
|
||||
if (lpt_ports[dev->id].enabled)
|
||||
if (timer_is_enabled(&dev->fifo_out_timer))
|
||||
timer_disable(&dev->fifo_out_timer);
|
||||
|
||||
lpt_port_zero(dev);
|
||||
|
||||
if (lpt_ports[dev->id].enabled) {
|
||||
if (dev->irq_state) {
|
||||
if (dev->irq == 0xff)
|
||||
dev->irq_state = 0x00;
|
||||
else {
|
||||
picintclevel(dev->irq, &dev->irq_state);
|
||||
picintc(dev->irq);
|
||||
}
|
||||
|
||||
lpt_ports[i].enable_irq = 0x00;
|
||||
lpt_ports[i].ext = !!(machine_has_bus(machine, MACHINE_BUS_MCA));
|
||||
lpt_ports[i].epp = 0;
|
||||
lpt_ports[i].ecp = 0;
|
||||
lpt_ports[i].ecr = 0x15;
|
||||
lpt_ports[i].dat = 0xff;
|
||||
lpt_ports[i].fifo_stat = 0x00;
|
||||
lpt_ports[i].dma_stat = 0x00;
|
||||
}
|
||||
|
||||
dev->enable_irq = 0x00;
|
||||
dev->ext = !!(machine_has_bus(machine, MACHINE_BUS_MCA));
|
||||
dev->epp = 0;
|
||||
dev->ecp = 0;
|
||||
dev->ecr = 0x15;
|
||||
dev->dat = 0xff;
|
||||
dev->fifo_stat = 0x00;
|
||||
dev->dma_stat = 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
lpt_init(void)
|
||||
static void *
|
||||
lpt_init(const device_t *info)
|
||||
{
|
||||
lpt_t *dev = (lpt_t *) calloc(1, sizeof(lpt_t));
|
||||
int orig_inst = next_inst;
|
||||
|
||||
const uint16_t default_ports[PARALLEL_MAX] = { LPT1_ADDR, LPT2_ADDR, LPT_MDA_ADDR, LPT4_ADDR };
|
||||
const uint8_t default_irqs[PARALLEL_MAX] = { LPT1_IRQ, LPT2_IRQ, LPT_MDA_IRQ, LPT4_IRQ };
|
||||
|
||||
for (uint8_t i = 0; i < PARALLEL_MAX; i++) {
|
||||
lpt_ports[i].id = i;
|
||||
lpt_ports[i].dt = NULL;
|
||||
lpt_ports[i].priv = NULL;
|
||||
lpt_ports[i].fifo = NULL;
|
||||
memset(&lpt_ports[i].fifo_out_timer, 0x00, sizeof(pc_timer_t));
|
||||
if (info->local & 0xFFF00000)
|
||||
next_inst = PARALLEL_MAX - 1;
|
||||
|
||||
lpt_port_zero(&(lpt_ports[i]));
|
||||
dev->id = next_inst;
|
||||
|
||||
lpt_ports[i].addr = 0xffff;
|
||||
lpt_ports[i].irq = 0xff;
|
||||
lpt_ports[i].dma = 0xff;
|
||||
lpt_ports[i].enable_irq = 0x00;
|
||||
lpt_ports[i].ext = 0;
|
||||
lpt_ports[i].epp = 0;
|
||||
lpt_ports[i].ecp = 0;
|
||||
lpt_ports[i].ecr = 0x15;
|
||||
if (lpt_ports[next_inst].enabled || (info->local & 0xFFF00000)) {
|
||||
lpt_log("Adding parallel port %i...\n", next_inst);
|
||||
dev->dt = &(lpt_devs[next_inst]);
|
||||
dev->dt->lpt = dev;
|
||||
|
||||
if (lpt_ports[i].enabled) {
|
||||
lpt_port_setup(i, default_ports[i]);
|
||||
lpt_port_irq(i, default_irqs[i]);
|
||||
dev->fifo = NULL;
|
||||
memset(&dev->fifo_out_timer, 0x00, sizeof(pc_timer_t));
|
||||
|
||||
lpt_ports[i].fifo = fifo16_init();
|
||||
lpt_port_zero(dev);
|
||||
|
||||
fifo_set_trigger_len(lpt_ports[i].fifo, 8);
|
||||
dev->addr = 0xffff;
|
||||
dev->irq = 0xff;
|
||||
dev->dma = 0xff;
|
||||
dev->enable_irq = 0x00;
|
||||
dev->ext = 0;
|
||||
dev->epp = 0;
|
||||
dev->ecp = 0;
|
||||
dev->ecr = 0x15;
|
||||
dev->cnfga_readout = 0x14;
|
||||
|
||||
fifo_set_d_ready_evt(lpt_ports[i].fifo, lpt_fifo_d_ready_evt);
|
||||
fifo_set_priv(lpt_ports[i].fifo, &lpt_ports[i]);
|
||||
|
||||
timer_add(&lpt_ports[i].fifo_out_timer, lpt_fifo_out_callback, &lpt_ports[i], 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
lpt_port_setup(const int i, const uint16_t port)
|
||||
{
|
||||
if (lpt_ports[i].enabled) {
|
||||
if ((lpt_ports[i].addr != 0x0000) && (lpt_ports[i].addr != 0xffff)) {
|
||||
io_removehandler(lpt_ports[i].addr, 0x0007, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]);
|
||||
io_removehandler(lpt_ports[i].addr + 0x0400, 0x0007, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]);
|
||||
}
|
||||
if ((port != 0x0000) && (port != 0xffff)) {
|
||||
lpt_log("Set handler: %04X-%04X\n", port, port + 0x0003);
|
||||
io_sethandler(port, 0x0003, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]);
|
||||
if (lpt_ports[i].epp)
|
||||
io_sethandler(port + 0x0003, 0x0005, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]);
|
||||
if (lpt_ports[i].ecp || lpt_ports[i].lv2) {
|
||||
io_sethandler(port + 0x0400, 0x0003, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]);
|
||||
if (lpt_ports[i].epp)
|
||||
io_sethandler(port + 0x0404, 0x0003, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]);
|
||||
if (lpt_ports[dev->id].enabled) {
|
||||
if (info->local & 0xfff00000) {
|
||||
lpt_port_setup(dev, info->local >> 20);
|
||||
lpt_port_irq(dev, (info->local >> 16) & 0xF);
|
||||
next_inst = orig_inst;
|
||||
} else {
|
||||
if ((dev->id == 2) && (lpt_3bc_used)) {
|
||||
lpt_port_setup(dev, LPT1_ADDR);
|
||||
lpt_port_irq(dev, LPT1_IRQ);
|
||||
} else {
|
||||
lpt_port_setup(dev, default_ports[dev->id]);
|
||||
lpt_port_irq(dev, default_irqs[dev->id]);
|
||||
}
|
||||
}
|
||||
|
||||
dev->fifo = fifo16_init();
|
||||
|
||||
fifo_set_trigger_len(dev->fifo, 8);
|
||||
|
||||
fifo_set_d_ready_evt(dev->fifo, lpt_fifo_d_ready_evt);
|
||||
fifo_set_priv(dev->fifo, dev);
|
||||
|
||||
timer_add(&dev->fifo_out_timer, lpt_fifo_out_callback, dev, 0);
|
||||
}
|
||||
lpt_ports[i].addr = port;
|
||||
} else
|
||||
lpt_ports[i].addr = 0xffff;
|
||||
}
|
||||
|
||||
void
|
||||
lpt_port_irq(const int i, const uint8_t irq)
|
||||
{
|
||||
if (lpt_ports[i].enabled)
|
||||
lpt_ports[i].irq = irq;
|
||||
else
|
||||
lpt_ports[i].irq = 0xff;
|
||||
|
||||
lpt_log("Port %i IRQ = %02X\n", i, irq);
|
||||
}
|
||||
|
||||
void
|
||||
lpt_port_dma(const int i, const uint8_t dma)
|
||||
{
|
||||
if (lpt_ports[i].enabled)
|
||||
lpt_ports[i].dma = dma;
|
||||
else
|
||||
lpt_ports[i].dma = 0xff;
|
||||
|
||||
lpt_log("Port %i DMA = %02X\n", i, dma);
|
||||
}
|
||||
|
||||
void
|
||||
lpt_port_remove(const int i)
|
||||
{
|
||||
if (lpt_ports[i].enabled && (lpt_ports[i].addr != 0xffff)) {
|
||||
io_removehandler(lpt_ports[i].addr, 0x0007, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]);
|
||||
io_removehandler(lpt_ports[i].addr + 0x0400, 0x0007, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]);
|
||||
|
||||
lpt_ports[i].addr = 0xffff;
|
||||
}
|
||||
|
||||
if (!(info->local & 0xfff00000))
|
||||
next_inst++;
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
void
|
||||
lpt1_remove_ams(void)
|
||||
lpt_set_next_inst(int ni)
|
||||
{
|
||||
if (lpt_ports[0].enabled)
|
||||
io_removehandler(lpt_ports[0].addr + 1, 0x0002, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[0]);
|
||||
next_inst = ni;
|
||||
}
|
||||
|
||||
void
|
||||
lpt_set_3bc_used(int is_3bc_used)
|
||||
{
|
||||
lpt_3bc_used = is_3bc_used;
|
||||
}
|
||||
|
||||
void
|
||||
lpt_standalone_init(void)
|
||||
{
|
||||
while (next_inst < (PARALLEL_MAX - 1))
|
||||
device_add_inst(&lpt_port_device, next_inst + 1);
|
||||
};
|
||||
|
||||
const device_t lpt_port_device = {
|
||||
.name = "Parallel Port",
|
||||
.internal_name = "lpt",
|
||||
.flags = 0,
|
||||
.local = 0,
|
||||
.init = lpt_init,
|
||||
.close = lpt_close,
|
||||
.reset = lpt_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = lpt_speed_changed,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
@@ -83,24 +83,29 @@ static const device_t mouse_internal_device = {
|
||||
|
||||
static mouse_t mouse_devices[] = {
|
||||
// clang-format off
|
||||
{ &mouse_none_device },
|
||||
{ &mouse_internal_device },
|
||||
{ &mouse_logibus_device },
|
||||
{ &mouse_msinport_device },
|
||||
{ &mouse_none_device },
|
||||
{ &mouse_internal_device },
|
||||
{ &mouse_logibus_device },
|
||||
{ &mouse_msinport_device },
|
||||
#ifdef USE_GENIBUS
|
||||
{ &mouse_genibus_device },
|
||||
{ &mouse_genibus_device },
|
||||
#endif
|
||||
|
||||
{ &mouse_mssystems_device },
|
||||
{ &mouse_mssystems_bus_device },
|
||||
{ &mouse_msserial_device },
|
||||
{ &mouse_msserial_ballpoint_device },
|
||||
{ &mouse_ltserial_device },
|
||||
{ &mouse_ps2_device },
|
||||
#ifdef USE_STANDALONE_QUICKPORT
|
||||
{ &mouse_upc_standalone_device },
|
||||
#endif
|
||||
{ &mouse_mssystems_device },
|
||||
{ &mouse_mssystems_bus_device },
|
||||
{ &mouse_msserial_device },
|
||||
{ &mouse_ltserial_device },
|
||||
{ &mouse_ps2_device },
|
||||
#ifdef USE_WACOM
|
||||
{ &mouse_wacom_device },
|
||||
{ &mouse_wacom_artpad_device },
|
||||
{ &mouse_wacom_device },
|
||||
{ &mouse_wacom_artpad_device },
|
||||
#endif
|
||||
{ &mouse_mtouch_device },
|
||||
{ NULL }
|
||||
{ &mouse_mtouch_device },
|
||||
{ NULL }
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
* Copyright 2023 Miran Grca.
|
||||
* Copyright 2023-2025 Miran Grca.
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
#include <stdatomic.h>
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <wchar.h>
|
||||
#define HAVE_STDARG_H
|
||||
#include <86box/86box.h>
|
||||
#include "cpu.h"
|
||||
#include <86box/device.h>
|
||||
#include <86box/keyboard.h>
|
||||
#include <86box/mouse.h>
|
||||
@@ -353,6 +352,9 @@ mouse_ps2_init(const device_t *info)
|
||||
atkbc_dev_t *dev = kbc_at_dev_init(DEV_AUX);
|
||||
int i;
|
||||
|
||||
if (info->local & MOUSE_TYPE_QPORT)
|
||||
device_context(&mouse_upc_standalone_device);
|
||||
|
||||
dev->name = info->name;
|
||||
dev->type = info->local;
|
||||
|
||||
@@ -382,6 +384,9 @@ mouse_ps2_init(const device_t *info)
|
||||
|
||||
mouse_set_poll(ps2_poll, dev);
|
||||
|
||||
if (info->local & MOUSE_TYPE_QPORT)
|
||||
device_context_restore();
|
||||
|
||||
/* Return our private data to the I/O layer. */
|
||||
return dev;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ enum {
|
||||
FORMAT_MM_SERIES = 0x13,
|
||||
FORMAT_PB_3BYTE,
|
||||
FORMAT_PB_5BYTE,
|
||||
FORMAT_MSYSTEMS = 0x15, /* Alias for FORMAT_PB_5BYTE. */
|
||||
FORMAT_MSYSTEMS = 0x15, /* Alias for FORMAT_PB_5BYTE. */
|
||||
FORMAT_MS,
|
||||
FORMAT_HEX,
|
||||
FORMAT_MS_4BYTE,
|
||||
@@ -59,45 +59,46 @@ enum {
|
||||
};
|
||||
|
||||
typedef struct mouse_t {
|
||||
const char *name; /* name of this device */
|
||||
const char *name; /* name of this device */
|
||||
|
||||
uint8_t id[252];
|
||||
uint8_t buf[256];
|
||||
uint8_t id[252];
|
||||
uint8_t buf[256];
|
||||
|
||||
uint8_t flags; /* device flags */
|
||||
uint8_t but;
|
||||
uint8_t rts_toggle;
|
||||
uint8_t status;
|
||||
uint8_t format;
|
||||
uint8_t prompt;
|
||||
uint8_t flags; /* device flags */
|
||||
uint8_t but;
|
||||
uint8_t rts_toggle;
|
||||
uint8_t status;
|
||||
uint8_t format;
|
||||
uint8_t prompt;
|
||||
|
||||
uint8_t continuous;
|
||||
uint8_t ib;
|
||||
uint8_t command;
|
||||
uint8_t buf_len;
|
||||
uint8_t report_mode;
|
||||
uint8_t id_len;
|
||||
uint8_t buf_pos;
|
||||
uint8_t rev;
|
||||
uint8_t continuous;
|
||||
uint8_t ib;
|
||||
uint8_t command;
|
||||
uint8_t buf_len;
|
||||
uint8_t report_mode;
|
||||
uint8_t id_len;
|
||||
uint8_t buf_pos;
|
||||
uint8_t rev;
|
||||
|
||||
int8_t type; /* type of this device */
|
||||
int8_t port;
|
||||
int8_t type; /* type of this device */
|
||||
int8_t port;
|
||||
|
||||
int state;
|
||||
int state;
|
||||
|
||||
int bps;
|
||||
int rps;
|
||||
int bps;
|
||||
int default_bps;
|
||||
int rps;
|
||||
|
||||
double transmit_period;
|
||||
double report_period;
|
||||
double cur_period;
|
||||
double min_bit_period;
|
||||
double acc_time;
|
||||
double host_transmit_period;
|
||||
double transmit_period;
|
||||
double report_period;
|
||||
double cur_period;
|
||||
double min_bit_period;
|
||||
double acc_time;
|
||||
double host_transmit_period;
|
||||
|
||||
pc_timer_t timer;
|
||||
pc_timer_t timer;
|
||||
|
||||
serial_t * serial;
|
||||
serial_t *serial;
|
||||
} mouse_t;
|
||||
|
||||
#define FLAG_INPORT 0x80 /* device is MS InPort */
|
||||
@@ -128,7 +129,7 @@ mouse_serial_log(const char *fmt, ...)
|
||||
static void
|
||||
sermouse_set_period(mouse_t *dev, double period)
|
||||
{
|
||||
dev->cur_period = period; /* Needed for the recalculation of the timings. */
|
||||
dev->cur_period = period; /* Needed for the recalculation of the timings. */
|
||||
|
||||
timer_stop(&dev->timer);
|
||||
|
||||
@@ -160,7 +161,7 @@ sermouse_transmit_byte(mouse_t *dev, int do_next)
|
||||
static void
|
||||
sermouse_transmit(mouse_t *dev, int len, int from_report, int to_report)
|
||||
{
|
||||
dev->state = to_report ? STATE_TRANSMIT_REPORT : STATE_TRANSMIT;
|
||||
dev->state = to_report ? STATE_TRANSMIT_REPORT : STATE_TRANSMIT;
|
||||
dev->buf_pos = 0;
|
||||
dev->buf_len = len;
|
||||
|
||||
@@ -186,7 +187,7 @@ sermouse_report_msystems(mouse_t *dev)
|
||||
{
|
||||
int delta_x = 0;
|
||||
int delta_y = 0;
|
||||
int b = mouse_get_buttons_ex();
|
||||
int b = mouse_get_buttons_ex();
|
||||
|
||||
mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -128, 127, 1, 0);
|
||||
|
||||
@@ -195,12 +196,12 @@ sermouse_report_msystems(mouse_t *dev)
|
||||
if (dev->but >= 3)
|
||||
dev->buf[0] |= (b & 0x04) ? 0x00 : 0x02; /* middle button */
|
||||
else
|
||||
dev->buf[0] |= 0x02; /* middle button */
|
||||
dev->buf[0] |= 0x02; /* middle button */
|
||||
dev->buf[0] |= (b & 0x02) ? 0x00 : 0x01; /* right button */
|
||||
dev->buf[1] = delta_x;
|
||||
dev->buf[2] = delta_y;
|
||||
dev->buf[3] = delta_x; /* same as byte 1 */
|
||||
dev->buf[4] = delta_y; /* same as byte 2 */
|
||||
dev->buf[3] = delta_x; /* same as byte 1 */
|
||||
dev->buf[4] = delta_y; /* same as byte 2 */
|
||||
|
||||
return 5;
|
||||
}
|
||||
@@ -210,7 +211,7 @@ sermouse_report_3bp(mouse_t *dev)
|
||||
{
|
||||
int delta_x = 0;
|
||||
int delta_y = 0;
|
||||
int b = mouse_get_buttons_ex();
|
||||
int b = mouse_get_buttons_ex();
|
||||
|
||||
mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -128, 127, 1, 0);
|
||||
|
||||
@@ -218,7 +219,7 @@ sermouse_report_3bp(mouse_t *dev)
|
||||
dev->buf[0] |= (b & 0x01) ? 0x04 : 0x00; /* left button */
|
||||
if (dev->but >= 3)
|
||||
dev->buf[0] |= (b & 0x04) ? 0x02 : 0x00; /* middle button */
|
||||
dev->buf[0] |= (b & 0x02) ? 0x01 : 0x00; /* right button */
|
||||
dev->buf[0] |= (b & 0x02) ? 0x01 : 0x00; /* right button */
|
||||
dev->buf[1] = delta_x;
|
||||
dev->buf[2] = delta_y;
|
||||
|
||||
@@ -230,7 +231,7 @@ sermouse_report_mmseries(mouse_t *dev)
|
||||
{
|
||||
int delta_x = 0;
|
||||
int delta_y = 0;
|
||||
int b = mouse_get_buttons_ex();
|
||||
int b = mouse_get_buttons_ex();
|
||||
|
||||
mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -127, 127, 1, 0);
|
||||
|
||||
@@ -243,7 +244,7 @@ sermouse_report_mmseries(mouse_t *dev)
|
||||
dev->buf[0] |= (b & 0x01) ? 0x04 : 0x00; /* left button */
|
||||
if (dev->but >= 3)
|
||||
dev->buf[0] |= (b & 0x04) ? 0x02 : 0x00; /* middle button */
|
||||
dev->buf[0] |= (b & 0x02) ? 0x01 : 0x00; /* right button */
|
||||
dev->buf[0] |= (b & 0x02) ? 0x01 : 0x00; /* right button */
|
||||
dev->buf[1] = ABS(delta_x) & 0x7f;
|
||||
dev->buf[2] = ABS(delta_y) & 0x7f;
|
||||
mouse_serial_log("MM series mouse report: %02X %02X %02X\n", dev->buf[0], dev->buf[1], dev->buf[2]);
|
||||
@@ -256,7 +257,7 @@ sermouse_report_bp1(mouse_t *dev, int abs)
|
||||
{
|
||||
int delta_x = 0;
|
||||
int delta_y = 0;
|
||||
int b = mouse_get_buttons_ex();
|
||||
int b = mouse_get_buttons_ex();
|
||||
|
||||
mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -2048, 2047, 1, abs);
|
||||
|
||||
@@ -264,7 +265,7 @@ sermouse_report_bp1(mouse_t *dev, int abs)
|
||||
dev->buf[0] |= (b & 0x01) ? 0x10 : 0x00; /* left button */
|
||||
if (dev->but >= 3)
|
||||
dev->buf[0] |= (b & 0x04) ? 0x08 : 0x00; /* middle button */
|
||||
dev->buf[0] |= (b & 0x02) ? 0x04 : 0x00; /* right button */
|
||||
dev->buf[0] |= (b & 0x02) ? 0x04 : 0x00; /* right button */
|
||||
dev->buf[1] = (delta_x & 0x3f);
|
||||
dev->buf[2] = ((delta_x >> 6) & 0x3f);
|
||||
dev->buf[3] = (delta_y & 0x3f);
|
||||
@@ -277,17 +278,17 @@ static uint8_t
|
||||
sermouse_report_ms(mouse_t *dev)
|
||||
{
|
||||
uint8_t len;
|
||||
int delta_x = 0;
|
||||
int delta_y = 0;
|
||||
int delta_z = 0;
|
||||
int b = mouse_get_buttons_ex();
|
||||
int delta_x = 0;
|
||||
int delta_y = 0;
|
||||
int delta_z = 0;
|
||||
int b = mouse_get_buttons_ex();
|
||||
|
||||
mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -128, 127, 0, 0);
|
||||
mouse_subtract_z(&delta_z, -8, 7, 1);
|
||||
|
||||
dev->buf[0] = 0x40;
|
||||
dev->buf[0] |= (((delta_y >> 6) & 0x03) << 2);
|
||||
dev->buf[0] |= ((delta_x >> 6) & 0x03);
|
||||
dev->buf[0] |= ((((delta_y & 0xFF) >> 6) & 0x03) << 2);
|
||||
dev->buf[0] |= (((delta_x & 0xFF) >> 6) & 0x03);
|
||||
if (b & 0x01)
|
||||
dev->buf[0] |= 0x20;
|
||||
if (b & 0x02)
|
||||
@@ -295,7 +296,16 @@ sermouse_report_ms(mouse_t *dev)
|
||||
dev->buf[1] = delta_x & 0x3f;
|
||||
dev->buf[2] = delta_y & 0x3f;
|
||||
mouse_serial_log("Microsoft serial mouse report: %02X %02X %02X\n", dev->buf[0], dev->buf[1], dev->buf[2]);
|
||||
if (dev->but == 3) {
|
||||
if (dev->type == MOUSE_TYPE_MSBPOINT) {
|
||||
len = 4;
|
||||
dev->buf[3] = 0;
|
||||
if (b & 0x4)
|
||||
dev->buf[3] |= 0x8;
|
||||
if (b & 0x8)
|
||||
dev->buf[3] |= 0x4;
|
||||
dev->buf[3] |= !!(delta_y < 0) ? 0x2 : 0;
|
||||
dev->buf[3] |= !!(delta_x < 0) ? 0x1 : 0;
|
||||
} else if (dev->but == 3) {
|
||||
len = 3;
|
||||
if (dev->format == FORMAT_MS) {
|
||||
if (b & 0x04) {
|
||||
@@ -325,18 +335,18 @@ sermouse_report_ms(mouse_t *dev)
|
||||
static uint8_t
|
||||
sermouse_report_hex(mouse_t *dev)
|
||||
{
|
||||
char ret[6] = { 0, 0, 0, 0, 0, 0 };
|
||||
uint8_t but = 0x00;
|
||||
int delta_x = 0;
|
||||
int delta_y = 0;
|
||||
int b = mouse_get_buttons_ex();
|
||||
char ret[6] = { 0, 0, 0, 0, 0, 0 };
|
||||
uint8_t but = 0x00;
|
||||
int delta_x = 0;
|
||||
int delta_y = 0;
|
||||
int b = mouse_get_buttons_ex();
|
||||
|
||||
mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -128, 127, 1, 0);
|
||||
|
||||
but |= (b & 0x01) ? 0x04 : 0x00; /* left button */
|
||||
if (dev->but >= 3)
|
||||
but |= (b & 0x04) ? 0x02 : 0x00; /* middle button */
|
||||
but |= (b & 0x02) ? 0x01 : 0x00; /* right button */
|
||||
but |= (b & 0x02) ? 0x01 : 0x00; /* right button */
|
||||
|
||||
sprintf(ret, "%01X%02X%02X", but & 0x0f, (int8_t) delta_x, (int8_t) delta_y);
|
||||
|
||||
@@ -441,14 +451,14 @@ ltsermouse_set_report_period(mouse_t *dev, int rps)
|
||||
sermouse_set_period(dev, 0.0);
|
||||
|
||||
dev->report_period = 0.0;
|
||||
dev->continuous = 1;
|
||||
dev->continuous = 1;
|
||||
} else {
|
||||
#if 0
|
||||
if (rps > dev->max_rps)
|
||||
rps = dev->max_rps;
|
||||
#endif
|
||||
|
||||
dev->continuous = 0;
|
||||
dev->continuous = 0;
|
||||
dev->report_period = 1000000.0 / ((double) rps);
|
||||
/* Actual spacing between reports. */
|
||||
}
|
||||
@@ -470,21 +480,22 @@ ltsermouse_update_report_period(mouse_t *dev)
|
||||
}
|
||||
|
||||
static void
|
||||
ltsermouse_switch_baud_rate(mouse_t *dev, int next_state)
|
||||
ltsermouse_switch_baud_rate(mouse_t *dev, int next_state, int prompt_off)
|
||||
{
|
||||
double word_lens[FORMATS_NUM] = {
|
||||
[FORMAT_BP1_ABS] = 7.0 + 1.0, /* 7 data bits + even parity */
|
||||
[FORMAT_BP1_REL] = 7.0 + 1.0, /* 7 data bits + even parity */
|
||||
[FORMAT_MM_SERIES] = 8.0 + 1.0, /* 8 data bits + odd parity */
|
||||
[FORMAT_PB_3BYTE] = 8.0, /* 8 data bits + no parity */
|
||||
[FORMAT_PB_5BYTE] = 8.0, /* 8 data bits + no parity */
|
||||
[FORMAT_MS] = 7.0, /* 7 datas bits + no parity */
|
||||
[FORMAT_HEX] = 8.0, /* 8 data bits + no parity */
|
||||
[FORMAT_MS_4BYTE] = 7.0, /* 7 datas bits + no parity */
|
||||
[FORMAT_MS_WHEEL] = 7.0 }; /* 7 datas bits + no parity */
|
||||
[FORMAT_BP1_ABS] = 7.0 + 1.0, /* 7 data bits + even parity */
|
||||
[FORMAT_BP1_REL] = 7.0 + 1.0, /* 7 data bits + even parity */
|
||||
[FORMAT_MM_SERIES] = 8.0 + 1.0, /* 8 data bits + odd parity */
|
||||
[FORMAT_PB_3BYTE] = 8.0, /* 8 data bits + no parity */
|
||||
[FORMAT_PB_5BYTE] = 8.0, /* 8 data bits + no parity */
|
||||
[FORMAT_MS] = 7.0, /* 7 datas bits + no parity */
|
||||
[FORMAT_HEX] = 8.0, /* 8 data bits + no parity */
|
||||
[FORMAT_MS_4BYTE] = 7.0, /* 7 datas bits + no parity */
|
||||
[FORMAT_MS_WHEEL] = 7.0 /* 7 datas bits + no parity */
|
||||
};
|
||||
double word_len = word_lens[dev->format];
|
||||
|
||||
word_len += 1.0 + 2.0; /* 1 start bit + 2 stop bits */
|
||||
word_len += 1.0 + 2.0; /* 1 start bit + 2 stop bits */
|
||||
|
||||
#if 0
|
||||
dev->max_rps = (int) floor(((double) dev->bps) / (word_len * num_words));
|
||||
@@ -506,7 +517,7 @@ ltsermouse_switch_baud_rate(mouse_t *dev, int next_state)
|
||||
ltsermouse_set_report_period(dev, dev->rps);
|
||||
|
||||
if (!dev->continuous && (next_state != STATE_BAUD_RATE)) {
|
||||
if (dev->prompt)
|
||||
if (dev->prompt && prompt_off)
|
||||
ltsermouse_set_prompt_mode(dev, 0);
|
||||
|
||||
sermouse_transmit_report(dev, 0);
|
||||
@@ -531,18 +542,19 @@ sermouse_next_state(mouse_t *dev)
|
||||
static void
|
||||
ltsermouse_process_command(mouse_t *dev)
|
||||
{
|
||||
int cmd_to_rps[9] = { 10, 20, 35, 70, 150, 0, -1, 100, 50 };
|
||||
int b;
|
||||
int cmd_to_rps[9] = { 10, 20, 35, 70, 150, 0, -1, 100, 50 };
|
||||
int b;
|
||||
uint8_t format_codes[FORMATS_NUM] = {
|
||||
[FORMAT_BP1_ABS] = 0x0c,
|
||||
[FORMAT_BP1_REL] = 0x06,
|
||||
[FORMAT_MM_SERIES] = 0x0a,
|
||||
[FORMAT_PB_3BYTE] = 0x00,
|
||||
[FORMAT_PB_5BYTE] = 0x02,
|
||||
[FORMAT_MS] = 0x0e,
|
||||
[FORMAT_HEX] = 0x04,
|
||||
[FORMAT_MS_4BYTE] = 0x08, /* Guess */
|
||||
[FORMAT_MS_WHEEL] = 0x08 }; /* Guess */
|
||||
[FORMAT_BP1_ABS] = 0x0c,
|
||||
[FORMAT_BP1_REL] = 0x06,
|
||||
[FORMAT_MM_SERIES] = 0x0a,
|
||||
[FORMAT_PB_3BYTE] = 0x00,
|
||||
[FORMAT_PB_5BYTE] = 0x02,
|
||||
[FORMAT_MS] = 0x0e,
|
||||
[FORMAT_HEX] = 0x04,
|
||||
[FORMAT_MS_4BYTE] = 0x08, /* Guess */
|
||||
[FORMAT_MS_WHEEL] = 0x08 /* Guess */
|
||||
};
|
||||
const char *copr = "\r\n(C) " COPYRIGHT_YEAR " 86Box, Revision 3.0";
|
||||
|
||||
mouse_serial_log("ltsermouse_process_command(): %02X\n", dev->ib);
|
||||
@@ -551,13 +563,13 @@ ltsermouse_process_command(mouse_t *dev)
|
||||
switch (dev->command) {
|
||||
case 0x20:
|
||||
/* Auto Baud Selection */
|
||||
dev->bps = (int) floor(1000000.0 / dev->host_transmit_period);
|
||||
dev->bps = (int) floor(1000000.0 / dev->host_transmit_period);
|
||||
dev->transmit_period = dev->host_transmit_period;
|
||||
|
||||
dev->buf[0] = 0x06;
|
||||
sermouse_transmit(dev, 1, 0, 0);
|
||||
|
||||
ltsermouse_switch_baud_rate(dev, STATE_BAUD_RATE);
|
||||
ltsermouse_switch_baud_rate(dev, STATE_BAUD_RATE, 0);
|
||||
break;
|
||||
|
||||
case 0x4a: /* Report Rate Selection commands */
|
||||
@@ -569,7 +581,7 @@ ltsermouse_process_command(mouse_t *dev)
|
||||
case 0x4e:
|
||||
case 0x4f:
|
||||
dev->report_mode = dev->command;
|
||||
dev->rps = cmd_to_rps[dev->command - 0x4a];
|
||||
dev->rps = cmd_to_rps[dev->command - 0x4a];
|
||||
ltsermouse_update_report_period(dev);
|
||||
break;
|
||||
|
||||
@@ -593,16 +605,16 @@ ltsermouse_process_command(mouse_t *dev)
|
||||
/* Absolute Bit Pad One Packed Binary Format */
|
||||
mouse_clear_coords();
|
||||
fallthrough;
|
||||
case 0x42: /* Relative Bit Pad One Packed Binary Format */
|
||||
case 0x53: /* MM Series Data Format */
|
||||
case 0x54: /* Three Byte Packed Binary Format */
|
||||
case 0x55: /* Five Byte Packed Binary Format (Mouse Systems-compatible) */
|
||||
case 0x56: /* Microsoft Compatible Format */
|
||||
case 0x57: /* Hexadecimal Format */
|
||||
case 0x58: /* Microsoft Compatible Format (3+1 byte 3-button, from the FreeBSD source code) */
|
||||
case 0x42: /* Relative Bit Pad One Packed Binary Format */
|
||||
case 0x53: /* MM Series Data Format */
|
||||
case 0x54: /* Three Byte Packed Binary Format */
|
||||
case 0x55: /* Five Byte Packed Binary Format (Mouse Systems-compatible) */
|
||||
case 0x56: /* Microsoft Compatible Format */
|
||||
case 0x57: /* Hexadecimal Format */
|
||||
case 0x58: /* Microsoft Compatible Format (3+1 byte 3-button, from the FreeBSD source code) */
|
||||
if ((dev->rev >= 0x02) && ((dev->command != 0x58) || (dev->rev > 0x04))) {
|
||||
dev->format = dev->command & 0x1f;
|
||||
ltsermouse_switch_baud_rate(dev, sermouse_next_state(dev));
|
||||
ltsermouse_switch_baud_rate(dev, sermouse_next_state(dev), 0);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -620,7 +632,7 @@ ltsermouse_process_command(mouse_t *dev)
|
||||
break;
|
||||
case 0x05:
|
||||
/* Diagnostic */
|
||||
b = mouse_get_buttons_ex();
|
||||
b = mouse_get_buttons_ex();
|
||||
dev->buf[0] = ((b & 0x01) << 2) | ((b & 0x06) >> 1);
|
||||
dev->buf[1] = dev->buf[2] = 0x00;
|
||||
sermouse_transmit(dev, 3, 0, 0);
|
||||
@@ -630,7 +642,7 @@ ltsermouse_process_command(mouse_t *dev)
|
||||
if (dev->rev >= 0x20) {
|
||||
/* Format and Revision Number */
|
||||
dev->buf[0] = format_codes[dev->format];
|
||||
dev->buf[0] |= 0x10; /* Revision 3.0, 0x00 would be Revision 2.0 */
|
||||
dev->buf[0] |= 0x10; /* Revision 3.0, 0x00 would be Revision 2.0 */
|
||||
sermouse_transmit(dev, 1, 0, 0);
|
||||
}
|
||||
break;
|
||||
@@ -676,7 +688,7 @@ ltsermouse_process_data(mouse_t *dev)
|
||||
{
|
||||
mouse_serial_log("ltsermouse_process_data(): %02X (command = %02X)\n", dev->ib, dev->command);
|
||||
|
||||
switch(dev->command) {
|
||||
switch (dev->command) {
|
||||
case 0x2a:
|
||||
switch (dev->ib) {
|
||||
default:
|
||||
@@ -694,7 +706,7 @@ ltsermouse_process_data(mouse_t *dev)
|
||||
dev->bps = 9600;
|
||||
break;
|
||||
}
|
||||
ltsermouse_switch_baud_rate(dev, (dev->prompt || dev->continuous) ? STATE_IDLE : STATE_TRANSMIT_REPORT);
|
||||
ltsermouse_switch_baud_rate(dev, (dev->prompt || dev->continuous) ? STATE_IDLE : STATE_TRANSMIT_REPORT, 0);
|
||||
break;
|
||||
default:
|
||||
dev->state = STATE_IDLE;
|
||||
@@ -707,25 +719,32 @@ sermouse_reset(mouse_t *dev, int callback)
|
||||
{
|
||||
sermouse_set_period(dev, 0.0);
|
||||
|
||||
dev->bps = 1200;
|
||||
dev->rps = 0;
|
||||
if (dev->default_bps)
|
||||
dev->bps = dev->default_bps;
|
||||
else
|
||||
dev->bps = 1200;
|
||||
dev->rps = 0;
|
||||
dev->prompt = 0;
|
||||
if (dev->id[0] == 'H')
|
||||
dev->format = FORMAT_MSYSTEMS;
|
||||
else switch (dev->but) {
|
||||
default:
|
||||
case 2:
|
||||
dev->format = FORMAT_MS;
|
||||
break;
|
||||
case 3:
|
||||
dev->format = (dev->type == MOUSE_TYPE_LT3BUTTON) ? FORMAT_MS : FORMAT_MS_4BYTE;
|
||||
break;
|
||||
case 4:
|
||||
dev->format = FORMAT_MS_WHEEL;
|
||||
break;
|
||||
}
|
||||
else
|
||||
switch (dev->but) {
|
||||
default:
|
||||
case 2:
|
||||
dev->format = FORMAT_MS;
|
||||
break;
|
||||
case 3:
|
||||
dev->format = (dev->type == MOUSE_TYPE_LT3BUTTON) ? FORMAT_MS : FORMAT_MS_4BYTE;
|
||||
break;
|
||||
case 4:
|
||||
dev->format = FORMAT_MS_WHEEL;
|
||||
break;
|
||||
case 5:
|
||||
dev->format = FORMAT_MS;
|
||||
break;
|
||||
}
|
||||
|
||||
ltsermouse_switch_baud_rate(dev, callback ? STATE_TRANSMIT : STATE_IDLE);
|
||||
ltsermouse_switch_baud_rate(dev, callback ? STATE_TRANSMIT : STATE_IDLE, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -840,7 +859,7 @@ sermouse_close(void *priv)
|
||||
static void *
|
||||
sermouse_init(const device_t *info)
|
||||
{
|
||||
mouse_t *dev;
|
||||
mouse_t *dev = (mouse_t *) calloc(1, sizeof(mouse_t));
|
||||
void (*rcr_callback)(struct serial_s *serial, void *priv);
|
||||
void (*dev_write)(struct serial_s *serial, void *priv, uint8_t data);
|
||||
void (*transmit_period_callback)(struct serial_s *serial, void *priv,
|
||||
@@ -850,34 +869,42 @@ sermouse_init(const device_t *info)
|
||||
uintptr_t irqbase = ((device_get_config_int("irq") << 16) |
|
||||
(device_get_config_hex16("addr") << 20)) |
|
||||
ns16450_device.local;
|
||||
device_add_params(&ns16450_device, (void*)irqbase);
|
||||
device_add_params(&ns16450_device, (void *) irqbase);
|
||||
}
|
||||
|
||||
dev = (mouse_t *) calloc(1, sizeof(mouse_t));
|
||||
dev->name = info->name;
|
||||
dev->but = device_get_config_int("buttons");
|
||||
dev->rev = device_get_config_int("revision");
|
||||
dev->but = (info->local == MOUSE_TYPE_MSBPOINT) ? 5 : device_get_config_int("buttons");
|
||||
|
||||
if (info->local == 0)
|
||||
dev->rts_toggle = 1;
|
||||
if ((info->local == 0) || (info->local == MOUSE_TYPE_MSBPOINT))
|
||||
dev->rts_toggle = 1;
|
||||
else
|
||||
dev->rts_toggle = device_get_config_int("rts_toggle");
|
||||
dev->rts_toggle = device_get_config_int("rts_toggle");
|
||||
|
||||
if (dev->but > 2)
|
||||
dev->flags |= FLAG_3BTN;
|
||||
|
||||
if (info->local == MOUSE_TYPE_MSYSTEMS || info->local == MOUSE_TYPE_MSYSTEMSB) {
|
||||
dev->format = 0;
|
||||
dev->type = info->local;
|
||||
dev->id_len = 1;
|
||||
dev->id[0] = 'H';
|
||||
if (info->local == MOUSE_TYPE_MSBPOINT) {
|
||||
dev->format = 7;
|
||||
dev->status = 0x0f;
|
||||
dev->type = MOUSE_TYPE_MSBPOINT;
|
||||
dev->id_len = 1;
|
||||
dev->id[0] = 'B';
|
||||
dev->flags &= ~FLAG_3BTN;
|
||||
} else if ((info->local == MOUSE_TYPE_MSYSTEMS) || (info->local == MOUSE_TYPE_MSYSTEMSB)) {
|
||||
dev->format = 0;
|
||||
dev->type = info->local;
|
||||
dev->id_len = 1;
|
||||
dev->id[0] = 'H';
|
||||
} else {
|
||||
dev->format = 7;
|
||||
dev->status = 0x0f;
|
||||
dev->id_len = 1;
|
||||
dev->id[0] = 'M';
|
||||
if (info->local)
|
||||
dev->rev = device_get_config_int("revision");
|
||||
dev->format = 7;
|
||||
dev->status = 0x0f;
|
||||
dev->id_len = 1;
|
||||
dev->id[0] = 'M';
|
||||
if (info->local == 1) {
|
||||
/* Logitech Serial Mouse */
|
||||
dev->rev = device_get_config_int("revision");
|
||||
dev->default_bps = device_get_config_int("default_baud");
|
||||
}
|
||||
switch (dev->but) {
|
||||
default:
|
||||
case 2:
|
||||
@@ -900,8 +927,8 @@ sermouse_init(const device_t *info)
|
||||
dev->port = (info->local == MOUSE_TYPE_MSYSTEMSB) ? (SERIAL_MAX - 1) : device_get_config_int("port");
|
||||
|
||||
/* Attach a serial port to the mouse. */
|
||||
rcr_callback = dev->rts_toggle ? sermouse_callback : NULL;
|
||||
dev_write = (info->local == 1) ? ltsermouse_write : NULL;
|
||||
rcr_callback = dev->rts_toggle ? sermouse_callback : NULL;
|
||||
dev_write = (info->local == 1) ? ltsermouse_write : NULL;
|
||||
transmit_period_callback = (info->local == 1) ? ltsermouse_transmit_period : NULL;
|
||||
|
||||
dev->serial = serial_attach_ex(dev->port, rcr_callback, dev_write,
|
||||
@@ -923,25 +950,28 @@ sermouse_init(const device_t *info)
|
||||
return dev;
|
||||
}
|
||||
|
||||
#define SERMOUSE_PORT_CONFIG_COMMON \
|
||||
{ \
|
||||
.name = "port", \
|
||||
.description = "Serial Port", \
|
||||
.type = CONFIG_SELECTION, \
|
||||
.default_string = NULL, \
|
||||
.default_int = 0, \
|
||||
.file_filter = NULL, \
|
||||
.spinner = { 0 }, \
|
||||
.selection = { \
|
||||
{ .description = "COM1", .value = 0 }, \
|
||||
{ .description = "COM2", .value = 1 }, \
|
||||
{ .description = "COM3", .value = 2 }, \
|
||||
{ .description = "COM4", .value = 3 }, \
|
||||
{ .description = "" } \
|
||||
}, \
|
||||
.bios = { { 0 } } \
|
||||
}
|
||||
|
||||
static const device_config_t msssermouse_config[] = {
|
||||
// clang-format off
|
||||
{
|
||||
.name = "port",
|
||||
.description = "Serial Port",
|
||||
.type = CONFIG_SELECTION,
|
||||
.default_string = NULL,
|
||||
.default_int = 0,
|
||||
.file_filter = NULL,
|
||||
.spinner = { 0 },
|
||||
.selection = {
|
||||
{ .description = "COM1", .value = 0 },
|
||||
{ .description = "COM2", .value = 1 },
|
||||
{ .description = "COM3", .value = 2 },
|
||||
{ .description = "COM4", .value = 3 },
|
||||
{ .description = "" }
|
||||
},
|
||||
.bios = { { 0 } }
|
||||
},
|
||||
// clang-format off
|
||||
SERMOUSE_PORT_CONFIG_COMMON,
|
||||
{
|
||||
.name = "buttons",
|
||||
.description = "Buttons",
|
||||
@@ -969,7 +999,7 @@ static const device_config_t msssermouse_config[] = {
|
||||
.bios = { { 0 } }
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static const device_config_t mssbusmouse_config[] = {
|
||||
@@ -1042,27 +1072,11 @@ static const device_config_t mssbusmouse_config[] = {
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
// clang-format on
|
||||
};
|
||||
};
|
||||
|
||||
static const device_config_t mssermouse_config[] = {
|
||||
// clang-format off
|
||||
{
|
||||
.name = "port",
|
||||
.description = "Serial Port",
|
||||
.type = CONFIG_SELECTION,
|
||||
.default_string = NULL,
|
||||
.default_int = 0,
|
||||
.file_filter = NULL,
|
||||
.spinner = { 0 },
|
||||
.selection = {
|
||||
{ .description = "COM1", .value = 0 },
|
||||
{ .description = "COM2", .value = 1 },
|
||||
{ .description = "COM3", .value = 2 },
|
||||
{ .description = "COM4", .value = 3 },
|
||||
{ .description = "" }
|
||||
},
|
||||
.bios = { { 0 } }
|
||||
},
|
||||
// clang-format off
|
||||
SERMOUSE_PORT_CONFIG_COMMON,
|
||||
{
|
||||
.name = "buttons",
|
||||
.description = "Buttons",
|
||||
@@ -1080,28 +1094,19 @@ static const device_config_t mssermouse_config[] = {
|
||||
.bios = { { 0 } }
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static const device_config_t msballpoint_config[] = {
|
||||
// clang-format off
|
||||
SERMOUSE_PORT_CONFIG_COMMON,
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static const device_config_t ltsermouse_config[] = {
|
||||
// clang-format off
|
||||
{
|
||||
.name = "port",
|
||||
.description = "Serial Port",
|
||||
.type = CONFIG_SELECTION,
|
||||
.default_string = NULL,
|
||||
.default_int = 0,
|
||||
.file_filter = NULL,
|
||||
.spinner = { 0 },
|
||||
.selection = {
|
||||
{ .description = "COM1", .value = 0 },
|
||||
{ .description = "COM2", .value = 1 },
|
||||
{ .description = "COM3", .value = 2 },
|
||||
{ .description = "COM4", .value = 3 },
|
||||
{ .description = "" }
|
||||
},
|
||||
.bios = { { 0 } }
|
||||
},
|
||||
// clang-format off
|
||||
SERMOUSE_PORT_CONFIG_COMMON,
|
||||
{
|
||||
.name = "buttons",
|
||||
.description = "Buttons",
|
||||
@@ -1134,6 +1139,23 @@ static const device_config_t ltsermouse_config[] = {
|
||||
},
|
||||
.bios = { { 0 } }
|
||||
},
|
||||
{
|
||||
.name = "default_baud",
|
||||
.description = "Default Baud rate",
|
||||
.type = CONFIG_SELECTION,
|
||||
.default_string = NULL,
|
||||
.default_int = 1200,
|
||||
.file_filter = NULL,
|
||||
.spinner = { 0 },
|
||||
.selection = {
|
||||
{ .description = "1200", .value = 1200 },
|
||||
{ .description = "2400", .value = 2400 },
|
||||
{ .description = "4800", .value = 4800 },
|
||||
{ .description = "9600", .value = 9600 },
|
||||
{ .description = "" }
|
||||
},
|
||||
.bios = { { 0 } }
|
||||
},
|
||||
{
|
||||
.name = "rts_toggle",
|
||||
.description = "RTS toggle",
|
||||
@@ -1146,7 +1168,7 @@ static const device_config_t ltsermouse_config[] = {
|
||||
.bios = { { 0 } }
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
const device_t mouse_mssystems_device = {
|
||||
@@ -1191,6 +1213,20 @@ const device_t mouse_msserial_device = {
|
||||
.config = mssermouse_config
|
||||
};
|
||||
|
||||
const device_t mouse_msserial_ballpoint_device = {
|
||||
.name = "Microsoft Serial BallPoint",
|
||||
.internal_name = "msballpoint",
|
||||
.flags = DEVICE_COM,
|
||||
.local = MOUSE_TYPE_MSBPOINT,
|
||||
.init = sermouse_init,
|
||||
.close = sermouse_close,
|
||||
.reset = NULL,
|
||||
.available = NULL,
|
||||
.speed_changed = sermouse_speed_changed,
|
||||
.force_redraw = NULL,
|
||||
.config = msballpoint_config
|
||||
};
|
||||
|
||||
const device_t mouse_ltserial_device = {
|
||||
.name = "Logitech Serial Mouse",
|
||||
.internal_name = "ltserial",
|
||||
|
||||
444
src/device/mouse_upc.c
Normal file
444
src/device/mouse_upc.c
Normal file
@@ -0,0 +1,444 @@
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Implementation of the Chips & Technologies F82C710 Universal
|
||||
* Peripheral Controller (UPC) PS/2 mouse port.
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
* Copyright 2025 Miran Grca.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#define HAVE_STDARG_H
|
||||
#include <wchar.h>
|
||||
#include <86box/86box.h>
|
||||
#include "cpu.h"
|
||||
#include "x86seg.h"
|
||||
#include <86box/device.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/io.h>
|
||||
#include <86box/pic.h>
|
||||
#include <86box/keyboard.h>
|
||||
#include <86box/mouse.h>
|
||||
|
||||
#define STAT_DEV_IDLE 0x01
|
||||
#define STAT_RX_FULL 0x02
|
||||
#define STAT_TX_IDLE 0x04
|
||||
#define STAT_RESET 0x08
|
||||
#define STAT_INTS_ON 0x10
|
||||
#define STAT_ERROR_FLAG 0x20
|
||||
#define STAT_CLEAR 0x40
|
||||
#define STAT_ENABLE 0x80
|
||||
|
||||
typedef struct mouse_upc_t {
|
||||
uint8_t status;
|
||||
uint8_t ib;
|
||||
uint8_t ob;
|
||||
uint8_t state;
|
||||
uint8_t ctrl_queue_start;
|
||||
uint8_t ctrl_queue_end;
|
||||
|
||||
uint8_t handler_enable[2];
|
||||
|
||||
uint16_t mdata_addr;
|
||||
uint16_t mstat_addr;
|
||||
|
||||
uint16_t irq;
|
||||
|
||||
uint16_t base_addr[2];
|
||||
|
||||
/* Local copies of the pointers to both ports for easier swapping (AMI '5' MegaKey). */
|
||||
kbc_at_port_t *port;
|
||||
|
||||
/* Main timers. */
|
||||
pc_timer_t poll_timer;
|
||||
pc_timer_t dev_poll_timer;
|
||||
|
||||
struct {
|
||||
uint8_t (*read)(uint16_t port, void *priv);
|
||||
void (*write)(uint16_t port, uint8_t val, void *priv);
|
||||
} handlers[2];
|
||||
|
||||
void *mouse_ps2;
|
||||
} mouse_upc_t;
|
||||
|
||||
enum {
|
||||
STATE_MAIN_IBF, /* UPC checking if the input buffer is full. */
|
||||
STATE_MAIN, /* UPC checking if the auxiliary has anything to send. */
|
||||
STATE_OUT, /* UPC is sending multiple bytes. */
|
||||
STATE_SEND, /* UPC is sending command to the auxiliary device. */
|
||||
STATE_SCAN /* UPC is waiting for the auxiliary command response. */
|
||||
};
|
||||
|
||||
#ifdef ENABLE_MOUSE_UPC_LOG
|
||||
int mouse_upc_do_log = ENABLE_MOUSE_UPC_LOG;
|
||||
|
||||
static void
|
||||
mouse_upc_log(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (mouse_upc_do_log) {
|
||||
va_start(ap, fmt);
|
||||
pclog_ex(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define mouse_upc_log(fmt, ...)
|
||||
#endif
|
||||
|
||||
static void
|
||||
mouse_upc_send_to_ob(mouse_upc_t *dev, uint8_t val)
|
||||
{
|
||||
dev->status = (dev->status & ~STAT_DEV_IDLE) | STAT_RX_FULL;
|
||||
|
||||
if (dev->status & STAT_INTS_ON) {
|
||||
picint_common(1 << dev->irq, 0, 0, NULL);
|
||||
picint_common(1 << dev->irq, 0, 1, NULL);
|
||||
}
|
||||
|
||||
dev->ob = val;
|
||||
}
|
||||
|
||||
static void
|
||||
set_enable_aux(mouse_upc_t *dev, uint8_t enable)
|
||||
{
|
||||
dev->status &= ~STAT_ENABLE;
|
||||
dev->status |= (enable ? STAT_ENABLE : 0x00);
|
||||
}
|
||||
|
||||
static void
|
||||
mouse_upc_ibf_process(mouse_upc_t *dev)
|
||||
{
|
||||
/* IBF set, process both commands and data. */
|
||||
dev->status |= STAT_TX_IDLE;
|
||||
dev->state = STATE_MAIN_IBF;
|
||||
|
||||
set_enable_aux(dev, 1);
|
||||
|
||||
if (dev->port != NULL) {
|
||||
dev->port->wantcmd = 1;
|
||||
dev->port->dat = dev->ib;
|
||||
dev->state = STATE_SEND;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Correct Procedure:
|
||||
1. Controller asks the device (keyboard or auxiliary device) for a byte.
|
||||
2. The device, unless it's in the reset or command states, sees if there's anything to give it,
|
||||
and if yes, begins the transfer.
|
||||
3. The controller checks if there is a transfer, if yes, transfers the byte and sends it to the host,
|
||||
otherwise, checks the next device, or if there is no device left to check, checks if IBF is full
|
||||
and if yes, processes it.
|
||||
*/
|
||||
static int
|
||||
mouse_upc_scan(mouse_upc_t *dev)
|
||||
{
|
||||
if ((dev->port != NULL) && (dev->port->out_new != -1)) {
|
||||
mouse_upc_log("UPC Mouse: %02X coming\n", dev->port->out_new & 0xff);
|
||||
mouse_upc_send_to_ob(dev, dev->port->out_new);
|
||||
dev->port->out_new = -1;
|
||||
dev->state = STATE_MAIN_IBF;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
mouse_upc_poll(void *priv)
|
||||
{
|
||||
mouse_upc_t *dev = (mouse_upc_t *) priv;
|
||||
|
||||
timer_advance_u64(&dev->poll_timer, (100ULL * TIMER_USEC));
|
||||
|
||||
switch (dev->state) {
|
||||
case STATE_MAIN_IBF:
|
||||
default:
|
||||
if (!(dev->status & STAT_TX_IDLE))
|
||||
mouse_upc_ibf_process(dev);
|
||||
else if (!(dev->status & STAT_RX_FULL)) {
|
||||
if (dev->status & STAT_ENABLE)
|
||||
dev->state = STATE_MAIN;
|
||||
}
|
||||
break;
|
||||
case STATE_MAIN:
|
||||
if (!(dev->status & STAT_TX_IDLE))
|
||||
mouse_upc_ibf_process(dev);
|
||||
else {
|
||||
(void) mouse_upc_scan(dev);
|
||||
dev->state = STATE_MAIN_IBF;
|
||||
}
|
||||
break;
|
||||
case STATE_SEND:
|
||||
if (!dev->port->wantcmd)
|
||||
dev->state = STATE_SCAN;
|
||||
break;
|
||||
case STATE_SCAN:
|
||||
(void) mouse_upc_scan(dev);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
mouse_upc_dev_poll(void *priv)
|
||||
{
|
||||
mouse_upc_t *dev = (mouse_upc_t *) priv;
|
||||
|
||||
timer_advance_u64(&dev->dev_poll_timer, (100ULL * TIMER_USEC));
|
||||
|
||||
if ((dev->port != NULL) && (dev->port->priv != NULL))
|
||||
dev->port->poll(dev->port->priv);
|
||||
}
|
||||
|
||||
static void
|
||||
mouse_upc_port_1_write(uint16_t port, uint8_t val, void *priv)
|
||||
{
|
||||
mouse_upc_t *dev = (mouse_upc_t *) priv;
|
||||
|
||||
mouse_upc_log("UPC Mouse: [%04X:%08X] write(%04X) = %02X\n", CS, cpu_state.pc, port, val);
|
||||
|
||||
if ((dev->status & STAT_TX_IDLE) && (dev->status & STAT_ENABLE)) {
|
||||
dev->ib = val;
|
||||
dev->status &= ~STAT_TX_IDLE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
mouse_upc_port_2_write(uint16_t port, uint8_t val, void *priv)
|
||||
{
|
||||
mouse_upc_t *dev = (mouse_upc_t *) priv;
|
||||
|
||||
mouse_upc_log("UPC Mouse: [%04X:%08X] write(%04X) = %02X\n", CS, cpu_state.pc, port, val);
|
||||
|
||||
dev->status = (dev->status & 0x27) | (val & 0xd8);
|
||||
|
||||
if (dev->status & (STAT_CLEAR | STAT_RESET)) {
|
||||
/* TODO: Silently reset the mouse. */
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
mouse_upc_port_1_read(uint16_t port, void *priv)
|
||||
{
|
||||
mouse_upc_t *dev = (mouse_upc_t *) priv;
|
||||
uint8_t ret = 0xff;
|
||||
|
||||
cycles -= ISA_CYCLES(8);
|
||||
|
||||
ret = dev->ob;
|
||||
dev->ob = 0xff;
|
||||
dev->status &= ~STAT_RX_FULL;
|
||||
dev->status |= STAT_DEV_IDLE;
|
||||
|
||||
mouse_upc_log("UPC Mouse: [%04X:%08X] read (%04X) = %02X\n", CS, cpu_state.pc, port, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
mouse_upc_port_2_read(uint16_t port, void *priv)
|
||||
{
|
||||
mouse_upc_t *dev = (mouse_upc_t *) priv;
|
||||
uint8_t ret = 0xff;
|
||||
|
||||
cycles -= ISA_CYCLES(8);
|
||||
|
||||
ret = dev->status;
|
||||
|
||||
mouse_upc_log("UPC Mouse: [%04X:%08X] read (%04X) = %02X\n", CS, cpu_state.pc, port, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
mouse_upc_reset(void *priv)
|
||||
{
|
||||
mouse_upc_t *dev = (mouse_upc_t *) priv;
|
||||
|
||||
dev->status = STAT_DEV_IDLE | STAT_TX_IDLE;
|
||||
dev->ob = 0xff;
|
||||
|
||||
dev->state = STATE_MAIN_IBF;
|
||||
}
|
||||
|
||||
static void
|
||||
mouse_upc_close(void *priv)
|
||||
{
|
||||
mouse_upc_t *dev = (mouse_upc_t *) priv;
|
||||
|
||||
/* Stop timers. */
|
||||
timer_disable(&dev->dev_poll_timer);
|
||||
timer_disable(&dev->poll_timer);
|
||||
|
||||
if (kbc_at_ports[1] != NULL) {
|
||||
free(kbc_at_ports[1]);
|
||||
kbc_at_ports[1] = NULL;
|
||||
}
|
||||
|
||||
free(dev);
|
||||
}
|
||||
|
||||
void
|
||||
mouse_upc_port_handler(int num, int set, uint16_t port, void *priv)
|
||||
{
|
||||
mouse_upc_t *dev = (mouse_upc_t *) priv;
|
||||
|
||||
if (dev->handler_enable[num] && (dev->base_addr[num] != 0x0000))
|
||||
io_removehandler(dev->base_addr[num], 1,
|
||||
dev->handlers[num].read, NULL, NULL,
|
||||
dev->handlers[num].write, NULL, NULL, priv);
|
||||
|
||||
dev->handler_enable[num] = set;
|
||||
dev->base_addr[num] = port;
|
||||
|
||||
if (dev->handler_enable[num] && (dev->base_addr[num] != 0x0000))
|
||||
io_sethandler(dev->base_addr[num], 1,
|
||||
dev->handlers[num].read, NULL, NULL,
|
||||
dev->handlers[num].write, NULL, NULL, priv);
|
||||
}
|
||||
|
||||
void
|
||||
mouse_upc_handler(int set, uint16_t port, void *priv)
|
||||
{
|
||||
mouse_upc_port_handler(0, set, port, priv);
|
||||
mouse_upc_port_handler(1, set, port + 0x0001, priv);
|
||||
}
|
||||
|
||||
void
|
||||
mouse_upc_set_irq(int num, uint16_t irq, void *priv)
|
||||
{
|
||||
mouse_upc_t *dev = (mouse_upc_t *) priv;
|
||||
|
||||
if (dev->irq != 0xffff)
|
||||
picintc(1 << dev->irq);
|
||||
|
||||
dev->irq = irq;
|
||||
}
|
||||
|
||||
static void *
|
||||
mouse_upc_init_common(int standalone, int irq)
|
||||
{
|
||||
mouse_upc_t *dev;
|
||||
|
||||
dev = (mouse_upc_t *) calloc(1, sizeof(mouse_upc_t));
|
||||
|
||||
mouse_upc_reset(dev);
|
||||
|
||||
dev->handlers[0].read = mouse_upc_port_1_read;
|
||||
dev->handlers[0].write = mouse_upc_port_1_write;
|
||||
dev->handlers[1].read = mouse_upc_port_2_read;
|
||||
dev->handlers[1].write = mouse_upc_port_2_write;
|
||||
|
||||
dev->irq = irq;
|
||||
|
||||
if (kbc_at_ports[1] == NULL) {
|
||||
kbc_at_ports[1] = (kbc_at_port_t *) calloc(1, sizeof(kbc_at_port_t));
|
||||
kbc_at_ports[1]->out_new = -1;
|
||||
}
|
||||
|
||||
dev->port = kbc_at_ports[1];
|
||||
|
||||
timer_add(&dev->poll_timer, mouse_upc_poll, dev, 1);
|
||||
timer_add(&dev->dev_poll_timer, mouse_upc_dev_poll, dev, 1);
|
||||
|
||||
if (standalone) {
|
||||
mouse_upc_handler(1, 0x02d4, dev);
|
||||
dev->mouse_ps2 = device_add_params(&mouse_ps2_device, (void *) (uintptr_t) MOUSE_TYPE_PS2_QPORT);
|
||||
}
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
static void *
|
||||
mouse_upc_init(const device_t *info)
|
||||
{
|
||||
void *dev = NULL;
|
||||
|
||||
if (info->local == 1)
|
||||
dev = mouse_upc_init_common(1, device_get_config_int("irq"));
|
||||
else
|
||||
dev = mouse_upc_init_common(0, info->local);
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
static const device_config_t upc_config[] = {
|
||||
// clang-format off
|
||||
{
|
||||
.name = "irq",
|
||||
.description = "IRQ",
|
||||
.type = CONFIG_SELECTION,
|
||||
.default_string = NULL,
|
||||
.default_int = 12,
|
||||
.file_filter = NULL,
|
||||
.spinner = { 0 },
|
||||
.selection = {
|
||||
{ .description = "IRQ 12", .value = 12 },
|
||||
{ .description = "IRQ 2/9", .value = 2 },
|
||||
{ .description = "" }
|
||||
},
|
||||
.bios = { { 0 } }
|
||||
},
|
||||
{
|
||||
.name = "buttons",
|
||||
.description = "Buttons",
|
||||
.type = CONFIG_SELECTION,
|
||||
.default_string = NULL,
|
||||
.default_int = 2,
|
||||
.file_filter = NULL,
|
||||
.spinner = { 0 },
|
||||
.selection = {
|
||||
{ .description = "Two", .value = 2 },
|
||||
{ .description = "Three", .value = 3 },
|
||||
{ .description = "Wheel", .value = 4 },
|
||||
{ .description = "Five + Wheel", .value = 5 },
|
||||
{ .description = "Five + 2 Wheels", .value = 6 },
|
||||
{ .description = "" }
|
||||
},
|
||||
.bios = { { 0 } }
|
||||
},
|
||||
{
|
||||
.name = "", .description = "", .type = CONFIG_END
|
||||
}
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
const device_t mouse_upc_device = {
|
||||
.name = "PS/2 QuickPort Mouse (F82C710)",
|
||||
.internal_name = "mouse_upc",
|
||||
.flags = DEVICE_ISA,
|
||||
.local = 0,
|
||||
.init = mouse_upc_init,
|
||||
.close = mouse_upc_close,
|
||||
.reset = mouse_upc_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t mouse_upc_standalone_device = {
|
||||
.name = "PS/2 QuickPort Mouse",
|
||||
.internal_name = "mouse_upc_standalone",
|
||||
.flags = DEVICE_ISA,
|
||||
.local = 1,
|
||||
.init = mouse_upc_init,
|
||||
.close = mouse_upc_close,
|
||||
.reset = mouse_upc_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = upc_config
|
||||
};
|
||||
@@ -746,6 +746,14 @@ serial_read(uint16_t addr, void *priv)
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
serial_get_shadow(serial_t *dev)
|
||||
{
|
||||
uint8_t ret = dev->fcr;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
serial_remove(serial_t *dev)
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@ add_library(hdd OBJECT
|
||||
hdc_ide_w83769f.c
|
||||
)
|
||||
|
||||
add_library(zip OBJECT zip.c)
|
||||
add_library(rdisk OBJECT rdisk.c)
|
||||
|
||||
add_library(mo OBJECT mo.c)
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ static const struct {
|
||||
{ &xtide_device },
|
||||
{ &st506_xt_st11_m_device },
|
||||
{ &st506_xt_st11_r_device },
|
||||
{ &xta_st50x_device },
|
||||
{ &st506_xt_victor_v86p_device },
|
||||
{ &st506_xt_wd1002a_27x_device },
|
||||
{ &st506_xt_wd1002a_wx1_device },
|
||||
@@ -78,6 +79,8 @@ static const struct {
|
||||
{ &xtide_at_2ch_device },
|
||||
{ &xtide_at_ps2_device },
|
||||
{ &xtide_at_ps2_2ch_device },
|
||||
{ &ide_ter_device },
|
||||
{ &ide_qua_device },
|
||||
{ &st506_at_wd1003_device },
|
||||
{ &esdi_at_wd1007vse1_device },
|
||||
/* MCA */
|
||||
@@ -88,6 +91,9 @@ static const struct {
|
||||
{ &ide_vlb_device },
|
||||
{ &ide_vlb_2ch_device },
|
||||
/* PCI */
|
||||
{ &ide_cmd646_ter_qua_device },
|
||||
{ &ide_cmd648_ter_qua_device },
|
||||
{ &ide_cmd649_ter_qua_device },
|
||||
{ &ide_pci_device },
|
||||
{ &ide_pci_2ch_device },
|
||||
{ NULL }
|
||||
@@ -108,18 +114,14 @@ hdc_init(void)
|
||||
void
|
||||
hdc_reset(void)
|
||||
{
|
||||
hdc_log("HDC: reset(current=%d, internal=%d)\n",
|
||||
hdc_current[0], (machines[machine].flags & MACHINE_HDC) ? 1 : 0);
|
||||
for (int i = 0; i < HDC_MAX; i++) {
|
||||
hdc_log("HDC %i: reset(current=%d, internal=%d)\n", i,
|
||||
hdc_current[i], hdc_current[i] == HDC_INTERNAL);
|
||||
|
||||
/* If we have a valid controller, add its device. */
|
||||
if (hdc_current[0] > HDC_INTERNAL)
|
||||
device_add(controllers[hdc_current[0]].device);
|
||||
|
||||
/* Now, add the tertiary and/or quaternary IDE controllers. */
|
||||
if (ide_ter_enabled)
|
||||
device_add(&ide_ter_device);
|
||||
if (ide_qua_enabled)
|
||||
device_add(&ide_qua_device);
|
||||
/* If we have a valid controller, add its device. */
|
||||
if (hdc_current[i] > HDC_INTERNAL)
|
||||
device_add_inst(controllers[hdc_current[i]].device, i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
const char *
|
||||
@@ -129,7 +131,7 @@ hdc_get_internal_name(int hdc)
|
||||
}
|
||||
|
||||
int
|
||||
hdc_get_from_internal_name(char *s)
|
||||
hdc_get_from_internal_name(const char *s)
|
||||
{
|
||||
int c = 0;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#include <86box/hdc.h>
|
||||
#include <86box/hdc_ide.h>
|
||||
#include <86box/hdd.h>
|
||||
#include <86box/zip.h>
|
||||
#include <86box/rdisk.h>
|
||||
#include <86box/version.h>
|
||||
|
||||
/* Bits of 'atastat' */
|
||||
@@ -234,9 +234,7 @@ static uint8_t ide_qua_pnp_rom[] = {
|
||||
0x79, 0x00
|
||||
};
|
||||
|
||||
ide_t *ide_drives[IDE_NUM];
|
||||
int ide_ter_enabled = 0;
|
||||
int ide_qua_enabled = 0;
|
||||
ide_t *ide_drives[IDE_NUM] = { 0 };
|
||||
|
||||
static void ide_atapi_callback(ide_t *ide);
|
||||
static void ide_callback(void *priv);
|
||||
@@ -2828,20 +2826,23 @@ ide_board_close(int board)
|
||||
|
||||
ide_log("ide_board_close(%i)\n", board);
|
||||
|
||||
if ((ide_boards[board] == NULL) || !ide_boards[board]->inited)
|
||||
if (ide_boards[board] == NULL)
|
||||
return;
|
||||
|
||||
ide_log("IDE: Closing board %i...\n", board);
|
||||
|
||||
timer_stop(&ide_boards[board]->timer);
|
||||
if (ide_boards[board]->inited) {
|
||||
timer_stop(&ide_boards[board]->timer);
|
||||
|
||||
ide_clear_bus_master(board);
|
||||
ide_clear_bus_master(board);
|
||||
}
|
||||
|
||||
/* Close hard disk image files (if previously open) */
|
||||
for (uint8_t d = 0; d < 2; d++) {
|
||||
c = (board << 1) + d;
|
||||
|
||||
ide_boards[board]->ide[d] = NULL;
|
||||
if (ide_boards[board]->inited)
|
||||
ide_boards[board]->ide[d] = NULL;
|
||||
|
||||
dev = ide_drives[c];
|
||||
|
||||
@@ -3265,6 +3266,16 @@ ide_close(UNUSED(void *priv))
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ide_hard_reset(void)
|
||||
{
|
||||
for (int i = 0; i < IDE_BUS_MAX; i++)
|
||||
ide_boards[i] = NULL;
|
||||
|
||||
for (int i = 0; i < IDE_NUM; i++)
|
||||
ide_drives[i] = NULL;
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
mcide_mca_read(const int port, void *priv)
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include <86box/hdc.h>
|
||||
#include <86box/hdc_ide.h>
|
||||
#include <86box/hdc_ide_sff8038i.h>
|
||||
#include <86box/zip.h>
|
||||
#include <86box/rdisk.h>
|
||||
#include <86box/mo.h>
|
||||
|
||||
typedef struct cmd640_t {
|
||||
@@ -417,10 +417,10 @@ cmd640_reset(void *priv)
|
||||
(cdrom[i].ide_channel <= max_channel) && cdrom[i].priv)
|
||||
scsi_cdrom_reset((scsi_common_t *) cdrom[i].priv);
|
||||
}
|
||||
for (i = 0; i < ZIP_NUM; i++) {
|
||||
if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) && (zip_drives[i].ide_channel >= min_channel) &&
|
||||
(zip_drives[i].ide_channel <= max_channel) && zip_drives[i].priv)
|
||||
zip_reset((scsi_common_t *) zip_drives[i].priv);
|
||||
for (i = 0; i < RDISK_NUM; i++) {
|
||||
if ((rdisk_drives[i].bus_type == RDISK_BUS_ATAPI) && (rdisk_drives[i].ide_channel >= min_channel) &&
|
||||
(rdisk_drives[i].ide_channel <= max_channel) && rdisk_drives[i].priv)
|
||||
rdisk_reset((scsi_common_t *) rdisk_drives[i].priv);
|
||||
}
|
||||
for (i = 0; i < MO_NUM; i++) {
|
||||
if ((mo_drives[i].bus_type == MO_BUS_ATAPI) && (mo_drives[i].ide_channel >= min_channel) &&
|
||||
@@ -667,7 +667,7 @@ const device_t ide_cmd640_pci_legacy_only_device = {
|
||||
};
|
||||
|
||||
const device_t ide_cmd640_pci_single_channel_device = {
|
||||
.name = "CMD PCI-0640B PCI",
|
||||
.name = "CMD PCI-0640B PCI (Single Channel)",
|
||||
.internal_name = "ide_cmd640_pci_single_channel",
|
||||
.flags = DEVICE_PCI,
|
||||
.local = 0x2000a,
|
||||
@@ -681,7 +681,7 @@ const device_t ide_cmd640_pci_single_channel_device = {
|
||||
};
|
||||
|
||||
const device_t ide_cmd640_pci_single_channel_sec_device = {
|
||||
.name = "CMD PCI-0640B PCI",
|
||||
.name = "CMD PCI-0640B PCI (Single Channel, Secondary)",
|
||||
.internal_name = "ide_cmd640_pci_single_channel_sec",
|
||||
.flags = DEVICE_PCI,
|
||||
.local = 0x4000a,
|
||||
|
||||
@@ -34,8 +34,26 @@
|
||||
#include <86box/hdc.h>
|
||||
#include <86box/hdc_ide.h>
|
||||
#include <86box/hdc_ide_sff8038i.h>
|
||||
#include <86box/zip.h>
|
||||
#include <86box/rdisk.h>
|
||||
#include <86box/rom.h>
|
||||
#include <86box/hdd.h>
|
||||
#include <86box/scsi_disk.h>
|
||||
#include <86box/mo.h>
|
||||
#include "cpu.h"
|
||||
#include "x86.h"
|
||||
|
||||
#define CMD_TYPE_646 0x0000000
|
||||
#define CMD_TYPE_648 0x0100000
|
||||
#define CMD_TYPE_649 0x0200000
|
||||
|
||||
#define CMD648_JP7 0x0400000 /* Reload subsystem ID on reset. */
|
||||
#define CMD648_RAID 0x0800000
|
||||
|
||||
#define CMD64X_ONBOARD 0x1000000
|
||||
|
||||
#define CMD648_BIOS_FILE "roms/hdd/ide/648_1910.bin"
|
||||
#define CMD649_REV_1914_BIOS_FILE "roms/hdd/ide/649_1914.bin"
|
||||
#define CMD649_REV_2301_BIOS_FILE "roms/hdd/ide/649_2301.bin"
|
||||
|
||||
typedef struct cmd646_t {
|
||||
uint8_t vlb_idx;
|
||||
@@ -46,11 +64,17 @@ typedef struct cmd646_t {
|
||||
uint8_t regs[256];
|
||||
|
||||
uint32_t local;
|
||||
uint32_t rom_addr;
|
||||
uint32_t rom_addr_size;
|
||||
uint32_t rom_addr_mask;
|
||||
|
||||
int irq_pin;
|
||||
int has_bios;
|
||||
|
||||
int irq_mode[2];
|
||||
|
||||
rom_t bios_rom;
|
||||
|
||||
sff8038i_t *bm[2];
|
||||
} cmd646_t;
|
||||
|
||||
@@ -80,7 +104,8 @@ cmd646_set_irq_0(uint8_t status, void *priv)
|
||||
if (!(dev->regs[0x50] & 0x04) || (status & 0x04))
|
||||
dev->regs[0x50] = (dev->regs[0x50] & ~0x04) | status;
|
||||
|
||||
sff_bus_master_set_irq(status, dev->bm[0]);
|
||||
if (!(dev->local & CMD_TYPE_648) || !(dev->regs[0x71] & 0x10))
|
||||
sff_bus_master_set_irq(status, dev->bm[0]);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -91,7 +116,8 @@ cmd646_set_irq_1(uint8_t status, void *priv)
|
||||
if (!(dev->regs[0x57] & 0x10) || (status & 0x04))
|
||||
dev->regs[0x57] = (dev->regs[0x57] & ~0x10) | (status << 2);
|
||||
|
||||
sff_bus_master_set_irq(status, dev->bm[1]);
|
||||
if (!(dev->local & CMD_TYPE_648) || !(dev->regs[0x71] & 0x20))
|
||||
sff_bus_master_set_irq(status, dev->bm[1]);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -116,13 +142,24 @@ cmd646_ide_handlers(cmd646_t *dev)
|
||||
uint16_t main;
|
||||
uint16_t side;
|
||||
int irq_mode[2] = { IRQ_MODE_LEGACY, IRQ_MODE_LEGACY };
|
||||
int first = 0;
|
||||
int reg09 = dev->regs[0x09];
|
||||
int reg50 = dev->regs[0x50];
|
||||
|
||||
if ((dev->local & CMD_TYPE_648) && (dev->local & CMD648_RAID)) {
|
||||
reg09 = 0xff;
|
||||
reg50 |= 0x40;
|
||||
}
|
||||
|
||||
if (dev->local & 0x80000)
|
||||
first += 2;
|
||||
|
||||
sff_set_slot(dev->bm[0], dev->pci_slot);
|
||||
sff_set_slot(dev->bm[1], dev->pci_slot);
|
||||
|
||||
ide_pri_disable();
|
||||
ide_handlers(first, 0);
|
||||
|
||||
if ((dev->regs[0x09] & 0x01) && (dev->regs[0x50] & 0x40)) {
|
||||
if ((reg09 & 0x01) && (reg50 & 0x40)) {
|
||||
main = (dev->regs[0x11] << 8) | (dev->regs[0x10] & 0xf8);
|
||||
side = ((dev->regs[0x15] << 8) | (dev->regs[0x14] & 0xfc)) + 2;
|
||||
} else {
|
||||
@@ -130,23 +167,28 @@ cmd646_ide_handlers(cmd646_t *dev)
|
||||
side = 0x3f6;
|
||||
}
|
||||
|
||||
ide_set_base(0, main);
|
||||
ide_set_side(0, side);
|
||||
ide_set_base(first, main);
|
||||
ide_set_side(first, side);
|
||||
|
||||
if (dev->regs[0x09] & 0x01)
|
||||
if (reg09 & 0x01)
|
||||
irq_mode[0] = IRQ_MODE_PCI_IRQ_PIN;
|
||||
|
||||
sff_set_irq_mode(dev->bm[0], irq_mode[0]);
|
||||
cmd646_log("IDE %i: %04X, %04X, %i\n", first, main, side, irq_mode[0]);
|
||||
|
||||
if (dev->regs[0x04] & 0x01)
|
||||
ide_pri_enable();
|
||||
int pri_enabled = (dev->regs[0x04] & 0x01);
|
||||
if (dev->local & CMD_TYPE_648)
|
||||
pri_enabled = pri_enabled && (dev->regs[0x51] & 0x04);
|
||||
|
||||
if (pri_enabled)
|
||||
ide_handlers(first, 1);
|
||||
|
||||
if (dev->single_channel)
|
||||
return;
|
||||
|
||||
ide_sec_disable();
|
||||
ide_handlers(first + 1, 0);
|
||||
|
||||
if ((dev->regs[0x09] & 0x04) && (dev->regs[0x50] & 0x40)) {
|
||||
if ((reg09 & 0x04) && (reg50 & 0x40)) {
|
||||
main = (dev->regs[0x19] << 8) | (dev->regs[0x18] & 0xf8);
|
||||
side = ((dev->regs[0x1d] << 8) | (dev->regs[0x1c] & 0xfc)) + 2;
|
||||
} else {
|
||||
@@ -154,16 +196,17 @@ cmd646_ide_handlers(cmd646_t *dev)
|
||||
side = 0x376;
|
||||
}
|
||||
|
||||
ide_set_base(1, main);
|
||||
ide_set_side(1, side);
|
||||
ide_set_base(first + 1, main);
|
||||
ide_set_side(first + 1, side);
|
||||
|
||||
if (dev->regs[0x09] & 0x04)
|
||||
irq_mode[1] = 1;
|
||||
if (reg09 & 0x04)
|
||||
irq_mode[1] = IRQ_MODE_PCI_IRQ_PIN;
|
||||
|
||||
sff_set_irq_mode(dev->bm[1], irq_mode[1]);
|
||||
cmd646_log("IDE %i: %04X, %04X, %i\n", first + 1, main, side, irq_mode[1]);
|
||||
|
||||
if ((dev->regs[0x04] & 0x01) && (dev->regs[0x51] & 0x08))
|
||||
ide_sec_enable();
|
||||
ide_handlers(first + 1, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -175,74 +218,176 @@ cmd646_ide_bm_handlers(cmd646_t *dev)
|
||||
sff_bus_master_handler(dev->bm[1], (dev->regs[0x04] & 1), base + 8);
|
||||
}
|
||||
|
||||
uint8_t
|
||||
cmd646_bm_write(uint16_t port, uint8_t val, void *priv)
|
||||
{
|
||||
cmd646_t *dev = (cmd646_t *) priv;
|
||||
uint8_t ret = val;
|
||||
|
||||
switch (port & 0x000f) {
|
||||
case 0x0001:
|
||||
dev->regs[(port & 0x000f) | 0x70] = val & 0xf0;
|
||||
if (val & 0x04)
|
||||
dev->regs[0x50] &= ~0x04;
|
||||
if (val & 0x08)
|
||||
dev->regs[0x57] &= ~0x10;
|
||||
ret &= 0x03;
|
||||
break;
|
||||
case 0x0003:
|
||||
dev->regs[0x73] = val;
|
||||
break;
|
||||
case 0x0009:
|
||||
dev->regs[(port & 0x000f) | 0x70] = (dev->regs[(port & 0x000f) | 0x70] & 0x0f) | (val & 0xf0);
|
||||
ret &= 0x03;
|
||||
break;
|
||||
case 0x000b:
|
||||
dev->regs[0x7b] = val;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
cmd646_bm_read(uint16_t port, uint8_t val, void *priv)
|
||||
{
|
||||
cmd646_t *dev = (cmd646_t *) priv;
|
||||
uint8_t ret = val;
|
||||
|
||||
switch (port & 0x000f) {
|
||||
case 0x0001:
|
||||
ret = (dev->regs[(port & 0x000f) | 0x70] & 0xf3) | (dev->regs[0x50] & 0x04) | ((dev->regs[0x57] & 0x10) >> 1);
|
||||
break;
|
||||
case 0x0002: case 0x000a:
|
||||
ret |= 0x08;
|
||||
break;
|
||||
case 0x0003:
|
||||
ret = dev->regs[0x73];
|
||||
break;
|
||||
case 0x0009:
|
||||
ret = dev->regs[(port & 0x000f) | 0x70];
|
||||
break;
|
||||
case 0x000b:
|
||||
ret = dev->regs[0x7b];
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
cmd646_bios_handler(cmd646_t *dev)
|
||||
{
|
||||
if ((dev->local & CMD_TYPE_648) && dev->has_bios) {
|
||||
uint32_t *addr = (uint32_t *) &(dev->regs[0x30]);
|
||||
|
||||
*addr &= (~dev->rom_addr_mask) | 0x00000001;
|
||||
dev->rom_addr = *addr & 0xfffffff0;
|
||||
|
||||
cmd646_log("ROM address now: %08X\n", dev->rom_addr);
|
||||
|
||||
if ((dev->regs[0x04] & 0x02) && (*addr & 0x00000001))
|
||||
mem_mapping_set_addr(&dev->bios_rom.mapping, dev->rom_addr, dev->rom_addr_size);
|
||||
else
|
||||
mem_mapping_disable(&dev->bios_rom.mapping);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cmd646_pci_write(int func, int addr, uint8_t val, void *priv)
|
||||
{
|
||||
cmd646_t *dev = (cmd646_t *) priv;
|
||||
cmd646_t *dev = (cmd646_t *) priv;
|
||||
int reg50 = dev->regs[0x50];
|
||||
|
||||
if ((dev->local & CMD_TYPE_648) && (dev->regs[0x0a] == 0x04) && (dev->regs[0x0b] == 0x01))
|
||||
reg50 |= 0x40;
|
||||
|
||||
cmd646_log("[%04X:%08X] (%08X) cmd646_pci_write(%i, %02X, %02X)\n", CS, cpu_state.pc, ESI, func, addr, val);
|
||||
|
||||
if (func == 0x00)
|
||||
switch (addr) {
|
||||
case 0x04:
|
||||
dev->regs[addr] = (val & 0x45);
|
||||
if (dev->has_bios)
|
||||
dev->regs[addr] = (val & 0x47);
|
||||
else
|
||||
dev->regs[addr] = (val & 0x45);
|
||||
|
||||
cmd646_ide_handlers(dev);
|
||||
cmd646_ide_bm_handlers(dev);
|
||||
|
||||
cmd646_bios_handler(dev);
|
||||
break;
|
||||
case 0x05:
|
||||
if (dev->local & CMD_TYPE_648)
|
||||
dev->regs[addr] = (dev->regs[addr] & 0x7e) | (val & 0x01);
|
||||
break;
|
||||
case 0x07:
|
||||
dev->regs[addr] &= ~(val & 0xb1);
|
||||
if (dev->local & CMD_TYPE_648)
|
||||
dev->regs[addr] = ((dev->regs[addr] & ~(val & 0xb9)) & 0xbf) | (val & 0x40);
|
||||
else
|
||||
dev->regs[addr] &= ~(val & 0xb1);
|
||||
break;
|
||||
case 0x09:
|
||||
if ((dev->regs[addr] & 0x0a) == 0x0a) {
|
||||
dev->regs[addr] = (dev->regs[addr] & 0x0a) | (val & 0x05);
|
||||
dev->irq_mode[0] = !!(val & 0x01);
|
||||
dev->irq_mode[1] = !!(val & 0x04);
|
||||
if (!(dev->local & CMD_TYPE_648) ||
|
||||
((dev->regs[0x0a] == 0x01) && (dev->regs[0x0b] == 0x01))) {
|
||||
if ((dev->regs[addr] & 0x0a) == 0x0a) {
|
||||
dev->regs[addr] = (dev->regs[addr] & 0x8a) | (val & 0x05);
|
||||
dev->irq_mode[0] = !!(val & 0x01);
|
||||
dev->irq_mode[1] = !!(val & 0x04);
|
||||
cmd646_ide_handlers(dev);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0x0a: case 0x0b:
|
||||
if ((dev->local & CMD_TYPE_648) && (dev->regs[0x4f] & 0x04)) {
|
||||
dev->regs[addr] = val;
|
||||
cmd646_ide_handlers(dev);
|
||||
}
|
||||
break;
|
||||
case 0x10:
|
||||
if (dev->regs[0x50] & 0x40) {
|
||||
if (reg50 & 0x40) {
|
||||
dev->regs[0x10] = (val & 0xf8) | 1;
|
||||
cmd646_ide_handlers(dev);
|
||||
}
|
||||
break;
|
||||
case 0x11:
|
||||
if (dev->regs[0x50] & 0x40) {
|
||||
if (reg50 & 0x40) {
|
||||
dev->regs[0x11] = val;
|
||||
cmd646_ide_handlers(dev);
|
||||
}
|
||||
break;
|
||||
case 0x14:
|
||||
if (dev->regs[0x50] & 0x40) {
|
||||
if (reg50 & 0x40) {
|
||||
dev->regs[0x14] = (val & 0xfc) | 1;
|
||||
cmd646_ide_handlers(dev);
|
||||
}
|
||||
break;
|
||||
case 0x15:
|
||||
if (dev->regs[0x50] & 0x40) {
|
||||
if (reg50 & 0x40) {
|
||||
dev->regs[0x15] = val;
|
||||
cmd646_ide_handlers(dev);
|
||||
}
|
||||
break;
|
||||
case 0x18:
|
||||
if (dev->regs[0x50] & 0x40) {
|
||||
if (reg50 & 0x40) {
|
||||
dev->regs[0x18] = (val & 0xf8) | 1;
|
||||
cmd646_ide_handlers(dev);
|
||||
}
|
||||
break;
|
||||
case 0x19:
|
||||
if (dev->regs[0x50] & 0x40) {
|
||||
if (reg50 & 0x40) {
|
||||
dev->regs[0x19] = val;
|
||||
cmd646_ide_handlers(dev);
|
||||
}
|
||||
break;
|
||||
case 0x1c:
|
||||
if (dev->regs[0x50] & 0x40) {
|
||||
if (reg50 & 0x40) {
|
||||
dev->regs[0x1c] = (val & 0xfc) | 1;
|
||||
cmd646_ide_handlers(dev);
|
||||
}
|
||||
break;
|
||||
case 0x1d:
|
||||
if (dev->regs[0x50] & 0x40) {
|
||||
if (reg50 & 0x40) {
|
||||
dev->regs[0x1d] = val;
|
||||
cmd646_ide_handlers(dev);
|
||||
}
|
||||
@@ -255,18 +400,42 @@ cmd646_pci_write(int func, int addr, uint8_t val, void *priv)
|
||||
dev->regs[0x21] = val;
|
||||
cmd646_ide_bm_handlers(dev);
|
||||
break;
|
||||
case 0x2c ... 0x2f:
|
||||
case 0x8c ... 0x8f:
|
||||
if (dev->local & CMD_TYPE_648)
|
||||
dev->regs[(addr & 0x0f) | 0x20] = val;
|
||||
break;
|
||||
case 0x30 ... 0x33:
|
||||
if ((dev->local & CMD_TYPE_648) && dev->has_bios) {
|
||||
dev->regs[addr] = val;
|
||||
cmd646_bios_handler(dev);
|
||||
}
|
||||
break;
|
||||
case 0x3c:
|
||||
dev->regs[0x3c] = val;
|
||||
break;
|
||||
case 0x4f:
|
||||
if (dev->local & CMD_TYPE_648)
|
||||
dev->regs[addr] = (dev->regs[addr] & 0xfa) | (val & 0x05);
|
||||
break;
|
||||
case 0x51:
|
||||
dev->regs[addr] = val & 0xc8;
|
||||
if (dev->local & CMD_TYPE_648)
|
||||
dev->regs[addr] = val & 0xcc;
|
||||
else
|
||||
dev->regs[addr] = val & 0xc8;
|
||||
cmd646_ide_handlers(dev);
|
||||
break;
|
||||
case 0x52:
|
||||
case 0x54:
|
||||
case 0x56:
|
||||
case 0x58:
|
||||
case 0x59:
|
||||
case 0x5b:
|
||||
dev->regs[addr] = val;
|
||||
break;
|
||||
case 0x59:
|
||||
if ((dev->local & CMD_TYPE_649) || !(dev->local & CMD_TYPE_648))
|
||||
dev->regs[addr] = val;
|
||||
break;
|
||||
case 0x53:
|
||||
case 0x55:
|
||||
dev->regs[addr] = val & 0xc0;
|
||||
@@ -274,10 +443,32 @@ cmd646_pci_write(int func, int addr, uint8_t val, void *priv)
|
||||
case 0x57:
|
||||
dev->regs[addr] = (dev->regs[addr] & 0x10) | (val & 0xcc);
|
||||
break;
|
||||
case 0x70 ... 0x77:
|
||||
case 0x64:
|
||||
if (dev->local & CMD_TYPE_648)
|
||||
dev->regs[addr] = (dev->regs[addr] & 0xfc) | (val & 0x03);
|
||||
break;
|
||||
case 0x65:
|
||||
if (dev->local & CMD_TYPE_648)
|
||||
dev->regs[addr] = (dev->regs[addr] & 0x7f) | (val & 0x80);
|
||||
break;
|
||||
case 0x71:
|
||||
if (dev->local & CMD_TYPE_648)
|
||||
sff_bus_master_write(addr & 0x0f, val, dev->bm[0]);
|
||||
else
|
||||
sff_bus_master_write(addr & 0x0f, val & 0x03, dev->bm[0]);
|
||||
break;
|
||||
case 0x70:
|
||||
case 0x72 ... 0x77:
|
||||
sff_bus_master_write(addr & 0x0f, val, dev->bm[0]);
|
||||
break;
|
||||
case 0x78 ... 0x7f:
|
||||
case 0x79:
|
||||
if (dev->local & CMD_TYPE_648)
|
||||
sff_bus_master_write(addr & 0x0f, val, dev->bm[1]);
|
||||
else
|
||||
sff_bus_master_write(addr & 0x0f, val & 0x03, dev->bm[1]);
|
||||
break;
|
||||
case 0x78:
|
||||
case 0x7a ... 0x7f:
|
||||
sff_bus_master_write(addr & 0x0f, val, dev->bm[1]);
|
||||
break;
|
||||
|
||||
@@ -295,14 +486,18 @@ cmd646_pci_read(int func, int addr, void *priv)
|
||||
if (func == 0x00) {
|
||||
ret = dev->regs[addr];
|
||||
|
||||
if (addr == 0x50)
|
||||
if ((addr == 0x09) && (dev->local & CMD_TYPE_648) && (dev->regs[0x0a] == 0x04))
|
||||
ret = 0x00;
|
||||
else if (addr == 0x50)
|
||||
dev->regs[0x50] &= ~0x04;
|
||||
else if (addr == 0x57)
|
||||
dev->regs[0x57] &= ~0x10;
|
||||
else if ((addr >= 0x70) && (addr <= 0x77))
|
||||
ret = sff_bus_master_read(addr & 0x0f, dev->bm[0]);
|
||||
else if ((addr >= 0x78) && (addr <= 0x7f))
|
||||
ret = sff_bus_master_read(addr & 0x0f, dev->bm[0]);
|
||||
ret = sff_bus_master_read(addr & 0x0f, dev->bm[1]);
|
||||
else if ((dev->local & CMD_TYPE_648) && (addr >= 0x8c) && (addr <= 0x8f))
|
||||
ret = dev->regs[(addr & 0x0f) | 0x20];
|
||||
}
|
||||
|
||||
cmd646_log("[%04X:%08X] (%08X) cmd646_pci_read(%i, %02X, %02X)\n", CS, cpu_state.pc, ESI, func, addr, ret);
|
||||
@@ -310,22 +505,44 @@ cmd646_pci_read(int func, int addr, void *priv)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
check_ch(cmd646_t *dev, int channel)
|
||||
{
|
||||
int ret = 0;
|
||||
int min = 0;
|
||||
int max = dev->single_channel ? 1 : 3;
|
||||
|
||||
if (dev->local & 0x80000) {
|
||||
min += 4;
|
||||
max += 4;
|
||||
}
|
||||
|
||||
if ((channel >= min) && (channel <= max))
|
||||
ret = 1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
cmd646_reset(void *priv)
|
||||
{
|
||||
cmd646_t *dev = (cmd646_t *) priv;
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < HDD_NUM; i++) {
|
||||
if ((hdd[i].bus_type == HDD_BUS_ATAPI) && check_ch(dev, hdd[i].ide_channel) && hdd[i].priv)
|
||||
scsi_disk_reset((scsi_common_t *) hdd[i].priv);
|
||||
}
|
||||
for (i = 0; i < CDROM_NUM; i++) {
|
||||
if ((cdrom[i].bus_type == CDROM_BUS_ATAPI) && (cdrom[i].ide_channel < 4) && cdrom[i].priv)
|
||||
if ((cdrom[i].bus_type == CDROM_BUS_ATAPI) && check_ch(dev, cdrom[i].ide_channel) && cdrom[i].priv)
|
||||
scsi_cdrom_reset((scsi_common_t *) cdrom[i].priv);
|
||||
}
|
||||
for (i = 0; i < ZIP_NUM; i++) {
|
||||
if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) && (zip_drives[i].ide_channel < 4) && zip_drives[i].priv)
|
||||
zip_reset((scsi_common_t *) zip_drives[i].priv);
|
||||
for (i = 0; i < RDISK_NUM; i++) {
|
||||
if ((rdisk_drives[i].bus_type == RDISK_BUS_ATAPI) && check_ch(dev, rdisk_drives[i].ide_channel) && rdisk_drives[i].priv)
|
||||
rdisk_reset((scsi_common_t *) rdisk_drives[i].priv);
|
||||
}
|
||||
for (i = 0; i < MO_NUM; i++) {
|
||||
if ((mo_drives[i].bus_type == MO_BUS_ATAPI) && (mo_drives[i].ide_channel < 4) && mo_drives[i].priv)
|
||||
if ((mo_drives[i].bus_type == MO_BUS_ATAPI) && check_ch(dev, mo_drives[i].ide_channel) && mo_drives[i].priv)
|
||||
mo_reset((scsi_common_t *) mo_drives[i].priv);
|
||||
}
|
||||
|
||||
@@ -336,16 +553,40 @@ cmd646_reset(void *priv)
|
||||
|
||||
dev->regs[0x00] = 0x95; /* CMD */
|
||||
dev->regs[0x01] = 0x10;
|
||||
dev->regs[0x02] = 0x46; /* PCI-0646 */
|
||||
if (dev->local & CMD_TYPE_649)
|
||||
dev->regs[0x02] = 0x49; /* PCI-0649 */
|
||||
else if (dev->local & CMD_TYPE_648)
|
||||
dev->regs[0x02] = 0x48; /* PCI-0648 */
|
||||
else
|
||||
dev->regs[0x02] = 0x46; /* PCI-0646 */
|
||||
dev->regs[0x03] = 0x06;
|
||||
dev->regs[0x04] = 0x00;
|
||||
dev->regs[0x06] = 0x80;
|
||||
dev->regs[0x07] = 0x02; /* DEVSEL timing: 01 medium */
|
||||
dev->regs[0x09] = dev->local; /* Programming interface */
|
||||
dev->regs[0x0a] = 0x01; /* IDE controller */
|
||||
if ((dev->local & CMD_TYPE_648) && (dev->local & CMD648_RAID)) {
|
||||
dev->regs[0x06] = 0x90;
|
||||
dev->regs[0x08] = 0x02;
|
||||
dev->regs[0x0a] = 0x04; /* RAID controller */
|
||||
|
||||
dev->regs[0x50] = 0x40; /* Enable Base address register R/W;
|
||||
If 0, they return 0 and are read-only 8 */
|
||||
|
||||
/* Blank base addresses */
|
||||
dev->regs[0x10] = 0x01;
|
||||
dev->regs[0x14] = 0x01;
|
||||
dev->regs[0x18] = 0x01;
|
||||
dev->regs[0x1c] = 0x01;
|
||||
} else {
|
||||
dev->regs[0x06] = 0x80;
|
||||
dev->regs[0x0a] = 0x01; /* IDE controller */
|
||||
}
|
||||
dev->regs[0x0b] = 0x01; /* Mass storage controller */
|
||||
|
||||
if ((dev->local & 0xffff) == 0x8a) {
|
||||
if ((dev->local & CMD_TYPE_648) && (dev->local & CMD648_JP7))
|
||||
for (int i = 0; i < 4; i++)
|
||||
dev->regs[0x2c + i] = dev->regs[i];
|
||||
|
||||
if ((dev->regs[0x0a] == 0x01) && ((dev->regs[0x09] & 0x8a) == 0x8a)) {
|
||||
dev->regs[0x50] = 0x40; /* Enable Base address register R/W;
|
||||
If 0, they return 0 and are read-only 8 */
|
||||
|
||||
@@ -371,13 +612,47 @@ cmd646_reset(void *priv)
|
||||
dev->regs[0x51] = 0x08;
|
||||
|
||||
dev->regs[0x57] = 0x0c;
|
||||
dev->regs[0x59] = 0x40;
|
||||
|
||||
dev->irq_mode[0] = dev->irq_mode[1] = 0;
|
||||
if (dev->local & CMD_TYPE_648) {
|
||||
dev->regs[0x34] = 0x60;
|
||||
|
||||
dev->regs[0x4f] = (dev->local & CMD648_JP7) ? 0x02 : 0x00;
|
||||
dev->regs[0x51] |= 0x04;
|
||||
|
||||
if (dev->local & CMD_TYPE_649) {
|
||||
dev->regs[0x57] |= 0x80;
|
||||
dev->regs[0x59] = 0x40;
|
||||
} else
|
||||
dev->regs[0x57] |= 0xc0;
|
||||
|
||||
dev->regs[0x60] = 0x01;
|
||||
dev->regs[0x62] = 0x21;
|
||||
dev->regs[0x63] = 0x06;
|
||||
dev->regs[0x65] = 0x60;
|
||||
dev->regs[0x67] = 0xf0;
|
||||
|
||||
/* 80-pin stuff. */
|
||||
dev->regs[0x72] = 0x08;
|
||||
dev->regs[0x7a] = 0x08;
|
||||
dev->regs[0x79] = 0x83;
|
||||
} else
|
||||
dev->regs[0x59] = 0x40;
|
||||
|
||||
dev->irq_pin = PCI_INTA;
|
||||
|
||||
if ((dev->local & CMD_TYPE_648) && (dev->local & CMD648_RAID))
|
||||
dev->irq_mode[0] = dev->irq_mode[1] = IRQ_MODE_PCI_IRQ_PIN;
|
||||
else {
|
||||
dev->irq_mode[0] = (dev->regs[0x09] & 0x01) ? IRQ_MODE_PCI_IRQ_PIN : IRQ_MODE_LEGACY;
|
||||
dev->irq_mode[1] = (dev->regs[0x09] & 0x04) ? IRQ_MODE_PCI_IRQ_PIN : IRQ_MODE_LEGACY;
|
||||
}
|
||||
|
||||
dev->irq_pin = PCI_INTA;
|
||||
|
||||
cmd646_ide_handlers(dev);
|
||||
cmd646_ide_bm_handlers(dev);
|
||||
|
||||
cmd646_bios_handler(dev);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -391,42 +666,147 @@ cmd646_close(void *priv)
|
||||
static void *
|
||||
cmd646_init(const device_t *info)
|
||||
{
|
||||
cmd646_t *dev = (cmd646_t *) calloc(1, sizeof(cmd646_t));
|
||||
cmd646_t *dev = (cmd646_t *) calloc(1, sizeof(cmd646_t));
|
||||
int first = 0;
|
||||
|
||||
dev->local = info->local;
|
||||
|
||||
device_add(&ide_pci_2ch_device);
|
||||
|
||||
if (info->local & 0x80000)
|
||||
pci_add_card(PCI_ADD_NORMAL, cmd646_pci_read, cmd646_pci_write, dev, &dev->pci_slot);
|
||||
else
|
||||
if (info->local & 0x80000) {
|
||||
first = 2;
|
||||
device_add(&ide_pci_ter_qua_2ch_device);
|
||||
} else
|
||||
device_add(&ide_pci_2ch_device);
|
||||
|
||||
if (info->local & CMD64X_ONBOARD)
|
||||
pci_add_card(PCI_ADD_IDE, cmd646_pci_read, cmd646_pci_write, dev, &dev->pci_slot);
|
||||
else
|
||||
pci_add_card(PCI_ADD_NORMAL, cmd646_pci_read, cmd646_pci_write, dev, &dev->pci_slot);
|
||||
|
||||
dev->single_channel = !!(info->local & 0x20000);
|
||||
|
||||
dev->bm[0] = device_add_inst(&sff8038i_device, 1);
|
||||
dev->bm[0] = device_add_inst(&sff8038i_device, first + 1);
|
||||
if (!dev->single_channel)
|
||||
dev->bm[1] = device_add_inst(&sff8038i_device, 2);
|
||||
dev->bm[1] = device_add_inst(&sff8038i_device, first + 2);
|
||||
|
||||
ide_set_bus_master(0, cmd646_bus_master_dma_0, cmd646_set_irq_0, dev);
|
||||
ide_set_bus_master(first, cmd646_bus_master_dma_0, cmd646_set_irq_0, dev);
|
||||
if (!dev->single_channel)
|
||||
ide_set_bus_master(1, cmd646_bus_master_dma_1, cmd646_set_irq_1, dev);
|
||||
ide_set_bus_master(first + 1, cmd646_bus_master_dma_1, cmd646_set_irq_1, dev);
|
||||
|
||||
sff_set_irq_mode(dev->bm[0], IRQ_MODE_LEGACY);
|
||||
|
||||
if (!dev->single_channel)
|
||||
sff_set_irq_mode(dev->bm[1], IRQ_MODE_LEGACY);
|
||||
|
||||
sff_set_slot(dev->bm[0], dev->pci_slot);
|
||||
sff_set_slot(dev->bm[1], dev->pci_slot);
|
||||
|
||||
if (dev->local & CMD_TYPE_648) {
|
||||
sff_set_ven_handlers(dev->bm[0], cmd646_bm_write, cmd646_bm_read, dev);
|
||||
sff_set_ven_handlers(dev->bm[1], cmd646_bm_write, cmd646_bm_read, dev);
|
||||
|
||||
dev->has_bios = device_get_config_int("bios");
|
||||
|
||||
if (dev->has_bios) {
|
||||
char *fn = NULL;
|
||||
|
||||
if (dev->local & CMD_TYPE_649) {
|
||||
const char *bios_rev = (char *) device_get_config_bios("bios_rev");
|
||||
fn = (char *) device_get_bios_file(info, bios_rev, 0);
|
||||
|
||||
dev->rom_addr_size = device_get_bios_file_size(info, bios_rev);
|
||||
} else {
|
||||
fn = CMD648_BIOS_FILE;
|
||||
|
||||
dev->rom_addr_size = 0x00004000;
|
||||
}
|
||||
|
||||
dev->rom_addr_mask = dev->rom_addr_size - 1;
|
||||
|
||||
rom_init(&dev->bios_rom, fn,
|
||||
0x000d0000, dev->rom_addr_size, dev->rom_addr_mask, 0, MEM_MAPPING_EXTERNAL);
|
||||
|
||||
mem_mapping_disable(&dev->bios_rom.mapping);
|
||||
}
|
||||
}
|
||||
|
||||
cmd646_reset(dev);
|
||||
|
||||
if (dev->local & CMD_TYPE_648)
|
||||
for (int i = 0; i < 4; i++)
|
||||
dev->regs[0x2c + i] = dev->regs[i];
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
static const device_config_t cmd648_config[] = {
|
||||
{
|
||||
.name = "bios",
|
||||
.description = "Enable BIOS",
|
||||
.type = CONFIG_BINARY,
|
||||
.default_string = NULL,
|
||||
.default_int = 0,
|
||||
.file_filter = NULL,
|
||||
.spinner = { 0 },
|
||||
.selection = { { 0 } },
|
||||
.bios = { { 0 } }
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
static const device_config_t cmd649_config[] = {
|
||||
{
|
||||
.name = "bios",
|
||||
.description = "Enable BIOS",
|
||||
.type = CONFIG_BINARY,
|
||||
.default_string = NULL,
|
||||
.default_int = 0,
|
||||
.file_filter = NULL,
|
||||
.spinner = { 0 },
|
||||
.selection = { { 0 } },
|
||||
.bios = { { 0 } }
|
||||
},
|
||||
{
|
||||
.name = "bios_rev",
|
||||
.description = "BIOS Revision",
|
||||
.type = CONFIG_BIOS,
|
||||
.default_string = "rev_2301",
|
||||
.default_int = 0,
|
||||
.file_filter = NULL,
|
||||
.spinner = { 0 },
|
||||
.bios = {
|
||||
{
|
||||
.name = "Revision 1.9.14",
|
||||
.internal_name = "rev_1914",
|
||||
.bios_type = BIOS_NORMAL,
|
||||
.files_no = 1,
|
||||
.local = 0,
|
||||
.size = 16384,
|
||||
.files = { CMD649_REV_2301_BIOS_FILE, "" }
|
||||
},
|
||||
{
|
||||
.name = "Revision 2.3.01",
|
||||
.internal_name = "rev_2301",
|
||||
.bios_type = BIOS_NORMAL,
|
||||
.files_no = 1,
|
||||
.local = 0,
|
||||
.size = 65536,
|
||||
.files = { CMD649_REV_2301_BIOS_FILE, "" }
|
||||
},
|
||||
{ .files_no = 0 }
|
||||
},
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
const device_t ide_cmd646_device = {
|
||||
.name = "CMD PCI-0646",
|
||||
.internal_name = "ide_cmd646",
|
||||
.flags = DEVICE_PCI,
|
||||
.local = 0x8a,
|
||||
.local = 0x000008a | CMD64X_ONBOARD,
|
||||
.init = cmd646_init,
|
||||
.close = cmd646_close,
|
||||
.reset = cmd646_reset,
|
||||
@@ -440,7 +820,7 @@ const device_t ide_cmd646_legacy_only_device = {
|
||||
.name = "CMD PCI-0646 (Legacy Mode Only)",
|
||||
.internal_name = "ide_cmd646_legacy_only",
|
||||
.flags = DEVICE_PCI,
|
||||
.local = 0x80,
|
||||
.local = 0x0000080 | CMD64X_ONBOARD,
|
||||
.init = cmd646_init,
|
||||
.close = cmd646_close,
|
||||
.reset = cmd646_reset,
|
||||
@@ -451,10 +831,10 @@ const device_t ide_cmd646_legacy_only_device = {
|
||||
};
|
||||
|
||||
const device_t ide_cmd646_single_channel_device = {
|
||||
.name = "CMD PCI-0646",
|
||||
.name = "CMD PCI-0646 (Single Channel)",
|
||||
.internal_name = "ide_cmd646_single_channel",
|
||||
.flags = DEVICE_PCI,
|
||||
.local = 0x2008a,
|
||||
.local = 0x002008a | CMD64X_ONBOARD,
|
||||
.init = cmd646_init,
|
||||
.close = cmd646_close,
|
||||
.reset = cmd646_reset,
|
||||
@@ -463,3 +843,59 @@ const device_t ide_cmd646_single_channel_device = {
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t ide_cmd646_ter_qua_device = {
|
||||
.name = "CMD PCI-0646 (Tertiary and Quaternary)",
|
||||
.internal_name = "ide_cmd646_ter_qua",
|
||||
.flags = DEVICE_PCI,
|
||||
.local = 0x008008f,
|
||||
.init = cmd646_init,
|
||||
.close = cmd646_close,
|
||||
.reset = cmd646_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t ide_cmd648_ter_qua_device = {
|
||||
.name = "CMD PCI-0648 (Tertiary and Quaternary)",
|
||||
.internal_name = "ide_cmd648_ter_qua",
|
||||
.flags = DEVICE_PCI,
|
||||
.local = 0x0d8008f,
|
||||
.init = cmd646_init,
|
||||
.close = cmd646_close,
|
||||
.reset = cmd646_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = cmd648_config
|
||||
};
|
||||
|
||||
const device_t ide_cmd648_ter_qua_onboard_device = {
|
||||
.name = "CMD PCI-0648 (Tertiary and Quaternary) On-Board",
|
||||
.internal_name = "ide_cmd648_ter_qua_onboard",
|
||||
.flags = DEVICE_PCI,
|
||||
.local = 0x0d8008f | CMD64X_ONBOARD,
|
||||
.init = cmd646_init,
|
||||
.close = cmd646_close,
|
||||
.reset = cmd646_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t ide_cmd649_ter_qua_device = {
|
||||
.name = "CMD PCI-0649 (Tertiary and Quaternary)",
|
||||
.internal_name = "ide_cmd649_ter_qua",
|
||||
.flags = DEVICE_PCI,
|
||||
.local = 0x0f8008f,
|
||||
.init = cmd646_init,
|
||||
.close = cmd646_close,
|
||||
.reset = cmd646_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = cmd649_config
|
||||
};
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include <86box/hdc.h>
|
||||
#include <86box/hdc_ide.h>
|
||||
#include <86box/hdc_ide_sff8038i.h>
|
||||
#include <86box/zip.h>
|
||||
#include <86box/rdisk.h>
|
||||
#include <86box/mo.h>
|
||||
|
||||
typedef struct rz1000_t {
|
||||
@@ -182,10 +182,10 @@ rz1000_reset(void *priv)
|
||||
(cdrom[i].ide_channel <= max_channel) && cdrom[i].priv)
|
||||
scsi_cdrom_reset((scsi_common_t *) cdrom[i].priv);
|
||||
}
|
||||
for (i = 0; i < ZIP_NUM; i++) {
|
||||
if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) && (zip_drives[i].ide_channel >= min_channel) &&
|
||||
(zip_drives[i].ide_channel <= max_channel) && zip_drives[i].priv)
|
||||
zip_reset((scsi_common_t *) zip_drives[i].priv);
|
||||
for (i = 0; i < RDISK_NUM; i++) {
|
||||
if ((rdisk_drives[i].bus_type == RDISK_BUS_ATAPI) && (rdisk_drives[i].ide_channel >= min_channel) &&
|
||||
(rdisk_drives[i].ide_channel <= max_channel) && rdisk_drives[i].priv)
|
||||
rdisk_reset((scsi_common_t *) rdisk_drives[i].priv);
|
||||
}
|
||||
for (i = 0; i < MO_NUM; i++) {
|
||||
if ((mo_drives[i].bus_type == MO_BUS_ATAPI) && (mo_drives[i].ide_channel >= min_channel) &&
|
||||
@@ -275,7 +275,7 @@ const device_t ide_rz1000_pci_device = {
|
||||
};
|
||||
|
||||
const device_t ide_rz1000_pci_single_channel_device = {
|
||||
.name = "PC Technology RZ-1000 PCI",
|
||||
.name = "PC Technology RZ-1000 PCI (Single Channel)",
|
||||
.internal_name = "ide_rz1000_pci_single_channel",
|
||||
.flags = DEVICE_PCI,
|
||||
.local = 0x20000,
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#include <86box/hdc.h>
|
||||
#include <86box/hdc_ide.h>
|
||||
#include <86box/hdc_ide_sff8038i.h>
|
||||
#include <86box/zip.h>
|
||||
#include <86box/rdisk.h>
|
||||
#include <86box/mo.h>
|
||||
#include <86box/plat_unused.h>
|
||||
|
||||
@@ -118,6 +118,9 @@ sff_bus_master_write(uint16_t port, uint8_t val, void *priv)
|
||||
|
||||
sff_log("SFF-8038i Bus master BYTE write: %04X %02X\n", port, val);
|
||||
|
||||
if (dev->ven_write != NULL)
|
||||
val = dev->ven_write(port, val, dev->priv);
|
||||
|
||||
switch (port & 7) {
|
||||
case 0:
|
||||
sff_log("sff Cmd : val = %02X, old = %02X\n", val, dev->command);
|
||||
@@ -255,6 +258,9 @@ sff_bus_master_read(uint16_t port, void *priv)
|
||||
break;
|
||||
}
|
||||
|
||||
if (dev->ven_read != NULL)
|
||||
ret= dev->ven_read(port, ret, dev->priv);
|
||||
|
||||
sff_log("SFF-8038i Bus master BYTE read : %04X %02X\n", port, ret);
|
||||
|
||||
return ret;
|
||||
@@ -489,10 +495,10 @@ sff_reset(void *priv)
|
||||
cdrom[i].priv)
|
||||
scsi_cdrom_reset((scsi_common_t *) cdrom[i].priv);
|
||||
}
|
||||
for (uint8_t i = 0; i < ZIP_NUM; i++) {
|
||||
if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) && (zip_drives[i].ide_channel < 4) &&
|
||||
zip_drives[i].priv)
|
||||
zip_reset((scsi_common_t *) zip_drives[i].priv);
|
||||
for (uint8_t i = 0; i < RDISK_NUM; i++) {
|
||||
if ((rdisk_drives[i].bus_type == RDISK_BUS_ATAPI) && (rdisk_drives[i].ide_channel < 4) &&
|
||||
rdisk_drives[i].priv)
|
||||
rdisk_reset((scsi_common_t *) rdisk_drives[i].priv);
|
||||
}
|
||||
for (uint8_t i = 0; i < MO_NUM; i++) {
|
||||
if ((mo_drives[i].bus_type == MO_BUS_ATAPI) && (mo_drives[i].ide_channel < 4) &&
|
||||
@@ -569,6 +575,16 @@ sff_set_mirq(sff8038i_t *dev, uint8_t mirq)
|
||||
dev->mirq = mirq;
|
||||
}
|
||||
|
||||
void
|
||||
sff_set_ven_handlers(sff8038i_t *dev, uint8_t (*ven_write)(uint16_t port, uint8_t val, void *priv),
|
||||
uint8_t (*ven_read)(uint16_t port, uint8_t val, void *priv), void *priv)
|
||||
{
|
||||
dev->ven_write = ven_write;
|
||||
dev->ven_read = ven_read;
|
||||
|
||||
dev->priv = priv;
|
||||
}
|
||||
|
||||
static void
|
||||
sff_close(void *priv)
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include <86box/hdc.h>
|
||||
#include <86box/hdc_ide.h>
|
||||
#include <86box/hdc_ide_sff8038i.h>
|
||||
#include <86box/zip.h>
|
||||
#include <86box/rdisk.h>
|
||||
#include <86box/mo.h>
|
||||
|
||||
typedef struct w83769f_t {
|
||||
@@ -297,10 +297,10 @@ w83769f_reset(void *priv)
|
||||
(cdrom[i].ide_channel <= max_channel) && cdrom[i].priv)
|
||||
scsi_cdrom_reset((scsi_common_t *) cdrom[i].priv);
|
||||
}
|
||||
for (i = 0; i < ZIP_NUM; i++) {
|
||||
if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) && (zip_drives[i].ide_channel >= min_channel) &&
|
||||
(zip_drives[i].ide_channel <= max_channel) && zip_drives[i].priv)
|
||||
zip_reset((scsi_common_t *) zip_drives[i].priv);
|
||||
for (i = 0; i < RDISK_NUM; i++) {
|
||||
if ((rdisk_drives[i].bus_type == RDISK_BUS_ATAPI) && (rdisk_drives[i].ide_channel >= min_channel) &&
|
||||
(rdisk_drives[i].ide_channel <= max_channel) && rdisk_drives[i].priv)
|
||||
rdisk_reset((scsi_common_t *) rdisk_drives[i].priv);
|
||||
}
|
||||
for (i = 0; i < MO_NUM; i++) {
|
||||
if ((mo_drives[i].bus_type == MO_BUS_ATAPI) && (mo_drives[i].ide_channel >= min_channel) &&
|
||||
|
||||
@@ -1915,7 +1915,7 @@ victor_v86p_available(void)
|
||||
static const device_config_t dtc_config[] = {
|
||||
{
|
||||
.name = "bios_addr",
|
||||
.description = "BIOS Address",
|
||||
.description = "BIOS address",
|
||||
.type = CONFIG_HEX20,
|
||||
.default_string = NULL,
|
||||
.default_int = 0xc8000,
|
||||
@@ -1969,7 +1969,7 @@ static const device_config_t st11_config[] = {
|
||||
},
|
||||
{
|
||||
.name = "bios_addr",
|
||||
.description = "BIOS Address",
|
||||
.description = "BIOS address",
|
||||
.type = CONFIG_HEX20,
|
||||
.default_string = NULL,
|
||||
.default_int = 0xc8000,
|
||||
@@ -2006,7 +2006,7 @@ static const device_config_t st11_config[] = {
|
||||
static const device_config_t wd_config[] = {
|
||||
{
|
||||
.name = "bios_addr",
|
||||
.description = "BIOS Address",
|
||||
.description = "BIOS address",
|
||||
.type = CONFIG_HEX20,
|
||||
.default_string = NULL,
|
||||
.default_int = 0xc8000,
|
||||
@@ -2089,7 +2089,7 @@ static const device_config_t wd_nobios_config[] = {
|
||||
static const device_config_t wd_rll_config[] = {
|
||||
{
|
||||
.name = "bios_addr",
|
||||
.description = "BIOS Address",
|
||||
.description = "BIOS address",
|
||||
.type = CONFIG_HEX20,
|
||||
.default_string = NULL,
|
||||
.default_int = 0xc8000,
|
||||
@@ -2153,7 +2153,7 @@ static const device_config_t wd_rll_config[] = {
|
||||
static const device_config_t wd1004a_config[] = {
|
||||
{
|
||||
.name = "bios_addr",
|
||||
.description = "BIOS Address",
|
||||
.description = "BIOS address",
|
||||
.type = CONFIG_HEX20,
|
||||
.default_string = NULL,
|
||||
.default_int = 0xc8000,
|
||||
@@ -2202,7 +2202,7 @@ static const device_config_t wd1004a_config[] = {
|
||||
static const device_config_t wd1004_rll_config[] = {
|
||||
{
|
||||
.name = "bios_addr",
|
||||
.description = "BIOS Address",
|
||||
.description = "BIOS address",
|
||||
.type = CONFIG_HEX20,
|
||||
.default_string = NULL,
|
||||
.default_int = 0xc8000,
|
||||
|
||||
@@ -82,6 +82,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <inttypes.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
@@ -101,11 +102,14 @@
|
||||
#include <86box/ui.h>
|
||||
#include <86box/hdc.h>
|
||||
#include <86box/hdd.h>
|
||||
#include "cpu.h"
|
||||
|
||||
#define HDC_TIME (250 * TIMER_USEC)
|
||||
|
||||
#define WD_REV_1_BIOS_FILE "roms/hdd/xta/idexywd2.bin"
|
||||
#define WD_REV_2_BIOS_FILE "roms/hdd/xta/infowdbios.rom"
|
||||
#define ST50X_BIOS_FILE "roms/hdd/xta/ST05XBIO.BIN"
|
||||
#define PC5086_BIOS_FILE "roms/machines/pc5086/c800.bin"
|
||||
|
||||
enum {
|
||||
STATE_IDLE = 0,
|
||||
@@ -236,6 +240,7 @@ typedef struct hdc_t {
|
||||
const char *name; /* controller name */
|
||||
|
||||
uint16_t base; /* controller base I/O address */
|
||||
uint8_t sw; /* controller switches */
|
||||
int8_t irq; /* controller IRQ channel */
|
||||
int8_t dma; /* controller DMA channel */
|
||||
int8_t type; /* controller type ID */
|
||||
@@ -269,6 +274,10 @@ typedef struct hdc_t {
|
||||
uint8_t sector_buf[512]; /* sector buffer */
|
||||
} hdc_t;
|
||||
|
||||
typedef struct hdc_dual_t {
|
||||
hdc_t *hdc[2];
|
||||
} hdc_dual_t;
|
||||
|
||||
#ifdef ENABLE_XTA_LOG
|
||||
int xta_do_log = ENABLE_XTA_LOG;
|
||||
|
||||
@@ -882,7 +891,7 @@ hdc_read(uint16_t port, void *priv)
|
||||
hdc_t *dev = (hdc_t *) priv;
|
||||
uint8_t ret = 0xff;
|
||||
|
||||
switch (port & 7) {
|
||||
switch (port & 3) {
|
||||
case 0: /* DATA register */
|
||||
dev->status &= ~STAT_IRQ;
|
||||
|
||||
@@ -915,7 +924,7 @@ hdc_read(uint16_t port, void *priv)
|
||||
break;
|
||||
|
||||
case 2: /* "read option jumpers" */
|
||||
ret = 0xff; /* all switches off */
|
||||
ret = dev->sw;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -931,7 +940,7 @@ hdc_write(uint16_t port, uint8_t val, void *priv)
|
||||
{
|
||||
hdc_t *dev = (hdc_t *) priv;
|
||||
|
||||
switch (port & 7) {
|
||||
switch (port & 3) {
|
||||
case 0: /* DATA register */
|
||||
if (dev->state == STATE_RDATA) {
|
||||
if (!(dev->status & STAT_REQ)) {
|
||||
@@ -989,38 +998,85 @@ hdc_write(uint16_t port, uint8_t val, void *priv)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
xta_handler(void *priv, int set)
|
||||
{
|
||||
hdc_t *dev = (hdc_t *) priv;
|
||||
|
||||
io_handler(set, dev->base, 4,
|
||||
hdc_read, NULL, NULL, hdc_write, NULL, NULL, dev);
|
||||
}
|
||||
|
||||
static void *
|
||||
xta_init(const device_t *info)
|
||||
xta_init_common(const device_t *info, int type)
|
||||
{
|
||||
drive_t *drive;
|
||||
const char *bios_rev = NULL;
|
||||
const char *fn = NULL;
|
||||
hdc_t *dev;
|
||||
int c;
|
||||
int max = XTA_NUM;
|
||||
int min = 0;
|
||||
int max = XTA_NUM;
|
||||
|
||||
/* Allocate and initialize device block. */
|
||||
dev = calloc(1, sizeof(hdc_t));
|
||||
dev->type = info->local;
|
||||
|
||||
dev->sw = 0xff; /* all switches off */
|
||||
dev->type = type;
|
||||
|
||||
/* Do per-controller-type setup. */
|
||||
switch (dev->type) {
|
||||
case 0: /* WDXT-150, with BIOS */
|
||||
dev->name = "WDXT-150";
|
||||
bios_rev = (char *) device_get_config_bios("bios_rev");
|
||||
fn = (char *) device_get_bios_file(info, bios_rev, 0);
|
||||
/* Revision 2 actually supports 2 drives using drive select. */
|
||||
if (!strcmp(bios_rev, "rev_1"))
|
||||
max = 1;
|
||||
#ifdef SELECTABLE_BASE
|
||||
dev->base = device_get_config_hex16("base");
|
||||
#else
|
||||
dev->base = 0x0320;
|
||||
#endif
|
||||
dev->irq = device_get_config_int("irq");
|
||||
dev->rom_addr = device_get_config_hex20("bios_addr");
|
||||
dev->dma = 3;
|
||||
bios_rev = (char *) device_get_config_bios("bios_rev");
|
||||
fn = (char *) device_get_bios_file(info, bios_rev, 0);
|
||||
max = 1;
|
||||
break;
|
||||
|
||||
case 1: /* EuroPC */
|
||||
dev->name = "HD20";
|
||||
dev->base = 0x0320;
|
||||
dev->irq = 5;
|
||||
dev->dma = 3;
|
||||
case 3: /* Amstrad PC5086 */
|
||||
switch (dev->type) {
|
||||
case 1:
|
||||
dev->name = "HD20";
|
||||
break;
|
||||
case 3:
|
||||
dev->name = "ST-50X PC5086";
|
||||
dev->rom_addr = 0xc8000;
|
||||
fn = PC5086_BIOS_FILE;
|
||||
max = 1;
|
||||
break;
|
||||
}
|
||||
dev->base = 0x0320;
|
||||
dev->irq = 5;
|
||||
dev->dma = 3;
|
||||
break;
|
||||
case 2: /* Seagate ST-05X Standalone */
|
||||
case 4: /* Seagate ST-05X Standalone secondary device */
|
||||
switch (dev->type) {
|
||||
case 2:
|
||||
dev->name = "ST-50X PRI";
|
||||
dev->rom_addr = device_get_config_hex20("bios_addr");
|
||||
fn = ST50X_BIOS_FILE;
|
||||
max = 1;
|
||||
break;
|
||||
case 4:
|
||||
dev->name = "ST-50X SEC";
|
||||
min = 1;
|
||||
break;
|
||||
}
|
||||
dev->base = 0x0320 + (dev->type & 4);
|
||||
dev->irq = 5;
|
||||
dev->dma = 3;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1031,14 +1087,16 @@ xta_init(const device_t *info)
|
||||
dev->name, dev->base, dev->irq, dev->dma);
|
||||
if (dev->rom_addr != 0x000000)
|
||||
xta_log(", BIOS=%06X", dev->rom_addr);
|
||||
|
||||
xta_log(")\n");
|
||||
|
||||
/* Load any disks for this device class. */
|
||||
c = 0;
|
||||
for (uint8_t i = 0; i < HDD_NUM; i++) {
|
||||
if ((hdd[i].bus_type == HDD_BUS_XTA) && (hdd[i].xta_channel < max)) {
|
||||
drive = &dev->drives[hdd[i].xta_channel];
|
||||
if ((hdd[i].bus_type == HDD_BUS_XTA) && (hdd[i].xta_channel >= min) && (hdd[i].xta_channel < max)) {
|
||||
if (dev->type == 4)
|
||||
drive = &dev->drives[0];
|
||||
else
|
||||
drive = &dev->drives[hdd[i].xta_channel];
|
||||
|
||||
if (!hdd_image_load(i)) {
|
||||
drive->present = 0;
|
||||
@@ -1058,6 +1116,112 @@ xta_init(const device_t *info)
|
||||
drive->hpc = drive->cfg_hpc;
|
||||
drive->tracks = drive->cfg_tracks;
|
||||
|
||||
if (dev->type == 0) {
|
||||
if (!strcmp(bios_rev, "rev_1")) {
|
||||
/*
|
||||
WDXT-150, Revision 1 switches:
|
||||
- Bit 6: 1 = IBM (INT 13h), 0 = Tandy (INT 0Ah).
|
||||
- Bit 5: 1 = 17 sectors per track, 0 = 27 sectors per track.
|
||||
- Drive 0, bits 1,0:
|
||||
- With bit 4 set:
|
||||
- 0,0 = 820/4/17;
|
||||
- 0,1 = 615/4/17;
|
||||
- 1,0 = 782/4/17;
|
||||
- 1,1 = 782/2/17.
|
||||
- With bit 4 clear:
|
||||
- 0,0 = 1024/4/17;
|
||||
- 0,1 = 940/4/17;
|
||||
- 1,0 = 1024/4/17;
|
||||
- 1,1 = 1024/2/17.
|
||||
- Drive 1, bits 3,2:
|
||||
- With bit 4 set:
|
||||
- 0,0 = 820/4/17;
|
||||
- 0,1 = 615/4/17;
|
||||
- 1,0 = 782/4/17;
|
||||
- 1,1 = 782/2/17.
|
||||
- With bit 4 clear:
|
||||
- 0,0 = 1024/4/17;
|
||||
- 0,1 = 940/4/17;
|
||||
- 1,0 = 1024/4/17;
|
||||
- 1,1 = 1024/2/17.
|
||||
*/
|
||||
if (drive->tracks == 940)
|
||||
dev->sw = ((dev->sw & 0xef) & (c ? 0xf3 : 0xfc)) | (0x01 << (c << 1));
|
||||
else if (drive->tracks == 1024) {
|
||||
if (drive->hpc == 4)
|
||||
dev->sw = ((dev->sw & 0xef) & (c ? 0xf3 : 0xfc)) | (0x00 << (c << 1));
|
||||
else
|
||||
dev->sw = ((dev->sw & 0xef) & (c ? 0xf3 : 0xfc)) | (0x03 << (c << 1));
|
||||
} else if (drive->tracks == 782) {
|
||||
if (drive->hpc == 4)
|
||||
dev->sw = (dev->sw & (c ? 0xf3 : 0xfc)) | (0x02 << (c << 1));
|
||||
else
|
||||
dev->sw = (dev->sw & (c ? 0xf3 : 0xfc)) | (0x03 << (c << 1));
|
||||
} else if (drive->tracks == 820)
|
||||
dev->sw = (dev->sw & (c ? 0xf3 : 0xfc)) | (0x00 << (c << 1));
|
||||
else
|
||||
dev->sw = (dev->sw & (c ? 0xf3 : 0xfc)) | (0x01 << (c << 1));
|
||||
} else {
|
||||
/*
|
||||
WDXT-150, Revision 2 switches:
|
||||
- Drive 0, bits 1,0:
|
||||
- With bit 4 set:
|
||||
- 0,0 = 612/4/17;
|
||||
- 0,1 = 615/6/17;
|
||||
- 1,0 = 977/5/17;
|
||||
- 1,1 = 615/4/17.
|
||||
- With bit 4 clear:
|
||||
- 0,0 = 976/4/17;
|
||||
- 0,1 = 1024/3/17;
|
||||
- 1,0 = 1024/4/17;
|
||||
- 1,1 = 1024/2/17.
|
||||
- Drive 1, bits 3,2:
|
||||
- With bit 4 set:
|
||||
- 0,0 = 612/4/17;
|
||||
- 0,1 = 615/6/17;
|
||||
- 1,0 = 977/5/17;
|
||||
- 1,1 = 615/4/17.
|
||||
- With bit 4 clear:
|
||||
- 0,0 = 976/4/17;
|
||||
- 0,1 = 1024/3/17;
|
||||
- 1,0 = 1024/4/17;
|
||||
- 1,1 = 1024/2/17.
|
||||
*/
|
||||
if (drive->tracks == 976)
|
||||
dev->sw = ((dev->sw & 0xef) & (c ? 0xf3 : 0xfc)) | (0x00 << (c << 1));
|
||||
else if (drive->tracks == 1024) {
|
||||
if (drive->hpc == 3)
|
||||
dev->sw = ((dev->sw & 0xef) & (c ? 0xf3 : 0xfc)) | (0x01 << (c << 1));
|
||||
else if (drive->hpc == 4)
|
||||
dev->sw = ((dev->sw & 0xef) & (c ? 0xf3 : 0xfc)) | (0x02 << (c << 1));
|
||||
else
|
||||
dev->sw = ((dev->sw & 0xef) & (c ? 0xf3 : 0xfc)) | (0x03 << (c << 1));
|
||||
} else if (drive->tracks == 615) {
|
||||
if (drive->hpc == 6)
|
||||
dev->sw = (dev->sw & (c ? 0xf3 : 0xfc)) | (0x01 << (c << 1));
|
||||
else
|
||||
dev->sw = (dev->sw & (c ? 0xf3 : 0xfc)) | (0x03 << (c << 1));
|
||||
} else if (drive->tracks == 612)
|
||||
dev->sw = (dev->sw & (c ? 0xf3 : 0xfc)) | (0x00 << (c << 1));
|
||||
else
|
||||
dev->sw = (dev->sw & (c ? 0xf3 : 0xfc)) | (0x02 << (c << 1));
|
||||
}
|
||||
} else if ((dev->type >= 2) && (dev->type <= 4)) {
|
||||
/*
|
||||
Bits 1, 0:
|
||||
- 1, 1 = 615/4/17 (20 MB);
|
||||
- 1, 0 or 0, 0 = 980/5/17 (40 MB);
|
||||
- 0, 1 = 615/6/17 (30 MB).
|
||||
- 0, 0 is actually no hard disk present - switch port supposed to be readable always?
|
||||
*/
|
||||
if (drive->tracks == 980)
|
||||
dev->sw = 0xfe;
|
||||
else if (drive->hpc == 6)
|
||||
dev->sw = 0xfd;
|
||||
else
|
||||
dev->sw = 0xff;
|
||||
}
|
||||
|
||||
xta_log("%s: drive%d (cyl=%d,hd=%d,spt=%d), disk %d\n",
|
||||
dev->name, hdd[i].xta_channel, drive->tracks,
|
||||
drive->hpc, drive->spt, i);
|
||||
@@ -1083,6 +1247,23 @@ xta_init(const device_t *info)
|
||||
return dev;
|
||||
}
|
||||
|
||||
static void *
|
||||
xta_init(const device_t *info)
|
||||
{
|
||||
return xta_init_common(info, info->local);
|
||||
}
|
||||
|
||||
static void *
|
||||
xta_st50x_init(const device_t *info)
|
||||
{
|
||||
hdc_dual_t *dev = (hdc_dual_t *) calloc(1, sizeof(hdc_dual_t));
|
||||
|
||||
dev->hdc[0] = xta_init_common(info, info->local);
|
||||
dev->hdc[1] = xta_init_common(info, 4);
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
static void
|
||||
xta_close(void *priv)
|
||||
{
|
||||
@@ -1104,6 +1285,21 @@ xta_close(void *priv)
|
||||
free(dev);
|
||||
}
|
||||
|
||||
static void
|
||||
xta_st50x_close(void *priv)
|
||||
{
|
||||
hdc_dual_t *dev = (hdc_dual_t *) priv;
|
||||
|
||||
xta_close(dev->hdc[1]);
|
||||
xta_close(dev->hdc[0]);
|
||||
}
|
||||
|
||||
static int
|
||||
st50x_available(void)
|
||||
{
|
||||
return (rom_present(ST50X_BIOS_FILE));
|
||||
}
|
||||
|
||||
static const device_config_t wdxt150_config[] = {
|
||||
// clang-format off
|
||||
{
|
||||
@@ -1136,6 +1332,7 @@ static const device_config_t wdxt150_config[] = {
|
||||
{ .files_no = 0 }
|
||||
},
|
||||
},
|
||||
#ifdef SELECTABLE_BASE
|
||||
{
|
||||
.name = "base",
|
||||
.description = "Address",
|
||||
@@ -1151,6 +1348,7 @@ static const device_config_t wdxt150_config[] = {
|
||||
},
|
||||
.bios = { { 0 } }
|
||||
},
|
||||
#endif
|
||||
{
|
||||
.name = "irq",
|
||||
.description = "IRQ",
|
||||
@@ -1168,7 +1366,28 @@ static const device_config_t wdxt150_config[] = {
|
||||
},
|
||||
{
|
||||
.name = "bios_addr",
|
||||
.description = "BIOS Address",
|
||||
.description = "BIOS address",
|
||||
.type = CONFIG_HEX20,
|
||||
.default_string = NULL,
|
||||
.default_int = 0xc8000,
|
||||
.file_filter = NULL,
|
||||
.spinner = { 0 },
|
||||
.selection = {
|
||||
{ .description = "C800H", .value = 0xc8000 },
|
||||
{ .description = "CA00H", .value = 0xca000 },
|
||||
{ .description = "" }
|
||||
},
|
||||
.bios = { { 0 } }
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
// clang-format off
|
||||
};
|
||||
|
||||
static const device_config_t st50x_config[] = {
|
||||
// clang-format off
|
||||
{
|
||||
.name = "bios_addr",
|
||||
.description = "BIOS address",
|
||||
.type = CONFIG_HEX20,
|
||||
.default_string = NULL,
|
||||
.default_int = 0xc8000,
|
||||
@@ -1212,3 +1431,31 @@ const device_t xta_hd20_device = {
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t xta_st50x_device = {
|
||||
.name = "ST-50X Fixed Disk Controller",
|
||||
.internal_name = "xta_st50x",
|
||||
.flags = DEVICE_ISA,
|
||||
.local = 2,
|
||||
.init = xta_st50x_init,
|
||||
.close = xta_st50x_close,
|
||||
.reset = NULL,
|
||||
.available = st50x_available,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = st50x_config
|
||||
};
|
||||
|
||||
const device_t xta_st50x_pc5086_device = {
|
||||
.name = "ST-50X Fixed Disk Controller (PC5086)",
|
||||
.internal_name = "xta_st50x_pc5086",
|
||||
.flags = DEVICE_ISA,
|
||||
.local = 3,
|
||||
.init = xta_init,
|
||||
.close = xta_close,
|
||||
.reset = NULL,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
@@ -341,7 +341,7 @@ static const device_config_t xtide_config[] = {
|
||||
},
|
||||
{
|
||||
.name = "bios_addr",
|
||||
.description = "BIOS Address",
|
||||
.description = "BIOS address",
|
||||
.type = CONFIG_HEX20,
|
||||
.default_string = NULL,
|
||||
.default_int = 0xd0000,
|
||||
|
||||
@@ -78,6 +78,12 @@ no_cdrom:
|
||||
|
||||
if (!strcmp(str, "scsi"))
|
||||
return HDD_BUS_SCSI;
|
||||
|
||||
if (!strcmp(str, "mitsumi"))
|
||||
return CDROM_BUS_MITSUMI;
|
||||
|
||||
if (!strcmp(str, "mke"))
|
||||
return CDROM_BUS_MKE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -89,6 +95,17 @@ hdd_bus_to_string(int bus, UNUSED(int cdrom))
|
||||
|
||||
switch (bus) {
|
||||
default:
|
||||
if (cdrom) {
|
||||
switch (bus) {
|
||||
case CDROM_BUS_MITSUMI:
|
||||
s = "mitsumi";
|
||||
break;
|
||||
case CDROM_BUS_MKE:
|
||||
s = "mke";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HDD_BUS_DISABLED:
|
||||
break;
|
||||
|
||||
@@ -143,8 +160,12 @@ hdd_seek_get_time(hard_disk_t *hdd, uint32_t dst_addr, uint8_t operation, uint8_
|
||||
|
||||
const hdd_zone_t *zone = NULL;
|
||||
if (hdd->num_zones <= 0) {
|
||||
#ifdef DO_FATAL
|
||||
fatal("hdd_seek_get_time(): hdd->num_zones < 0)\n");
|
||||
return 0.0;
|
||||
#else
|
||||
return 1000.0;
|
||||
#endif
|
||||
}
|
||||
for (uint32_t i = 0; i < hdd->num_zones; i++) {
|
||||
zone = &hdd->zones[i];
|
||||
|
||||
@@ -152,6 +152,14 @@ mo_load(const mo_t *dev, const char *fn, const int skip_insert)
|
||||
{
|
||||
const int was_empty = mo_is_empty(dev->id);
|
||||
int ret = 0;
|
||||
int offs = 0;
|
||||
|
||||
if (strstr(fn, "wp://") == fn) {
|
||||
offs = 5;
|
||||
dev->drv->read_only = 1;
|
||||
}
|
||||
|
||||
fn += offs;
|
||||
|
||||
if (dev->drv == NULL)
|
||||
mo_eject(dev->id);
|
||||
@@ -202,7 +210,7 @@ mo_load(const mo_t *dev, const char *fn, const int skip_insert)
|
||||
log_fatal(dev->log, "mo_load(): Error seeking to the beginning of "
|
||||
"the file\n");
|
||||
|
||||
strncpy(dev->drv->image_path, fn, sizeof(dev->drv->image_path) - 1);
|
||||
strncpy(dev->drv->image_path, fn - offs, sizeof(dev->drv->image_path) - 1);
|
||||
|
||||
ret = 1;
|
||||
} else
|
||||
@@ -218,6 +226,9 @@ mo_load(const mo_t *dev, const char *fn, const int skip_insert)
|
||||
if (was_empty)
|
||||
mo_insert((mo_t *) dev);
|
||||
}
|
||||
|
||||
if (ret)
|
||||
ui_sb_update_icon_wp(SB_MO | dev->id, dev->drv->read_only);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -335,14 +335,18 @@ fdc_int(fdc_t *fdc, int set_fintr)
|
||||
{
|
||||
int ienable = 0;
|
||||
|
||||
if (!(fdc->flags & FDC_FLAG_PCJR))
|
||||
if (fdc->flags & FDC_FLAG_PS2_MCA)
|
||||
ienable = 1;
|
||||
else if (!(fdc->flags & FDC_FLAG_PCJR))
|
||||
ienable = !!(fdc->dor & 8);
|
||||
|
||||
if (ienable)
|
||||
picint(1 << fdc->irq);
|
||||
if (ienable) {
|
||||
if (fdc->irq != 0xff)
|
||||
picint(1 << fdc->irq);
|
||||
|
||||
if (set_fintr)
|
||||
fdc->fintr = 1;
|
||||
if (set_fintr)
|
||||
fdc->fintr = 1;
|
||||
}
|
||||
fdc_log("fdc_int(%i): fdc->fintr = %i\n", set_fintr, fdc->fintr);
|
||||
}
|
||||
|
||||
@@ -355,7 +359,7 @@ fdc_watchdog_poll(void *priv)
|
||||
if (fdc->watchdog_count)
|
||||
timer_advance_u64(&fdc->watchdog_timer, 1000 * TIMER_USEC);
|
||||
else {
|
||||
if (fdc->dor & 0x20)
|
||||
if ((fdc->dor & 0x20) && (fdc->irq != 0xff))
|
||||
picint(1 << fdc->irq);
|
||||
}
|
||||
}
|
||||
@@ -435,6 +439,44 @@ fdc_set_media_id(fdc_t *fdc, int id, int set)
|
||||
fdc->media_id = (fdc->media_id & ~(1 << id)) | (set << id);
|
||||
}
|
||||
|
||||
void
|
||||
fdc_set_flags(fdc_t *fdc, int flags)
|
||||
{
|
||||
fdc->flags |= flags;
|
||||
}
|
||||
|
||||
void
|
||||
fdc_clear_flags(fdc_t *fdc, int flags)
|
||||
{
|
||||
fdc->flags &= ~flags;
|
||||
}
|
||||
|
||||
void
|
||||
fdc_set_fdd_changed(int drive, int changed)
|
||||
{
|
||||
if (changed)
|
||||
fdd_changed[drive] = 1;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
fdc_get_fdd_changed(int drive)
|
||||
{
|
||||
uint8_t ret = !!fdd_changed[drive];
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
fdc_get_shadow(fdc_t *fdc)
|
||||
{
|
||||
uint8_t ret = (fdc->rate & 0x03) |
|
||||
((fdc->pretrk & 0x07) << 2) |
|
||||
(fdc->power_down ? 0x40 : 0x00) |
|
||||
((fdc_read(0x03f2, fdc) & 0x04) ? 0x80 : 0x00);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
fdc_get_boot_drive(fdc_t *fdc)
|
||||
{
|
||||
@@ -762,9 +804,17 @@ fdc_write(uint16_t addr, uint8_t val, void *priv)
|
||||
fdc->st0 &= ~0x07;
|
||||
fdc->st0 |= (fdd_get_head(0) ? 4 : 0);
|
||||
} else {
|
||||
if (!(val & 8) && (fdc->dor & 8)) {
|
||||
fdc->tc = 1;
|
||||
fdc_int(fdc, 1);
|
||||
/*
|
||||
Writing this bit to logic "1" will enable the DRQ,
|
||||
nDACK, TC and FINTR outputs. This bit being a
|
||||
logic "0" will disable the nDACK and TC inputs, and
|
||||
hold the DRQ and FINTR outputs in a high
|
||||
impedance state.
|
||||
*/
|
||||
if (!(val & 8) && (fdc->dor & 8) && !(fdc->flags & FDC_FLAG_PS2_MCA)) {
|
||||
fdc->tc = 1;
|
||||
fdc->fintr = 0;
|
||||
picintc(1 << fdc->irq);
|
||||
}
|
||||
if (!(val & 4)) {
|
||||
fdd_stop(real_drive(fdc, val & 3));
|
||||
|
||||
@@ -110,7 +110,7 @@ static const device_config_t b215_config[] = {
|
||||
// clang-format off
|
||||
{
|
||||
.name = "bios_addr",
|
||||
.description = "BIOS Address",
|
||||
.description = "BIOS address",
|
||||
.type = CONFIG_HEX20,
|
||||
.default_string = NULL,
|
||||
.default_int = 0xca000,
|
||||
|
||||
@@ -162,7 +162,7 @@ static const device_config_t monster_fdc_config[] = {
|
||||
#endif
|
||||
{
|
||||
.name = "bios_addr",
|
||||
.description = "BIOS Address",
|
||||
.description = "BIOS address",
|
||||
.type = CONFIG_HEX20,
|
||||
.default_string = NULL,
|
||||
.default_int = 0xc8000,
|
||||
|
||||
@@ -123,7 +123,7 @@ static const device_config_t pii_config[] = {
|
||||
// clang-format off
|
||||
{
|
||||
.name = "bios_addr",
|
||||
.description = "BIOS Address",
|
||||
.description = "BIOS address",
|
||||
.type = CONFIG_HEX20,
|
||||
.default_string = NULL,
|
||||
.default_int = 0xce000,
|
||||
|
||||
@@ -459,11 +459,17 @@ fdd_load(int drive, char *fn)
|
||||
int size;
|
||||
const char *p;
|
||||
FILE *fp;
|
||||
int offs = 0;
|
||||
|
||||
fdd_log("FDD: loading drive %d with '%s'\n", drive, fn);
|
||||
|
||||
if (!fn)
|
||||
return;
|
||||
if (strstr(fn, "wp://") == fn) {
|
||||
offs = 5;
|
||||
ui_writeprot[drive] = 1;
|
||||
}
|
||||
fn += offs;
|
||||
p = path_get_extension(fn);
|
||||
if (!p)
|
||||
return;
|
||||
@@ -476,13 +482,14 @@ fdd_load(int drive, char *fn)
|
||||
while (loaders[c].ext) {
|
||||
if (!strcasecmp(p, (char *) loaders[c].ext) && (size == loaders[c].size || loaders[c].size == -1)) {
|
||||
driveloaders[drive] = c;
|
||||
if (floppyfns[drive] != fn)
|
||||
strcpy(floppyfns[drive], fn);
|
||||
if (floppyfns[drive] != (fn - offs))
|
||||
strcpy(floppyfns[drive], fn - offs);
|
||||
d86f_setup(drive);
|
||||
loaders[c].load(drive, floppyfns[drive]);
|
||||
loaders[c].load(drive, floppyfns[drive] + offs);
|
||||
drive_empty[drive] = 0;
|
||||
fdd_forced_seek(drive, 0);
|
||||
fdd_changed[drive] = 1;
|
||||
ui_sb_update_icon_wp(SB_FLOPPY | drive, ui_writeprot[drive]);
|
||||
return;
|
||||
}
|
||||
c++;
|
||||
@@ -532,7 +539,7 @@ fdd_hole(int drive)
|
||||
static __inline uint64_t
|
||||
fdd_byteperiod(int drive)
|
||||
{
|
||||
if (!fdd_get_turbo(drive) && drives[drive].byteperiod)
|
||||
if (drives[drive].byteperiod)
|
||||
return drives[drive].byteperiod(drive);
|
||||
else
|
||||
return 32ULL * TIMER_USEC;
|
||||
|
||||
@@ -758,36 +758,43 @@ d86f_get_encoding(int drive)
|
||||
uint64_t
|
||||
d86f_byteperiod(int drive)
|
||||
{
|
||||
double dusec = (double) TIMER_USEC;
|
||||
double p = 2.0;
|
||||
d86f_t *dev = d86f[drive];
|
||||
uint64_t ret = 32ULL * TIMER_USEC;
|
||||
|
||||
switch (d86f_track_flags(drive) & 0x0f) {
|
||||
case 0x02: /* 125 kbps, FM */
|
||||
p = 4.0;
|
||||
break;
|
||||
case 0x01: /* 150 kbps, FM */
|
||||
p = 20.0 / 6.0;
|
||||
break;
|
||||
case 0x0a: /* 250 kbps, MFM */
|
||||
case 0x00: /* 250 kbps, FM */
|
||||
default:
|
||||
p = 2.0;
|
||||
break;
|
||||
case 0x09: /* 300 kbps, MFM */
|
||||
p = 10.0 / 6.0;
|
||||
break;
|
||||
case 0x08: /* 500 kbps, MFM */
|
||||
p = 1.0;
|
||||
break;
|
||||
case 0x0b: /* 1000 kbps, MFM */
|
||||
p = 0.5;
|
||||
break;
|
||||
case 0x0d: /* 2000 kbps, MFM */
|
||||
p = 0.25;
|
||||
break;
|
||||
if (!fdd_get_turbo(drive) || (dev->version != 0x0063) || (dev->state == STATE_SECTOR_NOT_FOUND)) {
|
||||
double dusec = (double) TIMER_USEC;
|
||||
double p = 2.0;
|
||||
|
||||
switch (d86f_track_flags(drive) & 0x0f) {
|
||||
case 0x02: /* 125 kbps, FM */
|
||||
p = 4.0;
|
||||
break;
|
||||
case 0x01: /* 150 kbps, FM */
|
||||
p = 20.0 / 6.0;
|
||||
break;
|
||||
case 0x0a: /* 250 kbps, MFM */
|
||||
case 0x00: /* 250 kbps, FM */
|
||||
default:
|
||||
p = 2.0;
|
||||
break;
|
||||
case 0x09: /* 300 kbps, MFM */
|
||||
p = 10.0 / 6.0;
|
||||
break;
|
||||
case 0x08: /* 500 kbps, MFM */
|
||||
p = 1.0;
|
||||
break;
|
||||
case 0x0b: /* 1000 kbps, MFM */
|
||||
p = 0.5;
|
||||
break;
|
||||
case 0x0d: /* 2000 kbps, MFM */
|
||||
p = 0.25;
|
||||
break;
|
||||
}
|
||||
|
||||
ret = (uint64_t) (p * dusec);
|
||||
}
|
||||
|
||||
return (uint64_t) (p * dusec);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -2463,16 +2470,17 @@ d86f_poll(int drive)
|
||||
dev->state = STATE_SECTOR_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (fdd_get_turbo(drive) && (dev->version == 0x0063)) {
|
||||
d86f_turbo_poll(drive, side);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((dev->state != STATE_IDLE) && (dev->state != STATE_SECTOR_NOT_FOUND) && ((dev->state & 0xF8) != 0xE8)) {
|
||||
if (!d86f_can_read_address(drive))
|
||||
dev->state = STATE_SECTOR_NOT_FOUND;
|
||||
}
|
||||
|
||||
/* Do normal poll if DENSEL is wrong, because Windows 95 is very strict about timings there. */
|
||||
if (fdd_get_turbo(drive) && (dev->version == 0x0063) && (dev->state != STATE_SECTOR_NOT_FOUND)) {
|
||||
d86f_turbo_poll(drive, side);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((dev->state != STATE_02_SPIN_TO_INDEX) && (dev->state != STATE_0D_SPIN_TO_INDEX))
|
||||
d86f_get_bit(drive, side ^ 1);
|
||||
|
||||
@@ -2577,12 +2585,6 @@ d86f_poll(int drive)
|
||||
|
||||
d86f_advance_bit(drive, side);
|
||||
|
||||
if (d86f_wrong_densel(drive) && (dev->state != STATE_IDLE)) {
|
||||
dev->state = STATE_IDLE;
|
||||
fdc_noidam(d86f_fdc);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((dev->index_count == 2) && (dev->state != STATE_IDLE)) {
|
||||
switch (dev->state) {
|
||||
case STATE_0A_FIND_ID:
|
||||
@@ -3277,7 +3279,12 @@ d86f_readsector(int drive, int sector, int track, int side, int rate, int sector
|
||||
if (!ret)
|
||||
return;
|
||||
|
||||
if (sector == SECTOR_FIRST)
|
||||
if (d86f_wrong_densel(drive)) {
|
||||
dev->state = STATE_SECTOR_NOT_FOUND;
|
||||
|
||||
if (fdd_get_turbo(drive))
|
||||
dev->track_pos = 0;
|
||||
} else if (sector == SECTOR_FIRST)
|
||||
dev->state = STATE_02_SPIN_TO_INDEX;
|
||||
else if (sector == SECTOR_NEXT)
|
||||
dev->state = STATE_02_FIND_ID;
|
||||
@@ -3302,7 +3309,13 @@ d86f_writesector(int drive, int sector, int track, int side, int rate, int secto
|
||||
if (!ret)
|
||||
return;
|
||||
|
||||
dev->state = fdc_is_deleted(d86f_fdc) ? STATE_09_FIND_ID : STATE_05_FIND_ID;
|
||||
if (d86f_wrong_densel(drive)) {
|
||||
dev->state = STATE_SECTOR_NOT_FOUND;
|
||||
|
||||
if (fdd_get_turbo(drive))
|
||||
dev->track_pos = 0;
|
||||
} else
|
||||
dev->state = fdc_is_deleted(d86f_fdc) ? STATE_09_FIND_ID : STATE_05_FIND_ID;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -3315,7 +3328,13 @@ d86f_comparesector(int drive, int sector, int track, int side, int rate, int sec
|
||||
if (!ret)
|
||||
return;
|
||||
|
||||
dev->state = STATE_11_FIND_ID;
|
||||
if (d86f_wrong_densel(drive)) {
|
||||
dev->state = STATE_SECTOR_NOT_FOUND;
|
||||
|
||||
if (fdd_get_turbo(drive))
|
||||
dev->track_pos = 0;
|
||||
} else
|
||||
dev->state = STATE_11_FIND_ID;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -3336,7 +3355,13 @@ d86f_readaddress(int drive, UNUSED(int side), UNUSED(int rate))
|
||||
dev->id_found = 0;
|
||||
dev->dma_over = 0;
|
||||
|
||||
dev->state = STATE_0A_FIND_ID;
|
||||
if (d86f_wrong_densel(drive)) {
|
||||
dev->state = STATE_SECTOR_NOT_FOUND;
|
||||
|
||||
if (fdd_get_turbo(drive))
|
||||
dev->track_pos = 0;
|
||||
} else
|
||||
dev->state = STATE_0A_FIND_ID;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -3438,7 +3463,13 @@ d86f_common_format(int drive, int side, UNUSED(int rate), uint8_t fill, int prox
|
||||
dev->index_count = dev->error_condition = dev->satisfying_bytes = dev->sector_count = 0;
|
||||
dev->dma_over = 0;
|
||||
|
||||
dev->state = STATE_0D_SPIN_TO_INDEX;
|
||||
if (d86f_wrong_densel(drive) && !proxy) {
|
||||
dev->state = STATE_SECTOR_NOT_FOUND;
|
||||
|
||||
if (fdd_get_turbo(drive))
|
||||
dev->track_pos = 0;
|
||||
} else
|
||||
dev->state = STATE_0D_SPIN_TO_INDEX;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -61,13 +61,13 @@ typedef struct _joystick_instance_ {
|
||||
uint8_t state;
|
||||
g_axis_t axis[4];
|
||||
|
||||
const joystick_if_t *intf;
|
||||
void *dat;
|
||||
const joystick_t *intf;
|
||||
void *dat;
|
||||
} joystick_instance_t;
|
||||
|
||||
int joystick_type = JS_TYPE_NONE;
|
||||
|
||||
static const joystick_if_t joystick_none = {
|
||||
static const joystick_t joystick_none = {
|
||||
.name = "None",
|
||||
.internal_name = "none",
|
||||
.init = NULL,
|
||||
@@ -86,7 +86,7 @@ static const joystick_if_t joystick_none = {
|
||||
};
|
||||
|
||||
static const struct {
|
||||
const joystick_if_t *joystick;
|
||||
const joystick_t *joystick;
|
||||
} joysticks[] = {
|
||||
{ &joystick_none },
|
||||
{ &joystick_2axis_2button },
|
||||
@@ -100,7 +100,7 @@ static const struct {
|
||||
{ &joystick_3axis_2button },
|
||||
{ &joystick_2button_yoke_throttle },
|
||||
{ &joystick_3axis_4button },
|
||||
{ &joystick_win95_steering_wheel }, // Temp
|
||||
{ &joystick_win95_steering_wheel },
|
||||
{ &joystick_4button_yoke_throttle },
|
||||
{ &joystick_4axis_4button },
|
||||
{ &joystick_ch_flightstick_pro },
|
||||
@@ -114,24 +114,39 @@ static const struct {
|
||||
static joystick_instance_t *joystick_instance[GAMEPORT_MAX] = { NULL, NULL };
|
||||
|
||||
static uint8_t gameport_pnp_rom[] = {
|
||||
0x09, 0xf8, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, /* BOX0002, dummy checksum (filled in by isapnp_add_card) */
|
||||
0x0a, 0x10, 0x10, /* PnP version 1.0, vendor version 1.0 */
|
||||
0x82, 0x09, 0x00, 'G', 'a', 'm', 'e', ' ', 'P', 'o', 'r', 't', /* ANSI identifier */
|
||||
/* BOX0002, serial 0, dummy checksum (filled in by isapnp_add_card) */
|
||||
0x09, 0xf8, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
/* PnP version 1.0, vendor version 1.0 */
|
||||
0x0a, 0x10, 0x10,
|
||||
/* ANSI identifier */
|
||||
0x82, 0x09, 0x00, 'G', 'a', 'm', 'e', ' ', 'P', 'o', 'r', 't',
|
||||
|
||||
0x15, 0x09, 0xf8, 0x00, 0x02, 0x01, /* logical device BOX0002, can participate in boot */
|
||||
0x1c, 0x41, 0xd0, 0xb0, 0x2f, /* compatible device PNPB02F */
|
||||
0x31, 0x00, /* start dependent functions, preferred */
|
||||
0x47, 0x01, 0x00, 0x02, 0x00, 0x02, 0x08, 0x08, /* I/O 0x200, decodes 16-bit, 8-byte alignment, 8 addresses */
|
||||
0x30, /* start dependent functions, acceptable */
|
||||
0x47, 0x01, 0x08, 0x02, 0x08, 0x02, 0x08, 0x08, /* I/O 0x208, decodes 16-bit, 8-byte alignment, 8 addresses */
|
||||
0x31, 0x02, /* start dependent functions, sub-optimal */
|
||||
0x47, 0x01, 0x00, 0x01, 0xf8, 0xff, 0x08, 0x08, /* I/O 0x100-0xFFF8, decodes 16-bit, 8-byte alignment, 8 addresses */
|
||||
0x38, /* end dependent functions */
|
||||
/* Logical device BOX0002, can participate in boot */
|
||||
0x15, 0x09, 0xf8, 0x00, 0x02, 0x01,
|
||||
/* Compatible device PNPB02F */
|
||||
0x1c, 0x41, 0xd0, 0xb0, 0x2f,
|
||||
/* Start dependent functions, preferred */
|
||||
0x31, 0x00,
|
||||
/* I/O 0x200, decodes 16-bit, 8-byte alignment, 8 addresses */
|
||||
0x47, 0x01, 0x00, 0x02, 0x00, 0x02, 0x08, 0x08,
|
||||
/* Start dependent functions, acceptable */
|
||||
0x30,
|
||||
/* I/O 0x208, decodes 16-bit, 8-byte alignment, 8 addresses */
|
||||
0x47, 0x01, 0x08, 0x02, 0x08, 0x02, 0x08, 0x08,
|
||||
/* Start dependent functions, sub-optimal */
|
||||
0x31, 0x02,
|
||||
/* I/O 0x100-0xFFF8, decodes 16-bit, 8-byte alignment, 8 addresses */
|
||||
0x47, 0x01, 0x00, 0x01, 0xf8, 0xff, 0x08, 0x08,
|
||||
/* End dependent functions */
|
||||
0x38,
|
||||
|
||||
0x79, 0x00 /* end tag, dummy checksum (filled in by isapnp_add_card) */
|
||||
/* End tag, dummy checksum (filled in by isapnp_add_card) */
|
||||
0x79, 0x00
|
||||
};
|
||||
|
||||
static const isapnp_device_config_t gameport_pnp_defaults[] = {
|
||||
{.activate = 1,
|
||||
{
|
||||
.activate = 1,
|
||||
.io = {
|
||||
{ .base = 0x200 },
|
||||
}
|
||||
@@ -244,10 +259,8 @@ gameport_write(UNUSED(uint16_t addr), UNUSED(uint8_t val), void *priv)
|
||||
/* Read all axes. */
|
||||
joystick->state |= 0x0f;
|
||||
|
||||
gameport_time(joystick, 0, joystick->intf->read_axis(joystick->dat, 0));
|
||||
gameport_time(joystick, 1, joystick->intf->read_axis(joystick->dat, 1));
|
||||
gameport_time(joystick, 2, joystick->intf->read_axis(joystick->dat, 2));
|
||||
gameport_time(joystick, 3, joystick->intf->read_axis(joystick->dat, 3));
|
||||
for (uint8_t i = 0; i < 4; i++)
|
||||
gameport_time(joystick, i, joystick->intf->read_axis(joystick->dat, i));
|
||||
|
||||
/* Notify the interface. */
|
||||
joystick->intf->write(joystick->dat);
|
||||
@@ -384,20 +397,14 @@ gameport_init(const device_t *info)
|
||||
if (!joystick_instance[0] && joystick_type) {
|
||||
joystick_instance[0] = calloc(1, sizeof(joystick_instance_t));
|
||||
|
||||
joystick_instance[0]->axis[0].joystick = joystick_instance[0];
|
||||
joystick_instance[0]->axis[1].joystick = joystick_instance[0];
|
||||
joystick_instance[0]->axis[2].joystick = joystick_instance[0];
|
||||
joystick_instance[0]->axis[3].joystick = joystick_instance[0];
|
||||
// For each analog joystick axis
|
||||
for (uint8_t i = 0; i < 4; i++) {
|
||||
joystick_instance[0]->axis[i].joystick = joystick_instance[0];
|
||||
|
||||
joystick_instance[0]->axis[0].axis_nr = 0;
|
||||
joystick_instance[0]->axis[1].axis_nr = 1;
|
||||
joystick_instance[0]->axis[2].axis_nr = 2;
|
||||
joystick_instance[0]->axis[3].axis_nr = 3;
|
||||
joystick_instance[0]->axis[i].axis_nr = i;
|
||||
|
||||
timer_add(&joystick_instance[0]->axis[0].timer, timer_over, &joystick_instance[0]->axis[0], 0);
|
||||
timer_add(&joystick_instance[0]->axis[1].timer, timer_over, &joystick_instance[0]->axis[1], 0);
|
||||
timer_add(&joystick_instance[0]->axis[2].timer, timer_over, &joystick_instance[0]->axis[2], 0);
|
||||
timer_add(&joystick_instance[0]->axis[3].timer, timer_over, &joystick_instance[0]->axis[3], 0);
|
||||
timer_add(&joystick_instance[0]->axis[i].timer, timer_over, &joystick_instance[0]->axis[i], 0);
|
||||
}
|
||||
|
||||
joystick_instance[0]->intf = joysticks[joystick_type].joystick;
|
||||
joystick_instance[0]->dat = joystick_instance[0]->intf->init();
|
||||
@@ -409,8 +416,8 @@ gameport_init(const device_t *info)
|
||||
dev->len = (info->local >> 16) & 0xff;
|
||||
gameport_remap(dev, info->local & 0xffff);
|
||||
|
||||
/* Register ISAPnP if this is a standard game port card. */
|
||||
if ((info->local & 0xffff) == 0x200)
|
||||
/* Register ISAPnP if this is a PNP game port card. */
|
||||
if (info->local & GAMEPORT_PNPROM)
|
||||
isapnp_set_device_defaults(isapnp_add_card(gameport_pnp_rom, sizeof(gameport_pnp_rom), gameport_pnp_config_changed, NULL, NULL, NULL, dev), 0, gameport_pnp_defaults);
|
||||
|
||||
return dev;
|
||||
@@ -483,9 +490,23 @@ gameport_close(void *priv)
|
||||
}
|
||||
|
||||
const device_t gameport_device = {
|
||||
.name = "Game port",
|
||||
.name = "86Box PNP Game port",
|
||||
.internal_name = "gameport",
|
||||
.flags = 0,
|
||||
.local = GAMEPORT_PNPROM | GAMEPORT_8ADDR | 0x0200,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t gameport_200_device = {
|
||||
.name = "Game port (Port 200h-207h)",
|
||||
.internal_name = "gameport_200",
|
||||
.flags = 0,
|
||||
.local = GAMEPORT_8ADDR | 0x0200,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
@@ -736,7 +757,7 @@ const device_t gameport_sio_device = {
|
||||
|
||||
const device_t gameport_sio_1io_device = {
|
||||
.name = "Game port (Super I/O, 1 I/O port)",
|
||||
.internal_name = "gameport_sio",
|
||||
.internal_name = "gameport_sio_1io",
|
||||
.flags = 0,
|
||||
.local = GAMEPORT_SIO | GAMEPORT_1ADDR,
|
||||
.init = gameport_init,
|
||||
@@ -751,6 +772,7 @@ const device_t gameport_sio_1io_device = {
|
||||
static const GAMEPORT gameports[] = {
|
||||
{ &device_none },
|
||||
{ &device_internal },
|
||||
{ &gameport_200_device },
|
||||
{ &gameport_device },
|
||||
{ &gameport_208_device },
|
||||
{ &gameport_pnp_device },
|
||||
@@ -771,7 +793,7 @@ gameport_available(int port)
|
||||
|
||||
/* UI */
|
||||
const device_t *
|
||||
gameports_getdevice(int port)
|
||||
gameport_getdevice(int port)
|
||||
{
|
||||
return (gameports[port].device);
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
*
|
||||
* Implementation of the Flight Stick Pro.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <https://pcem-emulator.co.uk/>
|
||||
*
|
||||
@@ -138,7 +136,7 @@ ch_flightstick_pro_a0_over(UNUSED(void *priv))
|
||||
//
|
||||
}
|
||||
|
||||
const joystick_if_t joystick_ch_flightstick_pro = {
|
||||
const joystick_t joystick_ch_flightstick_pro = {
|
||||
.name = "CH Flightstick Pro",
|
||||
.internal_name = "ch_flightstick_pro",
|
||||
.init = ch_flightstick_pro_init,
|
||||
@@ -156,7 +154,7 @@ const joystick_if_t joystick_ch_flightstick_pro = {
|
||||
.pov_names = { "POV" }
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_ch_flightstick_pro_ch_pedals = {
|
||||
const joystick_t joystick_ch_flightstick_pro_ch_pedals = {
|
||||
.name = "CH Flightstick Pro + CH Pedals",
|
||||
.internal_name = "ch_flightstick_pro_ch_pedals",
|
||||
.init = ch_flightstick_pro_init,
|
||||
|
||||
@@ -274,7 +274,7 @@ joystick_standard_a0_over(UNUSED(void *priv))
|
||||
//
|
||||
}
|
||||
|
||||
const joystick_if_t joystick_2axis_2button = {
|
||||
const joystick_t joystick_2axis_2button = {
|
||||
.name = "2-axis, 2-button joystick(s)",
|
||||
.internal_name = "2axis_2button",
|
||||
.init = joystick_standard_init,
|
||||
@@ -292,7 +292,7 @@ const joystick_if_t joystick_2axis_2button = {
|
||||
.pov_names = { NULL }
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_2button_gamepad = {
|
||||
const joystick_t joystick_2button_gamepad = {
|
||||
.name = "2-button gamepad(s)",
|
||||
.internal_name = "2button_gamepad",
|
||||
.init = joystick_standard_init,
|
||||
@@ -310,7 +310,7 @@ const joystick_if_t joystick_2button_gamepad = {
|
||||
.pov_names = { NULL }
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_2button_flight_yoke = {
|
||||
const joystick_t joystick_2button_flight_yoke = {
|
||||
.name = "2-button flight yoke",
|
||||
.internal_name = "2button_flight_yoke",
|
||||
.init = joystick_standard_init,
|
||||
@@ -328,7 +328,7 @@ const joystick_if_t joystick_2button_flight_yoke = {
|
||||
.pov_names = { NULL }
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_2axis_4button = {
|
||||
const joystick_t joystick_2axis_4button = {
|
||||
.name = "2-axis, 4-button joystick",
|
||||
.internal_name = "2axis_4button",
|
||||
.init = joystick_standard_init,
|
||||
@@ -346,7 +346,7 @@ const joystick_if_t joystick_2axis_4button = {
|
||||
.pov_names = { NULL }
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_4button_gamepad = {
|
||||
const joystick_t joystick_4button_gamepad = {
|
||||
.name = "4-button gamepad",
|
||||
.internal_name = "4button_gamepad",
|
||||
.init = joystick_standard_init,
|
||||
@@ -364,7 +364,7 @@ const joystick_if_t joystick_4button_gamepad = {
|
||||
.pov_names = { NULL }
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_4button_flight_yoke = {
|
||||
const joystick_t joystick_4button_flight_yoke = {
|
||||
.name = "4-button flight yoke",
|
||||
.internal_name = "4button_flight_yoke",
|
||||
.init = joystick_standard_init,
|
||||
@@ -382,7 +382,7 @@ const joystick_if_t joystick_4button_flight_yoke = {
|
||||
.pov_names = { NULL }
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_3axis_2button = {
|
||||
const joystick_t joystick_3axis_2button = {
|
||||
.name = "3-axis, 2-button joystick",
|
||||
.internal_name = "3axis_2button",
|
||||
.init = joystick_standard_init,
|
||||
@@ -400,7 +400,7 @@ const joystick_if_t joystick_3axis_2button = {
|
||||
.pov_names = { NULL }
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_2button_yoke_throttle = {
|
||||
const joystick_t joystick_2button_yoke_throttle = {
|
||||
.name = "2-button flight yoke with throttle",
|
||||
.internal_name = "2button_yoke_throttle",
|
||||
.init = joystick_standard_init,
|
||||
@@ -418,7 +418,7 @@ const joystick_if_t joystick_2button_yoke_throttle = {
|
||||
.pov_names = { NULL }
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_3axis_4button = {
|
||||
const joystick_t joystick_3axis_4button = {
|
||||
.name = "3-axis, 4-button joystick",
|
||||
.internal_name = "3axis_4button",
|
||||
.init = joystick_standard_init,
|
||||
@@ -436,7 +436,7 @@ const joystick_if_t joystick_3axis_4button = {
|
||||
.pov_names = { NULL }
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_4button_yoke_throttle = {
|
||||
const joystick_t joystick_4button_yoke_throttle = {
|
||||
.name = "4-button flight yoke with throttle",
|
||||
.internal_name = "4button_yoke_throttle",
|
||||
.init = joystick_standard_init,
|
||||
@@ -454,7 +454,7 @@ const joystick_if_t joystick_4button_yoke_throttle = {
|
||||
.pov_names = { NULL }
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_win95_steering_wheel = {
|
||||
const joystick_t joystick_win95_steering_wheel = {
|
||||
.name = "Win95 Steering Wheel (3-axis, 4-button)",
|
||||
.internal_name = "win95_steering_wheel",
|
||||
.init = joystick_standard_init,
|
||||
@@ -472,7 +472,7 @@ const joystick_if_t joystick_win95_steering_wheel = {
|
||||
.pov_names = { NULL }
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_4axis_4button = {
|
||||
const joystick_t joystick_4axis_4button = {
|
||||
.name = "4-axis, 4-button joystick",
|
||||
.internal_name = "4axis_4button",
|
||||
.init = joystick_standard_init,
|
||||
@@ -490,7 +490,7 @@ const joystick_if_t joystick_4axis_4button = {
|
||||
.pov_names = { NULL }
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_2axis_6button = {
|
||||
const joystick_t joystick_2axis_6button = {
|
||||
.name = "2-axis, 6-button joystick",
|
||||
.internal_name = "2axis_6button",
|
||||
.init = joystick_standard_init,
|
||||
@@ -508,7 +508,7 @@ const joystick_if_t joystick_2axis_6button = {
|
||||
.pov_names = { NULL }
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_2axis_8button = {
|
||||
const joystick_t joystick_2axis_8button = {
|
||||
.name = "2-axis, 8-button joystick",
|
||||
.internal_name = "2axis_8button",
|
||||
.init = joystick_standard_init,
|
||||
|
||||
@@ -29,8 +29,6 @@
|
||||
* - Some DOS stuff will write to 0x201 while a packet is
|
||||
* being transferred. This seems to be ignored.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <https://pcem-emulator.co.uk/>
|
||||
*
|
||||
@@ -244,7 +242,7 @@ sw_a0_over(void *priv)
|
||||
timer_set_delay_u64(&sw->trigger_timer, TIMER_USEC * 10000);
|
||||
}
|
||||
|
||||
const joystick_if_t joystick_sw_pad = {
|
||||
const joystick_t joystick_sw_pad = {
|
||||
.name = "Microsoft SideWinder Pad",
|
||||
.internal_name = "sidewinder_pad",
|
||||
.init = sw_init,
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
*
|
||||
* Implementation of Thrust Master Flight Control System.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <https://pcem-emulator.co.uk/>
|
||||
*
|
||||
@@ -148,7 +146,7 @@ tm_fcs_a0_over(UNUSED(void *priv))
|
||||
//
|
||||
}
|
||||
|
||||
const joystick_if_t joystick_tm_fcs = {
|
||||
const joystick_t joystick_tm_fcs = {
|
||||
.name = "Thrustmaster Flight Control System",
|
||||
.internal_name = "thrustmaster_fcs",
|
||||
.init = tm_fcs_init,
|
||||
@@ -166,7 +164,7 @@ const joystick_if_t joystick_tm_fcs = {
|
||||
.pov_names = { "POV" }
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_tm_fcs_rcs = {
|
||||
const joystick_t joystick_tm_fcs_rcs = {
|
||||
.name = "Thrustmaster FCS + Rudder Control System",
|
||||
.internal_name = "thrustmaster_fcs_rcs",
|
||||
.init = tm_fcs_init,
|
||||
|
||||
@@ -25,6 +25,11 @@
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
|
||||
#if defined(__HAIKU__)
|
||||
/* Doesn't compile on Haiku without this include */
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
/* Configuration values. */
|
||||
#define GFXCARD_MAX 2
|
||||
#define SERIAL_MAX 8
|
||||
@@ -176,6 +181,7 @@ extern int hook_enabled; /* (C) Keyboard hook is enabled */
|
||||
extern char exe_path[2048]; /* path (dir) of executable */
|
||||
extern char usr_path[1024]; /* path (dir) of user data */
|
||||
extern char cfg_path[1024]; /* full path of config file */
|
||||
extern char global_cfg_path[1024]; /* full path of global config file */
|
||||
extern int open_dir_usr_path; /* default file open dialog directory of usr_path */
|
||||
extern char uuid[MAX_UUID_LEN]; /* UUID or machine identifier */
|
||||
extern char vmm_path[1024]; /* VM Manager path to scan (temporary) */
|
||||
@@ -195,6 +201,7 @@ extern void warning_ex(const char *fmt, va_list ap);
|
||||
#endif
|
||||
extern void pclog_toggle_suppr(void);
|
||||
extern void pclog(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
extern void always_log(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
extern void fatal(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
extern void warning(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
extern void set_screen_size(int x, int y);
|
||||
|
||||
@@ -75,7 +75,7 @@ void pc_cas_del(pc_cassette_t *cas);
|
||||
* @short Set the cassette file
|
||||
* @return True on error, false otherwise
|
||||
*****************************************************************************/
|
||||
int pc_cas_set_fname(pc_cassette_t *cas, const char *fname);
|
||||
int pc_cas_set_fname(pc_cassette_t *cas, char *fname);
|
||||
|
||||
/*!***************************************************************************
|
||||
* @short Get the cassette mode
|
||||
|
||||
@@ -29,8 +29,9 @@
|
||||
#define CD_STATUS_STOPPED 6
|
||||
#define CD_STATUS_PLAYING_COMPLETED 7
|
||||
#define CD_STATUS_HOLD 8
|
||||
#define CD_STATUS_DVD_REJECTED 16
|
||||
#define CD_STATUS_HAS_AUDIO 0xc
|
||||
#define CD_STATUS_MASK 0xf
|
||||
#define CD_STATUS_MASK 0x1f
|
||||
|
||||
/* Medium changed flag. */
|
||||
#define CD_STATUS_TRANSITION 0x40
|
||||
@@ -69,6 +70,8 @@
|
||||
|
||||
#define CD_FPS 75
|
||||
|
||||
#define _LUT_SIZE 0x100
|
||||
|
||||
#define FRAMES_TO_MSF(f, M, S, F) \
|
||||
{ \
|
||||
uint64_t value = f; \
|
||||
@@ -91,13 +94,19 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
enum {
|
||||
CDROM_BUS_DISABLED = 0,
|
||||
CDROM_BUS_ATAPI = 5,
|
||||
CDROM_BUS_SCSI = 6,
|
||||
CDROM_BUS_MITSUMI = 7,
|
||||
CDROM_BUS_USB = 8
|
||||
CDROM_BUS_DISABLED = 0,
|
||||
CDROM_BUS_PHILIPS = 1,
|
||||
CDROM_BUS_SONY = 2,
|
||||
CDROM_BUS_HITACHI = 3,
|
||||
CDROM_BUS_MKE = 4,
|
||||
CDROM_BUS_MITSUMI = 5,
|
||||
CDROM_BUS_LPT = 6,
|
||||
CDROM_BUS_ATAPI = 8,
|
||||
CDROM_BUS_SCSI = 9,
|
||||
CDROM_BUS_USB = 10
|
||||
};
|
||||
|
||||
#define BUS_TYPE_MKE CDROM_BUS_MKE
|
||||
#define BUS_TYPE_IDE CDROM_BUS_ATAPI
|
||||
#define BUS_TYPE_SCSI CDROM_BUS_SCSI
|
||||
#define BUS_TYPE_BOTH -2
|
||||
@@ -116,107 +125,112 @@ static const struct cdrom_drive_types_s {
|
||||
const int speed;
|
||||
const int inquiry_len;
|
||||
const int caddy;
|
||||
const int is_dvd;
|
||||
const int transfer_max[4];
|
||||
} cdrom_drive_types[] = {
|
||||
{ EMU_NAME, "86B_CD", CDV, "86cd", BUS_TYPE_BOTH, 2, -1, 36, 0, { 4, 2, 2, 5 } },
|
||||
{ EMU_NAME, "86B_CD", CDV, "86cd", BUS_TYPE_BOTH, 2, -1, 36, 0, 0, { 4, 2, 2, 5 } },
|
||||
/* SCSI-1 / early ATAPI generic - second on purpose so the later variant is the default. */
|
||||
{ EMU_NAME, "86B_CD", "1.00", "86cd100", BUS_TYPE_BOTH, 1, -1, 36, 1, { 0, -1, -1, -1 } },
|
||||
{ EMU_NAME, "86B_CD", "1.00", "86cd100", BUS_TYPE_BOTH, 1, -1, 36, 1, 0, { 0, -1, -1, -1 } },
|
||||
/* No difference from 86BOX CD-ROM, other than name - but enough people have requested such a name to warrant it. */
|
||||
{ EMU_NAME, "86B_DVD", "4.30", "86dvd", BUS_TYPE_BOTH, 2, -1, 36, 0, { 4, 2, 2, 5 } },
|
||||
{ "ASUS", "CD-S500/A", "1.41", "asus_500", BUS_TYPE_IDE, 0, 50, 36, 0, { 4, 2, 2, 2 } },
|
||||
{ "ASUS", "CD-S520/A4", "1.32", "asus_520", BUS_TYPE_IDE, 0, 52, 36, 0, { 4, 2, 2, 2 } },
|
||||
{ "AZT", "CDA46802I", "1.15", "azt_cda", BUS_TYPE_IDE, 0, 4, 36, 0, { 3, 0, 0, 0 } },
|
||||
{ "BTC", "CD-ROM BCD36XH", "U1.0", "btc_36xh", BUS_TYPE_IDE, 0, 36, 36, 0, { 4, 2, 2, -1 } },
|
||||
{ "GOLDSTAR", "CRD-8160B", "3.14", "goldstar", BUS_TYPE_IDE, 0, 16, 36, 0, { 4, 2, 2, -1 } },
|
||||
{ EMU_NAME, "86B_DVD", "5.00", "86dvd", BUS_TYPE_BOTH, 2, -1, 36, 0, 1, { 4, 2, 2, 5 } },
|
||||
{ "ASUS", "CD-S500/A", "1.41", "asus_500", BUS_TYPE_IDE, 0, 50, 36, 0, 0, { 4, 2, 2, 2 } },
|
||||
{ "ASUS", "CD-S520/A4", "1.32", "asus_520", BUS_TYPE_IDE, 0, 52, 36, 0, 0, { 4, 2, 2, 2 } },
|
||||
{ "AZT", "CDA46802I", "1.15", "azt_cda", BUS_TYPE_IDE, 0, 4, 36, 0, 0, { 3, 0, 0, 0 } },
|
||||
{ "BTC", "CD-ROM BCD36XH", "U1.0", "btc_36xh", BUS_TYPE_IDE, 0, 36, 36, 0, 0, { 4, 2, 2, -1 } },
|
||||
{ "GOLDSTAR", "CRD-8160B", "3.14", "goldstar", BUS_TYPE_IDE, 0, 16, 36, 0, 0, { 4, 2, 2, -1 } },
|
||||
/* TODO: Find an IDENTIFY and/or INQUIRY dump. */
|
||||
{ "GOLDSTAR", "GCD-R560B", "1.00", "goldstar", BUS_TYPE_IDE, 0, 6, 36, 0, { 4, 2, 2, -1 } },
|
||||
{ "HITACHI", "CDR-8130", "0020", "hitachi_r8130", BUS_TYPE_IDE, 0, 16, 36, 0, { 4, 2, 2, -1 } },
|
||||
{ "HITACHI", "GD-7500", "A1 ", "hitachi_7500", BUS_TYPE_IDE, 0, 40, 36, 0, { 4, 2, 2, 2 } }, /* DVD. */
|
||||
{ "HL-DT-ST", "CD-ROM GCR-8526B", "1.01", "hldtst_8526b", BUS_TYPE_IDE, 0, 52, 36, 0, { 4, 2, 2, 2 } },
|
||||
{ "HL-DT-ST", "DVDRAM GSA-4160", "A302", "hldtst_4160", BUS_TYPE_IDE, 0, 40, 36, 0, { 4, 2, 2, 2 } },
|
||||
{ "KENWOOD", "CD-ROM UCR-421", "208E", "kenwood_421", BUS_TYPE_IDE, 0, 72, 36, 0, { 4, 2, 2, 4 } },
|
||||
{ "GOLDSTAR", "GCD-R560B", "1.00", "goldstar", BUS_TYPE_IDE, 0, 6, 36, 0, 0, { 4, 2, 2, -1 } },
|
||||
{ "HITACHI", "CDR-8130", "0020", "hitachi_r8130", BUS_TYPE_IDE, 0, 16, 36, 0, 0, { 4, 2, 2, -1 } },
|
||||
{ "HITACHI", "GD-7500", "A1 ", "hitachi_7500", BUS_TYPE_IDE, 0, 40, 36, 0, 0, { 4, 2, 2, 2 } }, /* DVD. */
|
||||
{ "HL-DT-ST", "CD-ROM GCR-8526B", "1.01", "hldtst_8526b", BUS_TYPE_IDE, 0, 52, 36, 0, 0, { 4, 2, 2, 2 } },
|
||||
{ "HL-DT-ST", "DVDRAM GSA-4160", "A302", "hldtst_4160", BUS_TYPE_IDE, 0, 40, 36, 0, 0, { 4, 2, 2, 2 } },
|
||||
{ "KENWOOD", "CD-ROM UCR-421", "208E", "kenwood_421", BUS_TYPE_IDE, 0, 72, 36, 0, 0, { 4, 2, 2, 4 } },
|
||||
/*
|
||||
This is a laptop/notebook drive, as is also evident from the name:
|
||||
CRN = Notebook, CRD = Desktop.
|
||||
*/
|
||||
{ "LG", "CD-ROM CRN-8245B", "1.30", "lg_8245b", BUS_TYPE_IDE, 0, 24, 36, 0, { 4, 2, 2, -1 } },
|
||||
{ "LG", "CD-ROM CRD-8322B", "1.06", "lg_8322b", BUS_TYPE_IDE, 0, 32, 36, 0, { 4, 2, 2, -1 } },
|
||||
{ "LG", "CD-ROM CRN-8245B", "1.30", "lg_8245b", BUS_TYPE_IDE, 0, 24, 36, 0, 0, { 4, 2, 2, -1 } },
|
||||
{ "LG", "CD-ROM CRD-8322B", "1.06", "lg_8322b", BUS_TYPE_IDE, 0, 32, 36, 0, 0, { 4, 2, 2, -1 } },
|
||||
/* Nothing on Google, deduced 48x from the name. */
|
||||
{ "LITE-ON", "LTN48125S", "1S07", "liteon_48125s", BUS_TYPE_IDE, 0, 48, 36, 0, { 4, 2, 2, 2 } },
|
||||
{ "LITE-ON", "LTN48125S", "1S07", "liteon_48125s", BUS_TYPE_IDE, 0, 48, 36, 0, 0, { 4, 2, 2, 2 } },
|
||||
/* Confirmed to be 52x, was the basis for deducing the other one's speed. */
|
||||
{ "LITE-ON", "LTN526D", "YSR5", "liteon_526d", BUS_TYPE_IDE, 0, 52, 36, 0, { 4, 2, 2, 2 } },
|
||||
{ "MATSHITA", "CD-ROM CR-583", "1.07", "matshita_583", BUS_TYPE_IDE, 0, 8, 36, 0, { 4, 2, 2, -1 } },
|
||||
{ "MATSHITA", "CD-ROM CR-585", "Z18P", "matshita_585", BUS_TYPE_IDE, 0, 24, 36, 0, { 4, 2, 2, -1 } },
|
||||
{ "MATSHITA", "CD-ROM CR-587", "7S13", "matshita_587", BUS_TYPE_IDE, 0, 24, 36, 0, { 4, 2, 2, -1 } },
|
||||
{ "MATSHITA", "CD-ROM CR-588", "LS15", "matshita_588", BUS_TYPE_IDE, 0, 32, 36, 0, { 4, 2, 2, -1 } },
|
||||
{ "MATSHITA", "CR-571", "1.0e", "matshita_571", BUS_TYPE_IDE, 0, 2, 36, 0, { 0, -1, -1, -1 } },
|
||||
{ "MATSHITA", "CR-572", "1.0j", "matshita_572", BUS_TYPE_IDE, 0, 4, 36, 0, { 0, -1, -1, -1 } },
|
||||
{ "MITSUMI", "CRMC-FX4820T", "D02A", "mitsumi_4820t", BUS_TYPE_IDE, 0, 48, 36, 0, { 4, 2, 2, 2 } },
|
||||
{ "LITE-ON", "LTN526D", "YSR5", "liteon_526d", BUS_TYPE_IDE, 0, 52, 36, 0, 0, { 4, 2, 2, 2 } },
|
||||
{ "MATSHITA", "CD-ROM CR-583", "1.07", "matshita_583", BUS_TYPE_IDE, 0, 8, 36, 0, 0, { 4, 2, 2, -1 } },
|
||||
{ "MATSHITA", "CD-ROM CR-585", "Z18P", "matshita_585", BUS_TYPE_IDE, 0, 24, 36, 0, 0, { 4, 2, 2, -1 } },
|
||||
{ "MATSHITA", "CD-ROM CR-587", "7S13", "matshita_587", BUS_TYPE_IDE, 0, 24, 36, 0, 0, { 4, 2, 2, -1 } },
|
||||
{ "MATSHITA", "CD-ROM CR-588", "LS15", "matshita_588", BUS_TYPE_IDE, 0, 32, 36, 0, 0, { 4, 2, 2, -1 } },
|
||||
{ "MATSHITA", "CR-571", "1.0e", "matshita_571", BUS_TYPE_IDE, 0, 2, 36, 0, 0, { 0, -1, -1, -1 } },
|
||||
{ "MATSHITA", "CR-572", "1.0j", "matshita_572", BUS_TYPE_IDE, 0, 4, 36, 0, 0, { 0, -1, -1, -1 } },
|
||||
{ "MITSUMI", "CRMC-FX4820T", "D02A", "mitsumi_4820t", BUS_TYPE_IDE, 0, 48, 36, 0, 0, { 4, 2, 2, 2 } },
|
||||
/* TODO: Find an IDENTIFY and/or INQUIRY dump. */
|
||||
{ "MITSUMI", "CRMC-FX810T4", "????", "mitsumi_810t4", BUS_TYPE_IDE, 0, 8, 36, 0, { 4, 2, 2, -1 } },
|
||||
{ "NEC", "CD-ROM DRIVE:260", "1.00", "nec_260_early", BUS_TYPE_IDE, 1, 2, 36, 1, { 0, -1, -1, -1 } },
|
||||
{ "NEC", "CD-ROM DRIVE:260", "1.01", "nec_260", BUS_TYPE_IDE, 1, 4, 36, 1, { 0, -1, -1, -1 } },
|
||||
{ "NEC", "CD-ROM DRIVE:273", "4.20", "nec_273", BUS_TYPE_IDE, 0, 4, 36, 0, { 0, -1, -1, -1 } },
|
||||
{ "NEC", "CD-ROM DRIVE:280", "1.05", "nec_280_early", BUS_TYPE_IDE, 0, 6, 36, 1, { 4, 2, 2, -1 } },
|
||||
{ "NEC", "CD-ROM DRIVE:280", "3.08", "nec_280", BUS_TYPE_IDE, 0, 8, 36, 1, { 4, 2, 2, -1 } },
|
||||
{ "NEC", "CDR-1300A", "1.05", "nec_1300a", BUS_TYPE_IDE, 0, 6, 36, 0, { 4, 2, 2, -1 } },
|
||||
{ "NEC", "CDR-1900A", "1.00", "nec_1900a", BUS_TYPE_IDE, 0, 32, 36, 0, { 4, 2, 2, -1 } },
|
||||
{ "PHILIPS", "CD-ROM PCA403CD", "U31P", "philips_403", BUS_TYPE_IDE, 0, 40, 36, 0, { 4, 2, 2, -1 } },
|
||||
{ "SONY", "CD-ROM CDU76", "1.0i", "sony_76", BUS_TYPE_IDE, 0, 4, 36, 0, { 2, -1, -1, -1 } },
|
||||
{ "SONY", "CD-ROM CDU311", "3.0h", "sony_311", BUS_TYPE_IDE, 0, 8, 36, 0, { 3, 2, 1, -1 } },
|
||||
{ "SONY", "CD-ROM CDU5225", "NYS4", "sony_5225", BUS_TYPE_IDE, 0, 52, 36, 0, { 4, 2, 2, 4 } },
|
||||
{ "TEAC", "CD-516E", "1.0G", "teac_516e", BUS_TYPE_IDE, 0, 16, 36, 0, { 3, 2, 2, -1 } },
|
||||
{ "TEAC", "CD-524EA", "3.0D", "teac_524ea", BUS_TYPE_IDE, 0, 24, 36, 0, { 3, 2, 2, -1 } },
|
||||
{ "TEAC", "CD-532E", "2.0A", "teac_532e", BUS_TYPE_IDE, 0, 32, 36, 0, { 3, 2, 2, -1 } },
|
||||
{ "TOSHIBA", "CD-ROM XM-5302TA", "0305", "toshiba_5302ta", BUS_TYPE_IDE, 0, 4, 96, 0, { 0, -1, -1, -1 } },
|
||||
{ "TOSHIBA", "CD-ROM XM-5702B", "TA70", "toshiba_5702b", BUS_TYPE_IDE, 0, 12, 96, 0, { 3, 2, 1, -1 } },
|
||||
{ "TOSHIBA", "CD-ROM XM-6202B", "1512", "toshiba_6202b", BUS_TYPE_IDE, 0, 32, 96, 0, { 4, 2, 2, -1 } },
|
||||
{ "TOSHIBA", "CD-ROM XM-6402B", "1008", "toshiba_6402b", BUS_TYPE_IDE, 0, 32, 96, 0, { 4, 2, 2, 2 } },
|
||||
{ "TOSHIBA", "CD-ROM XM-6702B", "1007", "toshiba_6720b", BUS_TYPE_IDE, 0, 48, 96, 0, { 4, 2, 2, 2 } },
|
||||
{ "TOSHIBA", "DVD-ROM SD-M1802", "1051", "toshiba_m1802", BUS_TYPE_IDE, 0, 48, 96, 0, { 4, 2, 2, 2 } },
|
||||
{ "CHINON", "CD-ROM CDS-431", "H42 ", "chinon_431", BUS_TYPE_SCSI, 1, 1, 36, 1, { -1, -1, -1, -1 } },
|
||||
{ "CHINON", "CD-ROM CDX-435", "M62 ", "chinon_435", BUS_TYPE_SCSI, 1, 2, 36, 1, { -1, -1, -1, -1 } },
|
||||
{ "DEC", "RRD45 (C) DEC", "0436", "dec_45", BUS_TYPE_SCSI, 1, 4, 36, 0, { -1, -1, -1, -1 } },
|
||||
{ "MATSHITA", "CD-ROM CR-501", "1.0b", "matshita_501", BUS_TYPE_SCSI, 1, 1, 36, 1, { -1, -1, -1, -1 } },
|
||||
{ "NEC", "CD-ROM DRIVE:25", "1.0a", "nec_25", BUS_TYPE_SCSI, 1, 2, 36, 0, { -1, -1, -1, -1 } },
|
||||
{ "NEC", "CD-ROM DRIVE:38", "1.00", "nec_38", BUS_TYPE_SCSI, 2, 1, 36, 0, { -1, -1, -1, -1 } },
|
||||
{ "MITSUMI", "CRMC-FX810T4", "????", "mitsumi_810t4", BUS_TYPE_IDE, 0, 8, 36, 0, 0, { 4, 2, 2, -1 } },
|
||||
{ "NEC", "CD-ROM DRIVE:260", "1.00", "nec_260_early", BUS_TYPE_IDE, 1, 2, 36, 1, 0, { 0, -1, -1, -1 } },
|
||||
{ "NEC", "CD-ROM DRIVE:260", "1.01", "nec_260", BUS_TYPE_IDE, 1, 4, 36, 1, 0, { 0, -1, -1, -1 } },
|
||||
{ "NEC", "CD-ROM DRIVE:273", "4.20", "nec_273", BUS_TYPE_IDE, 0, 4, 36, 0, 0, { 0, -1, -1, -1 } },
|
||||
{ "NEC", "CD-ROM DRIVE:280", "1.05", "nec_280_early", BUS_TYPE_IDE, 0, 6, 36, 1, 0, { 4, 2, 2, -1 } },
|
||||
{ "NEC", "CD-ROM DRIVE:280", "3.08", "nec_280", BUS_TYPE_IDE, 0, 8, 36, 1, 0, { 4, 2, 2, -1 } },
|
||||
{ "NEC", "CDR-1300A", "1.05", "nec_1300a", BUS_TYPE_IDE, 0, 6, 36, 0, 0, { 4, 2, 2, -1 } },
|
||||
{ "NEC", "CDR-1900A", "1.00", "nec_1900a", BUS_TYPE_IDE, 0, 32, 36, 0, 0, { 4, 2, 2, -1 } },
|
||||
{ "PHILIPS", "CD-ROM PCA403CD", "U31P", "philips_403", BUS_TYPE_IDE, 0, 40, 36, 0, 0, { 4, 2, 2, -1 } },
|
||||
{ "SONY", "CD-ROM CDU76", "1.0i", "sony_76", BUS_TYPE_IDE, 0, 4, 36, 0, 0, { 2, -1, -1, -1 } },
|
||||
{ "SONY", "CD-ROM CDU311", "3.0h", "sony_311", BUS_TYPE_IDE, 0, 8, 36, 0, 0, { 3, 2, 1, -1 } },
|
||||
{ "SONY", "CD-ROM CDU5225", "NYS4", "sony_5225", BUS_TYPE_IDE, 0, 52, 36, 0, 0, { 4, 2, 2, 4 } },
|
||||
{ "TEAC", "CD-516E", "1.0G", "teac_516e", BUS_TYPE_IDE, 0, 16, 36, 0, 0, { 3, 2, 2, -1 } },
|
||||
{ "TEAC", "CD-524EA", "3.0D", "teac_524ea", BUS_TYPE_IDE, 0, 24, 36, 0, 0, { 3, 2, 2, -1 } },
|
||||
{ "TEAC", "CD-532E", "2.0A", "teac_532e", BUS_TYPE_IDE, 0, 32, 36, 0, 0, { 3, 2, 2, -1 } },
|
||||
{ "TOSHIBA", "CD-ROM XM-5302TA", "0305", "toshiba_5302ta", BUS_TYPE_IDE, 0, 4, 96, 0, 0, { 0, -1, -1, -1 } },
|
||||
{ "TOSHIBA", "CD-ROM XM-5702B", "TA70", "toshiba_5702b", BUS_TYPE_IDE, 0, 12, 96, 0, 0, { 3, 2, 1, -1 } },
|
||||
{ "TOSHIBA", "CD-ROM XM-6202B", "1512", "toshiba_6202b", BUS_TYPE_IDE, 0, 32, 96, 0, 0, { 4, 2, 2, -1 } },
|
||||
{ "TOSHIBA", "CD-ROM XM-6402B", "1008", "toshiba_6402b", BUS_TYPE_IDE, 0, 32, 96, 0, 0, { 4, 2, 2, 2 } },
|
||||
{ "TOSHIBA", "CD-ROM XM-6702B", "1007", "toshiba_6720b", BUS_TYPE_IDE, 0, 48, 96, 0, 0, { 4, 2, 2, 2 } },
|
||||
{ "TOSHIBA", "DVD-ROM SD-M1802", "1051", "toshiba_m1802", BUS_TYPE_IDE, 0, 48, 96, 0, 1, { 4, 2, 2, 2 } },
|
||||
{ "CHINON", "CD-ROM CDS-431", "H42 ", "chinon_431", BUS_TYPE_SCSI, 1, 1, 36, 1, 0, { -1, -1, -1, -1 } },
|
||||
{ "CHINON", "CD-ROM CDX-435", "M62 ", "chinon_435", BUS_TYPE_SCSI, 1, 2, 36, 1, 0, { -1, -1, -1, -1 } },
|
||||
{ "DEC", "RRD45 (C) DEC", "0436", "dec_45", BUS_TYPE_SCSI, 1, 4, 36, 0, 0, { -1, -1, -1, -1 } },
|
||||
{ "MATSHITA", "CD-ROM CR-501", "1.0b", "matshita_501", BUS_TYPE_SCSI, 1, 1, 36, 1, 0, { -1, -1, -1, -1 } },
|
||||
{ "NEC", "CD-ROM DRIVE:25", "1.0a", "nec_25", BUS_TYPE_SCSI, 1, 2, 36, 0, 0, { -1, -1, -1, -1 } },
|
||||
{ "NEC", "CD-ROM DRIVE:38", "1.00", "nec_38", BUS_TYPE_SCSI, 2, 1, 36, 0, 0, { -1, -1, -1, -1 } },
|
||||
/* The speed of the following two is guesswork based on the CDR-74. */
|
||||
{ "NEC", "CD-ROM DRIVE:75", "1.03", "nec_75", BUS_TYPE_SCSI, 1, 1, 36, 1, { -1, -1, -1, -1 } },
|
||||
{ "NEC", "CD-ROM DRIVE:77", "1.06", "nec_77", BUS_TYPE_SCSI, 1, 1, 36, 1, { -1, -1, -1, -1 } },
|
||||
{ "NEC", "CD-ROM DRIVE:211", "1.00", "nec_211", BUS_TYPE_SCSI, 2, 3, 36, 0, { -1, -1, -1, -1 } },
|
||||
{ "NEC", "CD-ROM DRIVE:75", "1.03", "nec_75", BUS_TYPE_SCSI, 1, 1, 36, 1, 0, { -1, -1, -1, -1 } },
|
||||
{ "NEC", "CD-ROM DRIVE:77", "1.06", "nec_77", BUS_TYPE_SCSI, 1, 1, 36, 1, 0, { -1, -1, -1, -1 } },
|
||||
{ "NEC", "CD-ROM DRIVE:211", "1.00", "nec_211", BUS_TYPE_SCSI, 2, 3, 36, 0, 0, { -1, -1, -1, -1 } },
|
||||
/* The speed of the following two is guesswork based on the CDR-400. */
|
||||
{ "NEC", "CD-ROM DRIVE:464", "1.05", "nec_464", BUS_TYPE_SCSI, 2, 3, 36, 0, { -1, -1, -1, -1 } },
|
||||
{ "NEC", "CD-ROM DRIVE:464", "1.05", "nec_464", BUS_TYPE_SCSI, 2, 3, 36, 0, 0, { -1, -1, -1, -1 } },
|
||||
/* The speed of the following two is guesswork based on the name. */
|
||||
{ "ShinaKen", "CD-ROM DM-3x1S", "1.04", "shinaken_3x1s", BUS_TYPE_SCSI, 1, 3, 36, 0, { -1, -1, -1, -1 } },
|
||||
{ "SONY", "CD-ROM CDU-541", "1.0i", "sony_541", BUS_TYPE_SCSI, 1, 1, 36, 1, { -1, -1, -1, -1 } },
|
||||
{ "SONY", "CD-ROM CDU-561", "1.8k", "sony_561", BUS_TYPE_SCSI, 2, 2, 36, 1, { -1, -1, -1, -1 } },
|
||||
{ "SONY", "CD-ROM CDU-76S", "1.00", "sony_76s", BUS_TYPE_SCSI, 2, 4, 36, 0, { -1, -1, -1, -1 } },
|
||||
{ "PHILIPS", "CDD2600", "1.07", "philips_2600", BUS_TYPE_SCSI, 2, 6, 36, 0, { -1, -1, -1, -1 } },
|
||||
{ "ShinaKen", "CD-ROM DM-3x1S", "1.04", "shinaken_3x1s", BUS_TYPE_SCSI, 1, 3, 36, 0, 0, { -1, -1, -1, -1 } },
|
||||
{ "SONY", "CD-ROM CDU-541", "1.0i", "sony_541", BUS_TYPE_SCSI, 1, 1, 36, 1, 0, { -1, -1, -1, -1 } },
|
||||
{ "SONY", "CD-ROM CDU-561", "1.8k", "sony_561", BUS_TYPE_SCSI, 2, 2, 36, 1, 0, { -1, -1, -1, -1 } },
|
||||
{ "SONY", "CD-ROM CDU-76S", "1.00", "sony_76s", BUS_TYPE_SCSI, 2, 4, 36, 0, 0, { -1, -1, -1, -1 } },
|
||||
{ "PHILIPS", "CDD2600", "1.07", "philips_2600", BUS_TYPE_SCSI, 2, 6, 36, 0, 0, { -1, -1, -1, -1 } },
|
||||
/* NOTE: The real thing is a CD changer drive! */
|
||||
{ "PIONEER", "CD-ROM DRM-604X", "2403", "pioneer_604x", BUS_TYPE_SCSI, 2, 4, 47, 0, { -1, -1, -1, -1 } },
|
||||
{ "PLEXTOR", "CD-ROM PX-32TS", "1.03", "plextor_32ts", BUS_TYPE_SCSI, 2, 32, 36, 0, { -1, -1, -1, -1 } },
|
||||
{ "PIONEER", "CD-ROM DRM-604X", "2403", "pioneer_604x", BUS_TYPE_SCSI, 2, 4, 47, 0, 0, { -1, -1, -1, -1 } },
|
||||
{ "PLEXTOR", "CD-ROM PX-32TS", "1.03", "plextor_32ts", BUS_TYPE_SCSI, 2, 32, 36, 0, 0, { -1, -1, -1, -1 } },
|
||||
/* The speed of the following two is guesswork based on the R55S. */
|
||||
{ "TEAC", "CD 50", "1.00", "teac_50", BUS_TYPE_SCSI, 2, 4, 36, 1, { -1, -1, -1, -1 } },
|
||||
{ "TEAC", "CD-ROM R55S", "1.0R", "teac_55s", BUS_TYPE_SCSI, 2, 4, 36, 0, { -1, -1, -1, -1 } },
|
||||
{ "TEAC", "CD 50", "1.00", "teac_50", BUS_TYPE_SCSI, 2, 4, 36, 1, 0, { -1, -1, -1, -1 } },
|
||||
{ "TEAC", "CD-ROM R55S", "1.0R", "teac_55s", BUS_TYPE_SCSI, 2, 4, 36, 0, 0, { -1, -1, -1, -1 } },
|
||||
/* Texel is Plextor according to Plextor's own EU website. */
|
||||
{ "TEXEL", "CD-ROM DM-3024", "1.00", "texel_3024", BUS_TYPE_SCSI, 2, 2, 36, 1, { -1, -1, -1, -1 } },
|
||||
{ "TEXEL", "CD-ROM DM-3024", "1.00", "texel_3024", BUS_TYPE_SCSI, 2, 2, 36, 1, 0, { -1, -1, -1, -1 } },
|
||||
/*
|
||||
Unusual 2.23x according to Google, I'm rounding it upwards to 3x.
|
||||
Assumed caddy based on the DM-3024.
|
||||
*/
|
||||
{ "TEXEL", "CD-ROM DM-3028", "1.06", "texel_3028", BUS_TYPE_SCSI, 2, 3, 36, 1, { -1, -1, -1, -1 } }, /* Caddy. */
|
||||
{ "TEXEL", "CD-ROM DM-3028", "1.06", "texel_3028", BUS_TYPE_SCSI, 2, 3, 36, 1, 0, { -1, -1, -1, -1 } }, /* Caddy. */
|
||||
/*
|
||||
The characteristics are a complete guesswork because I can't find
|
||||
this one on Google.
|
||||
|
||||
Also, INQUIRY length is always 96 on these Toshiba drives.
|
||||
*/
|
||||
{ "TOSHIBA", "CD-ROM DRIVE:XM", "3433", "toshiba_xm", BUS_TYPE_SCSI, 2, 2, 96, 0, { -1, -1, -1, -1 } }, /* Tray. */
|
||||
{ "TOSHIBA", "CD-ROM XM-3201B", "3232", "toshiba_3201b", BUS_TYPE_SCSI, 1, 1, 96, 1, { -1, -1, -1, -1 } }, /* Caddy. */
|
||||
{ "TOSHIBA", "CD-ROM XM-3301TA", "0272", "toshiba_3301ta", BUS_TYPE_SCSI, 2, 2, 96, 0, { -1, -1, -1, -1 } }, /* Tray. */
|
||||
{ "TOSHIBA", "CD-ROM XM-5701TA", "3136", "toshiba_5701a", BUS_TYPE_SCSI, 2, 12, 96, 0, { -1, -1, -1, -1 } }, /* Tray. */
|
||||
{ "TOSHIBA", "DVD-ROM SD-M1401", "1008", "toshiba_m1401", BUS_TYPE_SCSI, 2, 40, 96, 0, { -1, -1, -1, -1 } }, /* Tray. */
|
||||
{ "", "", "", "", BUS_TYPE_NONE, 0, -1, 0, 0, { -1, -1, -1, -1 } }
|
||||
{ "TOSHIBA", "CD-ROM DRIVE:XM", "3433", "toshiba_xm", BUS_TYPE_SCSI, 2, 2, 96, 0, 0, { -1, -1, -1, -1 } }, /* Tray. */
|
||||
{ "TOSHIBA", "CD-ROM XM-3201B", "3232", "toshiba_3201b", BUS_TYPE_SCSI, 1, 1, 96, 1, 0, { -1, -1, -1, -1 } }, /* Caddy. */
|
||||
{ "TOSHIBA", "CD-ROM XM-3301TA", "0272", "toshiba_3301ta", BUS_TYPE_SCSI, 2, 2, 96, 0, 0, { -1, -1, -1, -1 } }, /* Tray. */
|
||||
{ "TOSHIBA", "CD-ROM XM-5701TA", "3136", "toshiba_5701a", BUS_TYPE_SCSI, 2, 12, 96, 0, 0, { -1, -1, -1, -1 } }, /* Tray. */
|
||||
{ "TOSHIBA", "DVD-ROM SD-M1401", "1008", "toshiba_m1401", BUS_TYPE_SCSI, 2, 40, 96, 0, 1, { -1, -1, -1, -1 } }, /* Tray. */
|
||||
{ "MATSHITA", "CR-562", "0.75", "cr562", BUS_TYPE_MKE , 0, 2, 0, 0, 0, { -1, -1, -1, -1 } },
|
||||
{ "MATSHITA", "CR-562", "0.80", "cr562_080", BUS_TYPE_MKE , 0, 2, 0, 0, 0, { -1, -1, -1, -1 } },
|
||||
{ "MATSHITA", "CR-563", "0.75", "cr563", BUS_TYPE_MKE , 0, 2, 0, 0, 0, { -1, -1, -1, -1 } },
|
||||
{ "MATSHITA", "CR-563", "0.80", "cr563_080", BUS_TYPE_MKE , 0, 2, 0, 0, 0, { -1, -1, -1, -1 } },
|
||||
{ "", "", "", "", BUS_TYPE_NONE, 0, -1, 0, 0, 0, { -1, -1, -1, -1 } }
|
||||
};
|
||||
|
||||
/* To shut up the GCC compilers. */
|
||||
@@ -283,7 +297,7 @@ typedef struct cdrom {
|
||||
union {
|
||||
uint8_t res;
|
||||
uint8_t res0; /* Reserved for other ID's. */
|
||||
uint8_t res1;
|
||||
uint8_t mke_channel;
|
||||
uint8_t ide_channel;
|
||||
uint8_t scsi_device_id;
|
||||
};
|
||||
@@ -351,6 +365,13 @@ typedef struct cdrom {
|
||||
|
||||
/* Only used on Windows hosts for disc change notifications. */
|
||||
uint8_t host_letter;
|
||||
uint8_t mode2;
|
||||
|
||||
uint8_t _F_LUT[_LUT_SIZE];
|
||||
uint8_t _B_LUT[_LUT_SIZE];
|
||||
|
||||
uint8_t p_parity[172];
|
||||
uint8_t q_parity[104];
|
||||
} cdrom_t;
|
||||
|
||||
extern cdrom_t cdrom[CDROM_NUM];
|
||||
@@ -374,6 +395,7 @@ extern void cdrom_get_model(const int type, char *name, const int id)
|
||||
extern char *cdrom_get_revision(const int type);
|
||||
extern int cdrom_get_scsi_std(const int type);
|
||||
extern int cdrom_is_early(const int type);
|
||||
extern int cdrom_is_dvd(const int type);
|
||||
extern int cdrom_is_generic(const int type);
|
||||
extern int cdrom_is_caddy(const int type);
|
||||
extern int cdrom_get_speed(const int type);
|
||||
@@ -381,6 +403,7 @@ extern int cdrom_get_inquiry_len(const int type);
|
||||
extern int cdrom_has_dma(const int type);
|
||||
extern int cdrom_get_transfer_max(const int type, const int mode);
|
||||
extern int cdrom_get_type_count(void);
|
||||
extern void cdrom_generate_name_mke(const int type, char *name);
|
||||
extern void cdrom_get_identify_model(const int type, char *name, const int id);
|
||||
extern void cdrom_get_name(const int type, char *name);
|
||||
extern char *cdrom_get_internal_name(const int type);
|
||||
@@ -448,6 +471,12 @@ extern int cdrom_is_empty(const uint8_t id);
|
||||
extern void cdrom_eject(const uint8_t id);
|
||||
extern void cdrom_reload(const uint8_t id);
|
||||
|
||||
extern void cdrom_compute_ecc_block(cdrom_t *dev, uint8_t *parity, const uint8_t *data,
|
||||
uint32_t major_count, uint32_t minor_count,
|
||||
uint32_t major_mult, uint32_t minor_inc, int m2f1);
|
||||
extern unsigned long cdrom_crc32(unsigned long crc, const unsigned char *buf,
|
||||
size_t len);
|
||||
|
||||
extern int cdrom_assigned_letters;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
*
|
||||
* Mitsumi CD-ROM emulation for the ISA bus.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Jasmine Iwanek, <jriwanek@gmail.com>
|
||||
*
|
||||
* Copyright 2022 Miran Grca.
|
||||
* Copyright 2022 Miran Grca.
|
||||
* Copyright 2024-2025 Jasmine Iwanek.
|
||||
*/
|
||||
#ifndef CDROM_MITSUMI_H
|
||||
#define CDROM_MITSUMI_H
|
||||
|
||||
24
src/include/86box/cdrom_mke.h
Normal file
24
src/include/86box/cdrom_mke.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Panasonic/MKE CD-ROM emulation for the ISA bus.
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Cacodemon345
|
||||
*
|
||||
* Copyright 2022-2025 Miran Grca.
|
||||
* Copyright 2025 Cacodemon345.
|
||||
*/
|
||||
|
||||
#ifndef CDROM_MKE_H
|
||||
#define CDROM_MKE_H
|
||||
|
||||
extern const device_t mke_cdrom_device;
|
||||
extern const device_t mke_cdrom_noncreative_device;
|
||||
|
||||
#endif /*CDROM_MKE_H*/
|
||||
@@ -133,7 +133,7 @@ typedef struct config_t {
|
||||
|
||||
/* Other removable devices category */
|
||||
storage_cfg_t cdrom[CDROM_NUM]; /* CD-ROM drives */
|
||||
storage_cfg_t rdisk[ZIP_NUM]; /* Removable disk drives */
|
||||
storage_cfg_t rdisk[RDISK_NUM]; /* Removable disk drives */
|
||||
} config_t;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -223,6 +223,11 @@ extern uint8_t fdc_get_diswr(fdc_t *fdc);
|
||||
extern void fdc_set_diswr(fdc_t *fdc, uint8_t diswr);
|
||||
extern uint8_t fdc_get_swap(fdc_t *fdc);
|
||||
extern void fdc_set_swap(fdc_t *fdc, uint8_t swap);
|
||||
extern void fdc_set_flags(fdc_t *fdc, int flags);
|
||||
extern void fdc_clear_flags(fdc_t *fdc, int flags);
|
||||
extern void fdc_set_fdd_changed(int drive, int changed);
|
||||
extern uint8_t fdc_get_fdd_changed(int drive);
|
||||
extern uint8_t fdc_get_shadow(fdc_t *fdc);
|
||||
|
||||
extern void fdc_finishcompare(fdc_t *fdc, int satisfying);
|
||||
extern void fdc_finishread(fdc_t *fdc);
|
||||
|
||||
@@ -51,8 +51,9 @@
|
||||
#define GAMEPORT_6ADDR 0x060000
|
||||
#define GAMEPORT_8ADDR 0x080000
|
||||
#define GAMEPORT_SIO 0x1000000
|
||||
#define GAMEPORT_PNPROM 0x2000000
|
||||
|
||||
typedef struct joystick_if_t {
|
||||
typedef struct joystick_t {
|
||||
const char *name;
|
||||
const char *internal_name;
|
||||
|
||||
@@ -70,9 +71,9 @@ typedef struct joystick_if_t {
|
||||
const char *axis_names[MAX_JOY_AXES];
|
||||
const char *button_names[MAX_JOY_BUTTONS];
|
||||
const char *pov_names[MAX_JOY_POVS];
|
||||
} joystick_if_t;
|
||||
} joystick_t;
|
||||
|
||||
typedef struct plat_joystick_t {
|
||||
typedef struct plat_joystick_state_t {
|
||||
char name[260];
|
||||
|
||||
int a[MAX_JOY_AXES];
|
||||
@@ -97,9 +98,9 @@ typedef struct plat_joystick_t {
|
||||
int nr_axes;
|
||||
int nr_buttons;
|
||||
int nr_povs;
|
||||
} plat_joystick_t;
|
||||
} plat_joystick_state_t;
|
||||
|
||||
typedef struct joystick_t {
|
||||
typedef struct joystick_state_t {
|
||||
int axis[MAX_JOY_AXES];
|
||||
int button[MAX_JOY_BUTTONS];
|
||||
int pov[MAX_JOY_POVS];
|
||||
@@ -108,7 +109,7 @@ typedef struct joystick_t {
|
||||
int axis_mapping[MAX_JOY_AXES];
|
||||
int button_mapping[MAX_JOY_BUTTONS];
|
||||
int pov_mapping[MAX_JOY_POVS][2];
|
||||
} joystick_t;
|
||||
} joystick_state_t;
|
||||
|
||||
extern device_t game_ports[GAMEPORT_MAX];
|
||||
|
||||
@@ -126,6 +127,7 @@ extern int gameport_get_from_internal_name(const char *str);
|
||||
|
||||
#ifdef EMU_DEVICE_H
|
||||
extern const device_t gameport_device;
|
||||
extern const device_t gameport_200_device;
|
||||
extern const device_t gameport_201_device;
|
||||
extern const device_t gameport_203_device;
|
||||
extern const device_t gameport_205_device;
|
||||
@@ -144,10 +146,10 @@ extern const device_t gameport_sio_1io_device;
|
||||
|
||||
extern const device_t *standalone_gameport_type;
|
||||
#endif
|
||||
extern int gameport_instance_id;
|
||||
extern plat_joystick_t plat_joystick_state[MAX_PLAT_JOYSTICKS];
|
||||
extern joystick_t joystick_state[GAMEPORT_MAX][MAX_JOYSTICKS];
|
||||
extern int joysticks_present;
|
||||
extern int gameport_instance_id;
|
||||
extern plat_joystick_state_t plat_joystick_state[MAX_PLAT_JOYSTICKS];
|
||||
extern joystick_state_t joystick_state[GAMEPORT_MAX][MAX_JOYSTICKS];
|
||||
extern int joysticks_present;
|
||||
|
||||
extern int joystick_type;
|
||||
|
||||
@@ -170,28 +172,28 @@ extern void gameport_update_joystick_type(void);
|
||||
extern void gameport_remap(void *priv, uint16_t address);
|
||||
extern void *gameport_add(const device_t *gameport_type);
|
||||
|
||||
extern const joystick_if_t joystick_2axis_2button;
|
||||
extern const joystick_if_t joystick_2button_gamepad;
|
||||
extern const joystick_if_t joystick_2button_flight_yoke;
|
||||
extern const joystick_if_t joystick_2axis_4button;
|
||||
extern const joystick_if_t joystick_4button_gamepad;
|
||||
extern const joystick_if_t joystick_4button_flight_yoke;
|
||||
extern const joystick_if_t joystick_3axis_2button;
|
||||
extern const joystick_if_t joystick_2button_yoke_throttle;
|
||||
extern const joystick_if_t joystick_3axis_4button;
|
||||
extern const joystick_if_t joystick_4button_yoke_throttle;
|
||||
extern const joystick_if_t joystick_win95_steering_wheel;
|
||||
extern const joystick_if_t joystick_4axis_4button;
|
||||
extern const joystick_if_t joystick_2axis_6button;
|
||||
extern const joystick_if_t joystick_2axis_8button;
|
||||
extern const joystick_t joystick_2axis_2button;
|
||||
extern const joystick_t joystick_2button_gamepad;
|
||||
extern const joystick_t joystick_2button_flight_yoke;
|
||||
extern const joystick_t joystick_2axis_4button;
|
||||
extern const joystick_t joystick_4button_gamepad;
|
||||
extern const joystick_t joystick_4button_flight_yoke;
|
||||
extern const joystick_t joystick_3axis_2button;
|
||||
extern const joystick_t joystick_2button_yoke_throttle;
|
||||
extern const joystick_t joystick_3axis_4button;
|
||||
extern const joystick_t joystick_4button_yoke_throttle;
|
||||
extern const joystick_t joystick_win95_steering_wheel;
|
||||
extern const joystick_t joystick_4axis_4button;
|
||||
extern const joystick_t joystick_2axis_6button;
|
||||
extern const joystick_t joystick_2axis_8button;
|
||||
|
||||
extern const joystick_if_t joystick_ch_flightstick_pro;
|
||||
extern const joystick_if_t joystick_ch_flightstick_pro_ch_pedals;
|
||||
extern const joystick_t joystick_ch_flightstick_pro;
|
||||
extern const joystick_t joystick_ch_flightstick_pro_ch_pedals;
|
||||
|
||||
extern const joystick_if_t joystick_sw_pad;
|
||||
extern const joystick_t joystick_sw_pad;
|
||||
|
||||
extern const joystick_if_t joystick_tm_fcs;
|
||||
extern const joystick_if_t joystick_tm_fcs_rcs;
|
||||
extern const joystick_t joystick_tm_fcs;
|
||||
extern const joystick_t joystick_tm_fcs_rcs;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#define HDC_NONE 0
|
||||
#define HDC_INTERNAL 1
|
||||
|
||||
#define HDC_MAX 2
|
||||
#define HDC_MAX 4
|
||||
|
||||
extern int hdc_current[HDC_MAX];
|
||||
|
||||
@@ -79,6 +79,9 @@ extern const device_t ide_cmd646_device; /* CMD PCI-646 *
|
||||
extern const device_t ide_cmd646_legacy_only_device; /* CMD PCI-646 (Legacy Mode Only) */
|
||||
extern const device_t ide_cmd646_single_channel_device; /* CMD PCI-646 (Only primary channel) */
|
||||
extern const device_t ide_cmd646_ter_qua_device; /* CMD PCI-646 (Tertiary and quaternary channels) */
|
||||
extern const device_t ide_cmd648_ter_qua_device; /* CMD PCI-648 (Tertiary and quaternary channels) */
|
||||
extern const device_t ide_cmd648_ter_qua_onboard_device; /* CMD PCI-648 (Tertiary and quaternary channels, on-board) */
|
||||
extern const device_t ide_cmd649_ter_qua_device; /* CMD PCI-649 (Tertiary and quaternary channels) */
|
||||
|
||||
extern const device_t ide_opti611_vlb_device; /* OPTi 82c611/611A VLB */
|
||||
extern const device_t ide_opti611_vlb_sec_device; /* OPTi 82c611/611A VLB (Secondary channel) */
|
||||
@@ -102,8 +105,10 @@ extern const device_t ide_qua_pnp_device;
|
||||
|
||||
extern const device_t mcide_device;
|
||||
|
||||
extern const device_t xta_wdxt150_device; /* xta_wdxt150 */
|
||||
extern const device_t xta_hd20_device; /* EuroPC internal */
|
||||
extern const device_t xta_wdxt150_device; /* xta_wdxt150 */
|
||||
extern const device_t xta_hd20_device; /* EuroPC internal */
|
||||
extern const device_t xta_st50x_device; /* ST-50X */
|
||||
extern const device_t xta_st50x_pc5086_device; /* ST-50X (PC-5086) */
|
||||
|
||||
extern const device_t xtide_device; /* xtide_xt */
|
||||
extern const device_t xtide_at_device; /* xtide_at */
|
||||
@@ -116,10 +121,12 @@ extern void hdc_init(void);
|
||||
extern void hdc_reset(void);
|
||||
|
||||
extern const char *hdc_get_internal_name(int hdc);
|
||||
extern int hdc_get_from_internal_name(char *s);
|
||||
extern int hdc_get_from_internal_name(const char *s);
|
||||
extern int hdc_has_config(int hdc);
|
||||
extern const device_t *hdc_get_device(int hdc);
|
||||
extern int hdc_get_flags(int hdc);
|
||||
extern int hdc_available(int hdc);
|
||||
|
||||
extern void xta_handler(void *priv, int set);
|
||||
|
||||
#endif /*EMU_HDC_H*/
|
||||
|
||||
@@ -178,9 +178,6 @@ enum {
|
||||
TIMINGS_PIO_FC = 2
|
||||
};
|
||||
|
||||
extern int ide_ter_enabled;
|
||||
extern int ide_qua_enabled;
|
||||
|
||||
#ifdef SCSI_DEVICE_H
|
||||
extern ide_t *ide_get_drive(int ch);
|
||||
extern void ide_irq(ide_t *ide, int set, int log);
|
||||
@@ -230,6 +227,8 @@ extern void ide_padstr8(uint8_t *buf, int buf_size, const char *src);
|
||||
extern uint8_t ide_read_ali_75(void);
|
||||
extern uint8_t ide_read_ali_76(void);
|
||||
|
||||
extern void ide_hard_reset(void);
|
||||
|
||||
/* Legacy #define's. */
|
||||
#define ide_irq_raise(ide) ide_irq(ide, 1, 1)
|
||||
#define ide_irq_lower(ide) ide_irq(ide, 0, 1)
|
||||
|
||||
@@ -56,6 +56,11 @@ typedef struct sff8038i_t
|
||||
int irq_level;
|
||||
int irq_pin;
|
||||
int pci_irq_line;
|
||||
|
||||
uint8_t (*ven_write)(uint16_t port, uint8_t val, void *priv);
|
||||
uint8_t (*ven_read)(uint16_t port, uint8_t val, void *priv);
|
||||
|
||||
void *priv;
|
||||
} sff8038i_t;
|
||||
|
||||
extern const device_t sff8038i_device;
|
||||
@@ -78,4 +83,7 @@ extern void sff_set_irq_pin(sff8038i_t *dev, int irq_pin);
|
||||
extern void sff_set_irq_level(sff8038i_t *dev, int irq_level);
|
||||
extern void sff_set_mirq(sff8038i_t *dev, uint8_t mirq);
|
||||
|
||||
extern void sff_set_ven_handlers(sff8038i_t *dev, uint8_t (*ven_write)(uint16_t port, uint8_t val, void *priv),
|
||||
uint8_t (*ven_read)(uint16_t port, uint8_t val, void *priv), void *priv);
|
||||
|
||||
#endif /*EMU_HDC_IDE_SFF8038I_H*/
|
||||
|
||||
@@ -67,14 +67,15 @@ enum {
|
||||
};
|
||||
#else
|
||||
enum {
|
||||
HDD_BUS_DISABLED = 0,
|
||||
HDD_BUS_MFM = 1,
|
||||
HDD_BUS_XTA = 2,
|
||||
HDD_BUS_ESDI = 3,
|
||||
HDD_BUS_IDE = 4,
|
||||
HDD_BUS_ATAPI = 5,
|
||||
HDD_BUS_SCSI = 6,
|
||||
HDD_BUS_USB = 7
|
||||
HDD_BUS_DISABLED = 0,
|
||||
HDD_BUS_MFM = 1,
|
||||
HDD_BUS_XTA = 2,
|
||||
HDD_BUS_ESDI = 3,
|
||||
HDD_BUS_LPT = 6,
|
||||
HDD_BUS_IDE = 7,
|
||||
HDD_BUS_ATAPI = 8,
|
||||
HDD_BUS_SCSI = 9,
|
||||
HDD_BUS_USB = 10
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -22,6 +22,21 @@
|
||||
#ifndef EMU_KEYBOARD_H
|
||||
#define EMU_KEYBOARD_H
|
||||
|
||||
#define FLAG_AT 0x00 /* dev is AT */
|
||||
#define FLAG_PS2_KBD 0x10 /* dev is AT or PS/2 */
|
||||
#define FLAG_AX 0x08 /* dev is AX */
|
||||
#define FLAG_TYPE_MASK 0x07 /* mask for type */
|
||||
|
||||
enum {
|
||||
KBD_83_KEY = 0,
|
||||
KBD_84_KEY,
|
||||
KBD_101_KEY,
|
||||
KBD_102_KEY,
|
||||
KBD_JIS,
|
||||
KBD_KSC,
|
||||
KBD_ABNT2
|
||||
};
|
||||
|
||||
enum {
|
||||
DEV_KBD = 0,
|
||||
DEV_AUX = 1
|
||||
@@ -38,6 +53,15 @@ enum {
|
||||
DEV_STATE_MAIN_WANT_EXECUTE_BAT = 7
|
||||
};
|
||||
|
||||
enum {
|
||||
KEYBOARD_TYPE_INTERNAL = 0,
|
||||
KEYBOARD_TYPE_PC_XT,
|
||||
KEYBOARD_TYPE_AT,
|
||||
KEYBOARD_TYPE_AX,
|
||||
KEYBOARD_TYPE_PS2,
|
||||
KEYBOARD_TYPE_PS55
|
||||
};
|
||||
|
||||
/* Used by the AT / PS/2 keyboard controller, common device, keyboard, and mouse. */
|
||||
typedef struct kbc_at_port_t {
|
||||
uint8_t wantcmd;
|
||||
@@ -194,6 +218,8 @@ typedef struct scancode {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int keyboard_type;
|
||||
|
||||
extern uint8_t keyboard_mode;
|
||||
extern int keyboard_scan;
|
||||
|
||||
@@ -216,51 +242,56 @@ extern int mouse_scan;
|
||||
extern kbc_at_port_t *kbc_at_ports[2];
|
||||
|
||||
#ifdef EMU_DEVICE_H
|
||||
extern const device_t keyboard_pc_device;
|
||||
extern const device_t keyboard_pc82_device;
|
||||
extern const device_t keyboard_pravetz_device;
|
||||
extern const device_t keyboard_xt_device;
|
||||
extern const device_t keyboard_xt86_device;
|
||||
extern const device_t keyboard_xt_compaq_device;
|
||||
extern const device_t keyboard_xt_t1x00_device;
|
||||
extern const device_t keyboard_tandy_device;
|
||||
extern const device_t keyboard_xt_lxt3_device;
|
||||
extern const device_t keyboard_xt_olivetti_device;
|
||||
extern const device_t keyboard_xt_zenith_device;
|
||||
extern const device_t keyboard_xt_hyundai_device;
|
||||
extern const device_t keyboard_xt_fe2010_device;
|
||||
extern const device_t keyboard_xtclone_device;
|
||||
extern const device_t keyboard_at_device;
|
||||
extern const device_t keyboard_at_ami_device;
|
||||
extern const device_t keyboard_at_compaq_device;
|
||||
extern const device_t keyboard_at_phoenix_device;
|
||||
extern const device_t keyboard_at_ncr_device;
|
||||
extern const device_t keyboard_at_olivetti_device;
|
||||
extern const device_t keyboard_at_siemens_device;
|
||||
extern const device_t keyboard_at_tg_ami_device;
|
||||
extern const device_t keyboard_at_toshiba_device;
|
||||
extern const device_t keyboard_ps2_device;
|
||||
extern const device_t keyboard_ps2_ps1_device;
|
||||
extern const device_t keyboard_ps2_ps1_pci_device;
|
||||
extern const device_t keyboard_ps2_xi8088_device;
|
||||
extern const device_t keyboard_ps2_ami_device;
|
||||
extern const device_t keyboard_ps2_compaq_device;
|
||||
extern const device_t keyboard_ps2_holtek_device;
|
||||
extern const device_t keyboard_ps2_mca_1_device;
|
||||
extern const device_t keyboard_ps2_mca_2_device;
|
||||
extern const device_t keyboard_ps2_olivetti_device;
|
||||
extern const device_t keyboard_ps2_phoenix_device;
|
||||
extern const device_t keyboard_ps2_quadtel_device;
|
||||
extern const device_t keyboard_ps2_tg_ami_device;
|
||||
extern const device_t keyboard_ps2_tg_ami_green_device;
|
||||
extern const device_t keyboard_ps2_pci_device;
|
||||
extern const device_t keyboard_ps2_ami_pci_device;
|
||||
extern const device_t keyboard_ps2_intel_ami_pci_device;
|
||||
extern const device_t keyboard_ps2_acer_pci_device;
|
||||
extern const device_t keyboard_ps2_ali_pci_device;
|
||||
extern const device_t keyboard_ps2_phoenix_pci_device;
|
||||
extern const device_t keyboard_ps2_tg_ami_pci_device;
|
||||
extern const device_t kbc_pc_device;
|
||||
extern const device_t kbc_pc82_device;
|
||||
extern const device_t kbc_pravetz_device;
|
||||
extern const device_t kbc_xt_device;
|
||||
extern const device_t kbc_xt86_device;
|
||||
extern const device_t kbc_xt_compaq_device;
|
||||
extern const device_t kbc_xt_t1x00_device;
|
||||
extern const device_t kbc_tandy_device;
|
||||
extern const device_t kbc_xt_lxt3_device;
|
||||
extern const device_t kbc_xt_olivetti_device;
|
||||
extern const device_t kbc_xt_zenith_device;
|
||||
extern const device_t kbc_xt_hyundai_device;
|
||||
extern const device_t kbc_xt_fe2010_device;
|
||||
extern const device_t kbc_xtclone_device;
|
||||
extern const device_t kbc_at_device;
|
||||
extern const device_t kbc_at_ami_device;
|
||||
extern const device_t kbc_at_compaq_device;
|
||||
extern const device_t kbc_at_phoenix_device;
|
||||
extern const device_t kbc_at_ncr_device;
|
||||
extern const device_t kbc_at_olivetti_device;
|
||||
extern const device_t kbc_at_siemens_device;
|
||||
extern const device_t kbc_at_tg_ami_device;
|
||||
extern const device_t kbc_at_toshiba_device;
|
||||
extern const device_t kbc_ps2_device;
|
||||
extern const device_t kbc_ps2_ps1_device;
|
||||
extern const device_t kbc_ps2_ps1_pci_device;
|
||||
extern const device_t kbc_ps2_xi8088_device;
|
||||
extern const device_t kbc_ps2_ami_device;
|
||||
extern const device_t kbc_ps2_compaq_device;
|
||||
extern const device_t kbc_ps2_holtek_device;
|
||||
extern const device_t kbc_ps2_mca_1_device;
|
||||
extern const device_t kbc_ps2_mca_2_device;
|
||||
extern const device_t kbc_ps2_olivetti_device;
|
||||
extern const device_t kbc_ps2_phoenix_device;
|
||||
extern const device_t kbc_ps2_quadtel_device;
|
||||
extern const device_t kbc_ps2_tg_ami_device;
|
||||
extern const device_t kbc_ps2_tg_ami_green_device;
|
||||
extern const device_t kbc_ps2_pci_device;
|
||||
extern const device_t kbc_ps2_ami_pci_device;
|
||||
extern const device_t kbc_ps2_intel_ami_pci_device;
|
||||
extern const device_t kbc_ps2_acer_pci_device;
|
||||
extern const device_t kbc_ps2_ali_pci_device;
|
||||
extern const device_t kbc_ps2_phoenix_pci_device;
|
||||
extern const device_t kbc_ps2_tg_ami_pci_device;
|
||||
|
||||
extern const device_t keyboard_pc_xt_device;
|
||||
extern const device_t keyboard_at_device;
|
||||
extern const device_t keyboard_ax_device;
|
||||
extern const device_t keyboard_ps2_device;
|
||||
extern const device_t keyboard_ps55_device;
|
||||
extern const device_t keyboard_at_generic_device;
|
||||
#endif /*EMU_DEVICE_H*/
|
||||
|
||||
@@ -303,6 +334,18 @@ extern atkbc_dev_t *kbc_at_dev_init(uint8_t inst);
|
||||
passed on incorrectly. */
|
||||
extern uint16_t convert_scan_code(uint16_t scan_code);
|
||||
|
||||
extern const char * keyboard_get_name(int mouse);
|
||||
extern const char * keyboard_get_internal_name(int mouse);
|
||||
extern int keyboard_get_from_internal_name(char *s);
|
||||
extern int keyboard_has_config(int mouse);
|
||||
#ifdef EMU_DEVICE_H
|
||||
extern const device_t *keyboard_get_device(int mouse);
|
||||
#endif
|
||||
extern int keyboard_get_ndev(void);
|
||||
extern void keyboard_add_device(void);
|
||||
|
||||
extern const scancode scancode_set1[512];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -29,7 +29,7 @@ extern "C" {
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
|
||||
#define LOG_SIZE_BUFFER 1024 /* Log size buffer */
|
||||
#define LOG_SIZE_BUFFER 8192 /* Log size buffer */
|
||||
#define LOG_SIZE_BUFFER_CYCLIC_LINES 32 /* Cyclic log size buffer (number of lines that should be cehcked) */
|
||||
#define LOG_MINIMUM_REPEAT_ORDER 4 /* Minimum repeat size */
|
||||
|
||||
|
||||
@@ -17,66 +17,32 @@
|
||||
#define LPT6_IRQ 5
|
||||
#endif
|
||||
|
||||
typedef struct lpt_device_t {
|
||||
const char *name;
|
||||
const char *internal_name;
|
||||
typedef struct lpt_device_s {
|
||||
const char *name;
|
||||
const char *internal_name;
|
||||
|
||||
void *(*init)(void *lpt);
|
||||
void (*close)(void *priv);
|
||||
void (*write_data)(uint8_t val, void *priv);
|
||||
void (*write_ctrl)(uint8_t val, void *priv);
|
||||
void (*autofeed)(uint8_t val,void *priv);
|
||||
void (*strobe)(uint8_t old, uint8_t val,void *priv);
|
||||
uint8_t (*read_status)(void *priv);
|
||||
uint8_t (*read_ctrl)(void *priv);
|
||||
void (*epp_write_data)(uint8_t is_addr, uint8_t val, void *priv);
|
||||
void (*epp_request_read)(uint8_t is_addr, void *priv);
|
||||
void *(*init)(void *lpt);
|
||||
void (*close)(void *priv);
|
||||
void (*write_data)(uint8_t val, void *priv);
|
||||
void (*write_ctrl)(uint8_t val, void *priv);
|
||||
void (*autofeed)(uint8_t val,void *priv);
|
||||
void (*strobe)(uint8_t old, uint8_t val,void *priv);
|
||||
uint8_t (*read_status)(void *priv);
|
||||
uint8_t (*read_ctrl)(void *priv);
|
||||
void (*epp_write_data)(uint8_t is_addr, uint8_t val, void *priv);
|
||||
void (*epp_request_read)(uint8_t is_addr, void *priv);
|
||||
|
||||
void *priv;
|
||||
struct lpt_t *lpt;
|
||||
//#ifdef EMU_DEVICE_H
|
||||
// struct device_t *cfgdevice;
|
||||
//#else
|
||||
void *cfgdevice;
|
||||
//#endif
|
||||
} lpt_device_t;
|
||||
|
||||
extern void lpt_set_ext(int port, uint8_t ext);
|
||||
extern void lpt_set_ecp(int port, uint8_t ecp);
|
||||
extern void lpt_set_epp(int port, uint8_t epp);
|
||||
extern void lpt_set_lv2(int port, uint8_t lv2);
|
||||
extern void lpt_set_fifo_threshold(int port, int threshold);
|
||||
extern void lpt_reset(void);
|
||||
extern void lpt_close(void);
|
||||
extern void lpt_init(void);
|
||||
extern void lpt_port_setup(int i, uint16_t port);
|
||||
extern void lpt_port_irq(int i, uint8_t irq);
|
||||
extern void lpt_port_dma(int i, uint8_t dma);
|
||||
extern void lpt_port_remove(int i);
|
||||
extern void lpt1_remove_ams(void);
|
||||
|
||||
#define lpt1_setup(a) lpt_port_setup(0, a)
|
||||
#define lpt1_irq(a) lpt_port_irq(0, a)
|
||||
#define lpt1_remove() lpt_port_remove(0)
|
||||
|
||||
#define lpt2_setup(a) lpt_port_setup(1, a)
|
||||
#define lpt2_irq(a) lpt_port_irq(1, a)
|
||||
#define lpt2_remove() lpt_port_remove(1)
|
||||
|
||||
#define lpt3_setup(a) lpt_port_setup(2, a)
|
||||
#define lpt3_irq(a) lpt_port_irq(2, a)
|
||||
#define lpt3_remove() lpt_port_remove(2)
|
||||
|
||||
#define lpt4_setup(a) lpt_port_setup(3, a)
|
||||
#define lpt4_irq(a) lpt_port_irq(3, a)
|
||||
#define lpt4_remove() lpt_port_remove(3)
|
||||
|
||||
#if 0
|
||||
#define lpt5_setup(a) lpt_port_setup(4, a)
|
||||
#define lpt5_irq(a) lpt_port_irq(4, a)
|
||||
#define lpt5_remove() lpt_port_remove(4)
|
||||
|
||||
#define lpt6_setup(a) lpt_port_setup(5, a)
|
||||
#define lpt6_irq(a) lpt_port_irq(5, a)
|
||||
#define lpt6_remove() lpt_port_remove(5)
|
||||
#endif
|
||||
|
||||
void lpt_devices_init(void);
|
||||
void lpt_devices_close(void);
|
||||
|
||||
typedef struct lpt_port_t {
|
||||
#ifdef _TIMER_H_
|
||||
typedef struct lpt_t {
|
||||
uint8_t enabled;
|
||||
uint8_t irq;
|
||||
uint8_t irq_state;
|
||||
@@ -94,52 +60,87 @@ typedef struct lpt_port_t {
|
||||
uint8_t autofeed;
|
||||
uint8_t strobe;
|
||||
uint8_t lv2;
|
||||
uint8_t pad[7];
|
||||
uint8_t cnfga_readout;
|
||||
uint8_t inst;
|
||||
uint8_t pad[5];
|
||||
uint16_t addr;
|
||||
uint16_t id;
|
||||
uint16_t pad0[2];
|
||||
int device;
|
||||
int enable_irq;
|
||||
lpt_device_t *dt;
|
||||
#ifdef FIFO_H
|
||||
fifo16_t *fifo;
|
||||
fifo16_t * fifo;
|
||||
#else
|
||||
void *fifo;
|
||||
void * fifo;
|
||||
#endif
|
||||
void *priv;
|
||||
|
||||
pc_timer_t fifo_out_timer;
|
||||
} lpt_t;
|
||||
#endif /* _TIMER_H_ */
|
||||
|
||||
typedef struct lpt_port_s {
|
||||
uint8_t enabled;
|
||||
|
||||
int device;
|
||||
} lpt_port_t;
|
||||
|
||||
extern lpt_port_t lpt_ports[PARALLEL_MAX];
|
||||
|
||||
typedef enum {
|
||||
LPT_STATE_IDLE = 0,
|
||||
LPT_STATE_READ_DMA,
|
||||
LPT_STATE_WRITE_FIFO
|
||||
} lpt_state_t;
|
||||
|
||||
extern lpt_port_t lpt_ports[PARALLEL_MAX];
|
||||
extern void lpt_write(uint16_t port, uint8_t val, void *priv);
|
||||
|
||||
extern void lpt_write(uint16_t port, uint8_t val, void *priv);
|
||||
extern void lpt_write_to_fifo(void *priv, uint8_t val);
|
||||
|
||||
extern void lpt_write_to_fifo(void *priv, uint8_t val);
|
||||
extern uint8_t lpt_read(uint16_t port, void *priv);
|
||||
|
||||
extern uint8_t lpt_read(uint16_t port, void *priv);
|
||||
extern uint8_t lpt_read_port(lpt_t *dev, uint16_t reg);
|
||||
|
||||
extern uint8_t lpt_read_port(int port, uint16_t reg);
|
||||
extern uint8_t lpt_read_status(lpt_t *dev);
|
||||
extern void lpt_irq(void *priv, int raise);
|
||||
|
||||
extern uint8_t lpt_read_status(int port);
|
||||
extern void lpt_irq(void *priv, int raise);
|
||||
extern int lpt_device_get_from_internal_name(const char *str);
|
||||
|
||||
extern int lpt_device_get_from_internal_name(const char *s);
|
||||
extern const char *lpt_device_get_name(int id);
|
||||
extern const char *lpt_device_get_internal_name(int id);
|
||||
|
||||
extern const char *lpt_device_get_name(int id);
|
||||
extern const char *lpt_device_get_internal_name(int id);
|
||||
#ifdef EMU_DEVICE_H
|
||||
extern const device_t *lpt_device_getdevice(const int id);
|
||||
#endif
|
||||
|
||||
extern const lpt_device_t lpt_dac_device;
|
||||
extern const lpt_device_t lpt_dac_stereo_device;
|
||||
extern int lpt_device_has_config(const int id);
|
||||
|
||||
extern const lpt_device_t dss_device;
|
||||
extern const lpt_device_t lpt_dac_device;
|
||||
extern const lpt_device_t lpt_dac_stereo_device;
|
||||
|
||||
extern const lpt_device_t lpt_hasp_savquest_device;
|
||||
extern const lpt_device_t dss_device;
|
||||
|
||||
extern const lpt_device_t lpt_hasp_savquest_device;
|
||||
|
||||
extern void lpt_set_ext(lpt_t *dev, uint8_t ext);
|
||||
extern void lpt_set_ecp(lpt_t *dev, uint8_t ecp);
|
||||
extern void lpt_set_epp(lpt_t *dev, uint8_t epp);
|
||||
extern void lpt_set_lv2(lpt_t *dev, uint8_t lv2);
|
||||
extern void lpt_set_fifo_threshold(lpt_t *dev, int threshold);
|
||||
extern void lpt_set_cnfga_readout(lpt_t *dev, const uint8_t cnfga_readout);
|
||||
extern void lpt_port_setup(lpt_t *dev, uint16_t port);
|
||||
extern void lpt_port_irq(lpt_t *dev, uint8_t irq);
|
||||
extern void lpt_port_dma(lpt_t *dev, uint8_t dma);
|
||||
extern void lpt_port_remove(lpt_t *dev);
|
||||
extern void lpt1_remove_ams(lpt_t *dev);
|
||||
|
||||
extern void lpt_devices_init(void);
|
||||
extern void lpt_devices_close(void);
|
||||
|
||||
extern void lpt_set_next_inst(int ni);
|
||||
extern void lpt_set_3bc_used(int is_3bc_used);
|
||||
|
||||
extern void lpt_standalone_init(void);
|
||||
|
||||
extern const device_t lpt_port_device;
|
||||
|
||||
#endif /*EMU_LPT_H*/
|
||||
|
||||
@@ -85,23 +85,24 @@
|
||||
#define MACHINE_SOFTFLOAT_ONLY 0x00000001 /* sys requires SoftFloat FPU */
|
||||
#define MACHINE_VIDEO 0x00000002 /* sys has int video */
|
||||
#define MACHINE_VIDEO_8514A 0x00000004 /* sys has int video */
|
||||
#define MACHINE_VIDEO_XGA 0x00000008 /* sys has int video */
|
||||
#define MACHINE_VIDEO_ONLY 0x00000010 /* sys has fixed video */
|
||||
#define MACHINE_MOUSE 0x00000020 /* sys has int mouse */
|
||||
#define MACHINE_FDC 0x00000040 /* sys has int FDC */
|
||||
#define MACHINE_LPT_PRI 0x00000080 /* sys has int pri LPT */
|
||||
#define MACHINE_LPT_SEC 0x00000100 /* sys has int sec LPT */
|
||||
#define MACHINE_LPT_TER 0x00000200 /* sys has int ter LPT */
|
||||
#define MACHINE_PS2_KBC 0x00000400 /* sys has a PS/2 keyboard controller */
|
||||
#define MACHINE_VIDEO_ONLY 0x00000008 /* sys has fixed video */
|
||||
#define MACHINE_KEYBOARD 0x00000010 /* sys has int keyboard */
|
||||
#define MACHINE_AX 0x00000020 /* sys adheres to Japanese AX standard */
|
||||
#define MACHINE_KEYBOARD_JIS 0x00000020 /* sys has int keyboard which is Japanese (AX or PS/55) */
|
||||
#define MACHINE_MOUSE 0x00000040 /* sys has int mouse */
|
||||
#define MACHINE_FDC 0x00000080 /* sys has int FDC */
|
||||
#define MACHINE_LPT_PRI 0x00000100 /* sys has int pri LPT */
|
||||
#define MACHINE_LPT_SEC 0x00000200 /* sys has int sec LPT */
|
||||
#define MACHINE_LPT_TER 0x00000400 /* sys has int ter LPT */
|
||||
#define MACHINE_PS2_KBC 0x00000800 /* sys has a PS/2 keyboard controller */
|
||||
/* this is separate from having PS/2 ports */
|
||||
#define MACHINE_UART_PRI 0x00000800 /* sys has int pri UART */
|
||||
#define MACHINE_UART_SEC 0x00001000 /* sys has int sec UART */
|
||||
#define MACHINE_UART_TER 0x00002000 /* sys has int ter UART */
|
||||
#define MACHINE_UART_QUA 0x00004000 /* sys has int qua UART */
|
||||
#define MACHINE_GAMEPORT 0x00008000 /* sys has int game port */
|
||||
#define MACHINE_SOUND 0x00010000 /* sys has int sound */
|
||||
#define MACHINE_NIC 0x00020000 /* sys has int NIC */
|
||||
#define MACHINE_AX 0x00040000 /* sys adheres to Japanese AX standard */
|
||||
#define MACHINE_UART_PRI 0x00010800 /* sys has int pri UART */
|
||||
#define MACHINE_UART_SEC 0x00002000 /* sys has int sec UART */
|
||||
#define MACHINE_UART_TER 0x00004000 /* sys has int ter UART */
|
||||
#define MACHINE_UART_QUA 0x00008000 /* sys has int qua UART */
|
||||
#define MACHINE_GAMEPORT 0x00010000 /* sys has int game port */
|
||||
#define MACHINE_SOUND 0x00020000 /* sys has int sound */
|
||||
#define MACHINE_NIC 0x00040000 /* sys has int NIC */
|
||||
/* Feature flags for advanced devices. */
|
||||
#define MACHINE_APM 0x00080000 /* sys has APM */
|
||||
#define MACHINE_ACPI 0x00100000 /* sys has ACPI */
|
||||
@@ -338,6 +339,7 @@ typedef struct _machine_ {
|
||||
uint32_t gpio_acpi;
|
||||
#ifdef EMU_DEVICE_H
|
||||
const device_t *device;
|
||||
const device_t *kbd_device;
|
||||
const device_t *fdc_device;
|
||||
const device_t *sio_device;
|
||||
const device_t *vid_device;
|
||||
@@ -345,6 +347,7 @@ typedef struct _machine_ {
|
||||
const device_t *net_device;
|
||||
#else
|
||||
void *device;
|
||||
void *kbd_device;
|
||||
void *fdc_device;
|
||||
void *sio_device;
|
||||
void *vid_device;
|
||||
@@ -789,6 +792,7 @@ extern int machine_at_ms5146_init(const machine_t *);
|
||||
extern int machine_at_cb52xsi_init(const machine_t *);
|
||||
|
||||
extern int machine_at_m560_init(const machine_t *);
|
||||
extern int machine_at_m5ata_init(const machine_t *);
|
||||
extern int machine_at_ms5164_init(const machine_t *);
|
||||
|
||||
extern int machine_at_sp97xv_init(const machine_t *);
|
||||
@@ -917,6 +921,9 @@ extern int machine_xt_m19_init(const machine_t *);
|
||||
/* m_pcjr.c */
|
||||
extern int machine_pcjr_init(const machine_t *);
|
||||
|
||||
/* m_pc5086.c */
|
||||
extern int machine_pc5086_init(const machine_t *);
|
||||
|
||||
/* m_ps1.c */
|
||||
extern int machine_ps1_m2011_init(const machine_t *);
|
||||
extern int machine_ps1_m2121_init(const machine_t *);
|
||||
|
||||
@@ -5,6 +5,7 @@ typedef struct dev_status_empty_active_t {
|
||||
atomic_bool_t empty;
|
||||
atomic_bool_t active;
|
||||
atomic_bool_t write_active;
|
||||
atomic_bool_t write_prot;
|
||||
} dev_status_empty_active_t;
|
||||
|
||||
typedef struct dev_status_active_t {
|
||||
@@ -19,7 +20,7 @@ typedef struct dev_status_empty_t {
|
||||
typedef struct machine_status_t {
|
||||
dev_status_empty_active_t fdd[FDD_NUM];
|
||||
dev_status_empty_active_t cdrom[CDROM_NUM];
|
||||
dev_status_empty_active_t zip[ZIP_NUM];
|
||||
dev_status_empty_active_t rdisk[RDISK_NUM];
|
||||
dev_status_empty_active_t mo[MO_NUM];
|
||||
dev_status_empty_active_t cassette;
|
||||
dev_status_active_t hdd[HDD_BUS_USB];
|
||||
|
||||
@@ -84,10 +84,11 @@ static const mo_drive_type_t mo_drive_types[KNOWN_MO_DRIVE_TYPES] = {
|
||||
};
|
||||
|
||||
enum {
|
||||
MO_BUS_DISABLED = 0,
|
||||
MO_BUS_ATAPI = 5,
|
||||
MO_BUS_SCSI = 6,
|
||||
MO_BUS_USB = 7
|
||||
MO_BUS_DISABLED = 0,
|
||||
MO_BUS_LPT = 6,
|
||||
MO_BUS_ATAPI = 8,
|
||||
MO_BUS_SCSI = 9,
|
||||
MO_BUS_USB = 10
|
||||
};
|
||||
|
||||
typedef struct mo_drive_t {
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#endif
|
||||
|
||||
#define MOUSE_TYPE_NONE 0 /* no mouse configured */
|
||||
#define MOUSE_TYPE_INTERNAL 1 /* achine has internal mouse */
|
||||
#define MOUSE_TYPE_INTERNAL 1 /* machine has internal mouse */
|
||||
#define MOUSE_TYPE_LOGIBUS 2 /* Logitech/ATI Bus Mouse */
|
||||
#define MOUSE_TYPE_INPORT 3 /* Microsoft InPort Mouse */
|
||||
#if 0
|
||||
@@ -42,7 +42,10 @@
|
||||
#define MOUSE_TYPE_WACOM 12 /* WACOM tablet */
|
||||
#define MOUSE_TYPE_WACOMARTP 13 /* WACOM tablet (ArtPad) */
|
||||
#define MOUSE_TYPE_MSYSTEMSB 14 /* Mouse Systems bus mouse */
|
||||
#define MOUSE_TYPE_MSBPOINT 15 /* Microsoft Serial BallPoint mouse */
|
||||
#define MOUSE_TYPE_PS2_QPORT 27 /* PS/2 QuickPort series Bus Mouse */
|
||||
|
||||
#define MOUSE_TYPE_QPORT 0x40 /* Mouse is an on-board version of one of the above. */
|
||||
#define MOUSE_TYPE_ONBOARD 0x80 /* Mouse is an on-board version of one of the above. */
|
||||
|
||||
|
||||
@@ -71,8 +74,11 @@ extern const device_t mouse_genibus_device;
|
||||
extern const device_t mouse_mssystems_device;
|
||||
extern const device_t mouse_mssystems_bus_device;
|
||||
extern const device_t mouse_msserial_device;
|
||||
extern const device_t mouse_msserial_ballpoint_device;
|
||||
extern const device_t mouse_ltserial_device;
|
||||
extern const device_t mouse_ps2_device;
|
||||
extern const device_t mouse_upc_device;
|
||||
extern const device_t mouse_upc_standalone_device;
|
||||
# ifdef USE_WACOM
|
||||
extern const device_t mouse_wacom_device;
|
||||
extern const device_t mouse_wacom_artpad_device;
|
||||
@@ -129,6 +135,11 @@ extern void mouse_init(void);
|
||||
|
||||
extern void mouse_bus_set_irq(void *priv, int irq);
|
||||
|
||||
extern void mouse_upc_port_handler(int num, int set, uint16_t port, void *priv);
|
||||
extern void mouse_upc_handler(int set, uint16_t port, void *priv);
|
||||
|
||||
extern void mouse_upc_set_irq(int num, uint16_t irq, void *priv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -48,11 +48,13 @@
|
||||
#include <stdint.h>
|
||||
|
||||
/* Network provider types. */
|
||||
#define NET_TYPE_NONE 0 /* use the null network driver */
|
||||
#define NET_TYPE_SLIRP 1 /* use the SLiRP port forwarder */
|
||||
#define NET_TYPE_PCAP 2 /* use the (Win)Pcap API */
|
||||
#define NET_TYPE_VDE 3 /* use the VDE plug API */
|
||||
#define NET_TYPE_TAP 4 /* use a linux TAP device */
|
||||
#define NET_TYPE_NONE 0 /* use the null network driver */
|
||||
#define NET_TYPE_SLIRP 1 /* use the SLiRP port forwarder */
|
||||
#define NET_TYPE_PCAP 2 /* use the (Win)Pcap API */
|
||||
#define NET_TYPE_VDE 3 /* use the VDE plug API */
|
||||
#define NET_TYPE_TAP 4 /* use a linux TAP device */
|
||||
#define NET_TYPE_NMSWITCH 5 /* use the network multicast switch provider */
|
||||
#define NET_TYPE_NRSWITCH 6 /* use the network remote switch provider */
|
||||
|
||||
#define NET_MAX_FRAME 1518
|
||||
/* Queue size must be a power of 2 */
|
||||
@@ -96,6 +98,9 @@ typedef struct netcard_conf_t {
|
||||
int net_type;
|
||||
char host_dev_name[128];
|
||||
uint32_t link_state;
|
||||
uint8_t switch_group;
|
||||
uint8_t promisc_mode;
|
||||
char nrs_hostname[128];
|
||||
} netcard_conf_t;
|
||||
|
||||
extern netcard_conf_t net_cards_conf[NET_CARD_MAX];
|
||||
@@ -129,6 +134,7 @@ extern const netdrv_t net_slirp_drv;
|
||||
extern const netdrv_t net_vde_drv;
|
||||
extern const netdrv_t net_tap_drv;
|
||||
extern const netdrv_t net_null_drv;
|
||||
extern const netdrv_t net_netswitch_drv;
|
||||
|
||||
struct _netcard_t {
|
||||
const device_t *device;
|
||||
@@ -194,6 +200,7 @@ extern int network_dev_available(int);
|
||||
extern int network_dev_to_id(char *);
|
||||
extern int network_card_available(int);
|
||||
extern int network_card_has_config(int);
|
||||
extern int network_type_has_config(int);
|
||||
extern const char *network_card_get_internal_name(int);
|
||||
extern int network_card_get_from_internal_name(char *);
|
||||
#ifdef EMU_DEVICE_H
|
||||
|
||||
@@ -143,8 +143,8 @@ extern int plat_getcwd(char *bufp, int max);
|
||||
extern int plat_chdir(char *path);
|
||||
extern void plat_tempfile(char *bufp, char *prefix, char *suffix);
|
||||
extern void plat_get_exe_name(char *s, int size);
|
||||
extern void plat_get_global_config_dir(char *outbuf, uint8_t len);
|
||||
extern void plat_get_global_data_dir(char *outbuf, uint8_t len);
|
||||
extern void plat_get_global_config_dir(char *outbuf, size_t len);
|
||||
extern void plat_get_global_data_dir(char *outbuf, size_t len);
|
||||
extern void plat_get_temp_dir(char *outbuf, uint8_t len);
|
||||
extern void plat_init_rom_paths(void);
|
||||
extern int plat_dir_check(char *path);
|
||||
@@ -185,9 +185,9 @@ extern void floppy_mount(uint8_t id, char *fn, uint8_t wp);
|
||||
extern void floppy_eject(uint8_t id);
|
||||
extern void cdrom_mount(uint8_t id, char *fn);
|
||||
extern void plat_cdrom_ui_update(uint8_t id, uint8_t reload);
|
||||
extern void zip_eject(uint8_t id);
|
||||
extern void zip_mount(uint8_t id, char *fn, uint8_t wp);
|
||||
extern void zip_reload(uint8_t id);
|
||||
extern void rdisk_eject(uint8_t id);
|
||||
extern void rdisk_mount(uint8_t id, char *fn, uint8_t wp);
|
||||
extern void rdisk_reload(uint8_t id);
|
||||
extern void mo_eject(uint8_t id);
|
||||
extern void mo_mount(uint8_t id, char *fn, uint8_t wp);
|
||||
extern void mo_reload(uint8_t id);
|
||||
|
||||
@@ -2,10 +2,14 @@
|
||||
#define EMU_PRT_DEVS_H
|
||||
|
||||
extern const lpt_device_t lpt_prt_text_device;
|
||||
extern const device_t prt_text_device;
|
||||
extern const lpt_device_t lpt_prt_escp_device;
|
||||
extern const device_t prt_escp_device;
|
||||
extern const lpt_device_t lpt_prt_ps_device;
|
||||
extern const device_t prt_ps_device;
|
||||
#ifdef USE_PCL
|
||||
extern const lpt_device_t lpt_prt_pcl_device;
|
||||
extern const device_t prt_pcl_device;
|
||||
#endif
|
||||
|
||||
#endif /*EMU_PRT_DEVS_H*/
|
||||
|
||||
50
src/include/86box/prt_papersizes.h
Normal file
50
src/include/86box/prt_papersizes.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Define the various paper sizes for printers.
|
||||
*
|
||||
* Authors: Jasmine Iwanek, <jasmine@iwanek.co.uk>
|
||||
*
|
||||
* Copyright 2025 Jasmine Iwanek
|
||||
*/
|
||||
#ifndef EMU_PRT_PAPERSIZES_H
|
||||
#define EMU_PRT_PAPERSIZES_H
|
||||
|
||||
/* Standard U.S. Letter */
|
||||
#define LETTER_PAGE_WIDTH 8.5
|
||||
#define LETTER_PAGE_HEIGHT 11.0
|
||||
|
||||
/* Standard U.S. Legal */
|
||||
#define LEGAL_PAGE_WIDTH 8.5
|
||||
#define LEGAL_PAGE_HEIGHT 14.0
|
||||
|
||||
/* Standard U.S. Ledger */
|
||||
#define LEDGER_PAGE_WIDTH 11.0
|
||||
#define LEDGER_PAGE_HEIGHT 17.0
|
||||
|
||||
/* Standard A0 */
|
||||
#define A0_PAGE_WIDTH 33.125
|
||||
#define A0_PAGE_HEIGHT 46.75
|
||||
|
||||
/* Standard A1 */
|
||||
#define A1_PAGE_WIDTH 23.375
|
||||
#define A1_PAGE_HEIGHT 33.125
|
||||
|
||||
/* Standard A2 */
|
||||
#define A2_PAGE_WIDTH 16.5
|
||||
#define A2_PAGE_HEIGHT 23.375
|
||||
|
||||
/* Standard A3 */
|
||||
#define A3_PAGE_WIDTH 11.75
|
||||
#define A3_PAGE_HEIGHT 16.5
|
||||
|
||||
/* Standard A4 */
|
||||
#define A4_PAGE_WIDTH 8.25
|
||||
#define A4_PAGE_HEIGHT 11.75
|
||||
|
||||
#endif /*EMU_PLAT_FALLTHROUGH_H*/
|
||||
@@ -16,29 +16,62 @@
|
||||
* Copyright 2018-2025 Miran Grca.
|
||||
*/
|
||||
|
||||
#ifndef EMU_ZIP_H
|
||||
#define EMU_ZIP_H
|
||||
#ifndef EMU_RDISK_H
|
||||
#define EMU_RDISK_H
|
||||
|
||||
#define ZIP_NUM 4
|
||||
#define RDISK_NUM 4
|
||||
|
||||
#define BUF_SIZE 32768
|
||||
#define BUF_SIZE 32768
|
||||
|
||||
#define ZIP_TIME 10.0
|
||||
#define RDISK_TIME 10.0
|
||||
|
||||
#define ZIP_SECTORS (96 * 2048)
|
||||
#define ZIP_SECTORS (96 * 2048)
|
||||
|
||||
#define ZIP_250_SECTORS (489532)
|
||||
#define ZIP_250_SECTORS (489532)
|
||||
|
||||
#define ZIP_IMAGE_HISTORY 10
|
||||
#define RDISK_IMAGE_HISTORY 10
|
||||
|
||||
enum {
|
||||
ZIP_BUS_DISABLED = 0,
|
||||
ZIP_BUS_ATAPI = 5,
|
||||
ZIP_BUS_SCSI = 6,
|
||||
ZIP_BUS_USB = 7
|
||||
RDISK_TYPE_GENERIC = 0,
|
||||
RDISK_TYPE_ZIP_100,
|
||||
RDISK_TYPE_ZIP_250
|
||||
};
|
||||
|
||||
typedef struct zip_drive_t {
|
||||
typedef struct rdisk_type_t {
|
||||
uint32_t sectors;
|
||||
uint16_t bytes_per_sector;
|
||||
} rdisk_type_t;
|
||||
|
||||
#define KNOWN_RDISK_TYPES 2
|
||||
static const rdisk_type_t rdisk_types[KNOWN_RDISK_TYPES] = {
|
||||
{ ZIP_SECTORS, 512 },
|
||||
{ ZIP_250_SECTORS, 512 },
|
||||
};
|
||||
|
||||
typedef struct rdisk_drive_type_t {
|
||||
const char *vendor;
|
||||
const char *model;
|
||||
const char *revision;
|
||||
int8_t supported_media[KNOWN_RDISK_TYPES];
|
||||
} rdisk_drive_type_t;
|
||||
|
||||
#define KNOWN_RDISK_DRIVE_TYPES 3
|
||||
static const rdisk_drive_type_t rdisk_drive_types[KNOWN_RDISK_DRIVE_TYPES] = {
|
||||
{ "86BOX", "REMOVABLE DISK", "5.00", { 1, 1 }},
|
||||
{ "IOMEGA", "ZIP 100", "E.08", { 1, 0 }},
|
||||
{ "IOMEGA", "ZIP 250", "42.S", { 1, 1 }}
|
||||
};
|
||||
|
||||
enum {
|
||||
RDISK_BUS_DISABLED = 0,
|
||||
RDISK_BUS_LPT = 6,
|
||||
RDISK_BUS_IDE = 7,
|
||||
RDISK_BUS_ATAPI = 8,
|
||||
RDISK_BUS_SCSI = 9,
|
||||
RDISK_BUS_USB = 10
|
||||
};
|
||||
|
||||
typedef struct rdisk_drive_t {
|
||||
uint8_t id;
|
||||
|
||||
union {
|
||||
@@ -64,17 +97,17 @@ typedef struct zip_drive_t {
|
||||
char image_path[1024];
|
||||
char prev_image_path[1024];
|
||||
|
||||
char *image_history[ZIP_IMAGE_HISTORY];
|
||||
char *image_history[RDISK_IMAGE_HISTORY];
|
||||
|
||||
uint32_t is_250;
|
||||
uint32_t type;
|
||||
uint32_t medium_size;
|
||||
uint32_t base;
|
||||
} zip_drive_t;
|
||||
} rdisk_drive_t;
|
||||
|
||||
typedef struct zip_t {
|
||||
typedef struct rdisk_t {
|
||||
mode_sense_pages_t ms_pages_saved;
|
||||
|
||||
zip_drive_t *drv;
|
||||
rdisk_drive_t *drv;
|
||||
#ifdef EMU_IDE_H
|
||||
ide_tf_t *tf;
|
||||
#else
|
||||
@@ -113,37 +146,37 @@ typedef struct zip_t {
|
||||
double callback;
|
||||
|
||||
uint8_t (*ven_cmd)(void *sc, uint8_t *cdb, int32_t *BufLen);
|
||||
} zip_t;
|
||||
} rdisk_t;
|
||||
|
||||
extern zip_t *zip[ZIP_NUM];
|
||||
extern zip_drive_t zip_drives[ZIP_NUM];
|
||||
extern uint8_t atapi_zip_drives[8];
|
||||
extern uint8_t scsi_zip_drives[16];
|
||||
extern rdisk_t *rdisk[RDISK_NUM];
|
||||
extern rdisk_drive_t rdisk_drives[RDISK_NUM];
|
||||
extern uint8_t atapi_rdisk_drives[8];
|
||||
extern uint8_t scsi_rdisk_drives[16];
|
||||
|
||||
#define zip_sense_error dev->sense[0]
|
||||
#define zip_sense_key dev->sense[2]
|
||||
#define zip_info *(uint32_t *) &(dev->sense[3])
|
||||
#define zip_asc dev->sense[12]
|
||||
#define zip_ascq dev->sense[13]
|
||||
#define rdisk_sense_error dev->sense[0]
|
||||
#define rdisk_sense_key dev->sense[2]
|
||||
#define rdisk_info *(uint32_t *) &(dev->sense[3])
|
||||
#define rdisk_asc dev->sense[12]
|
||||
#define rdisk_ascq dev->sense[13]
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void zip_disk_close(const zip_t *dev);
|
||||
extern void zip_disk_reload(const zip_t *dev);
|
||||
extern void zip_insert(zip_t *dev);
|
||||
extern void rdisk_disk_close(const rdisk_t *dev);
|
||||
extern void rdisk_disk_reload(const rdisk_t *dev);
|
||||
extern void rdisk_insert(rdisk_t *dev);
|
||||
|
||||
extern void zip_global_init(void);
|
||||
extern void zip_hard_reset(void);
|
||||
extern void rdisk_global_init(void);
|
||||
extern void rdisk_hard_reset(void);
|
||||
|
||||
extern void zip_reset(scsi_common_t *sc);
|
||||
extern int zip_is_empty(const uint8_t id);
|
||||
extern void zip_load(const zip_t *dev, const char *fn, const int skip_insert);
|
||||
extern void zip_close(void);
|
||||
extern void rdisk_reset(scsi_common_t *sc);
|
||||
extern int rdisk_is_empty(const uint8_t id);
|
||||
extern void rdisk_load(const rdisk_t *dev, const char *fn, const int skip_insert);
|
||||
extern void rdisk_close(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*EMU_ZIP_H*/
|
||||
#endif /*EMU_RDISK_H*/
|
||||
@@ -151,6 +151,7 @@ extern void serial_set_dsr(serial_t *dev, uint8_t enabled);
|
||||
extern void serial_set_dcd(serial_t *dev, uint8_t enabled);
|
||||
extern void serial_set_ri(serial_t *dev, uint8_t enabled);
|
||||
extern int serial_get_ri(serial_t *dev);
|
||||
extern uint8_t serial_get_shadow(serial_t *dev);
|
||||
|
||||
extern const device_t ns8250_device;
|
||||
extern const device_t ns8250_pcjr_device;
|
||||
|
||||
@@ -26,6 +26,7 @@ extern const device_t ali5123_device;
|
||||
extern const device_t f82c606_device;
|
||||
|
||||
extern const device_t f82c710_device;
|
||||
extern const device_t f82c710_pc5086_device;
|
||||
|
||||
/* SM(S)C */
|
||||
extern const device_t fdc37c651_device;
|
||||
@@ -44,27 +45,26 @@ extern const device_t fdc37c666_device;
|
||||
extern const device_t fdc37c669_device;
|
||||
extern const device_t fdc37c669_370_device;
|
||||
|
||||
extern const device_t fdc37c67x_device;
|
||||
|
||||
#define FDC37C93X_NORMAL 0x0002
|
||||
#define FDC37C93X_FR 0x0003
|
||||
#define FDC37C93X_APM 0x0030
|
||||
#define FDC37C93X_CHIP_ID 0x00ff
|
||||
|
||||
#define FDC37C931 0x0100 /* Compaq KBC firmware and configuration registers on GPIO ports. */
|
||||
#define FDC37C932 0x0200 /* AMI '5' Megakey KBC firmware. */
|
||||
#define FDC37C933 0x0300 /* IBM KBC firmware. */
|
||||
#define FDC37C935 0x0500 /* Phoenix Multikey/42 1.38 KBC firmware. */
|
||||
#define FDC37C937 0x0700 /* Phoenix Multikey/42i 4.16 KBC firmware. */
|
||||
#define FDC37C93X_KBC 0x0f00
|
||||
#define FDC37XXX1 0x0100 /* Compaq KBC firmware and configuration registers on GPIO ports. */
|
||||
#define FDC37XXX2 0x0200 /* AMI '5' Megakey KBC firmware. */
|
||||
#define FDC37XXX3 0x0300 /* IBM KBC firmware. */
|
||||
#define FDC37XXX5 0x0500 /* Phoenix Multikey/42 1.38 KBC firmware. */
|
||||
#define FDC37XXX7 0x0700 /* Phoenix Multikey/42i 4.16 KBC firmware. */
|
||||
#define FDC37XXXX_KBC 0x0f00
|
||||
|
||||
#define FDC37C93X_NO_NVR 0x1000
|
||||
#define FDC37C93X_370 0x2000
|
||||
#define FDC37XXXX_370 0x2000
|
||||
|
||||
extern const device_t fdc37c93x_device;
|
||||
|
||||
extern const device_t fdc37m60x_device;
|
||||
extern const device_t fdc37m60x_370_device;
|
||||
|
||||
extern const device_t fdc37c67x_device;
|
||||
|
||||
/* ITE */
|
||||
extern const device_t it8661f_device;
|
||||
@@ -84,16 +84,6 @@ extern const device_t i82091aa_ide_device;
|
||||
extern const device_t pc87310_device;
|
||||
|
||||
/* National Semiconductors */
|
||||
extern const device_t pc87306_device;
|
||||
extern const device_t pc87311_device;
|
||||
extern const device_t pc87311_ide_device;
|
||||
extern const device_t pc87332_device;
|
||||
extern const device_t pc87332_398_device;
|
||||
extern const device_t pc87332_398_ide_device;
|
||||
extern const device_t pc87332_398_ide_sec_device;
|
||||
extern const device_t pc87332_398_ide_fdcon_device;
|
||||
|
||||
/* National Semiconductors PC87307 / PC87309 */
|
||||
#define PCX7307_PC87307 0x00c0
|
||||
#define PCX7307_PC97307 0x00cf
|
||||
|
||||
@@ -108,6 +98,17 @@ extern const device_t pc87332_398_ide_fdcon_device;
|
||||
|
||||
#define PCX730X_15C 0x2000
|
||||
|
||||
extern const device_t pc87306_device;
|
||||
|
||||
extern const device_t pc87311_device;
|
||||
extern const device_t pc87311_ide_device;
|
||||
extern const device_t pc87332_device;
|
||||
extern const device_t pc87332_398_device;
|
||||
extern const device_t pc87332_398_ide_device;
|
||||
extern const device_t pc87332_398_ide_sec_device;
|
||||
extern const device_t pc87332_398_ide_fdcon_device;
|
||||
|
||||
/* National Semiconductors PC87307 / PC87309 */
|
||||
extern const device_t pc87307_device;
|
||||
|
||||
extern const device_t pc87309_device;
|
||||
|
||||
@@ -12,9 +12,11 @@
|
||||
*
|
||||
* Authors: Sarah Walker, <https://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Jasmine Iwanek, <jriwanek@gmail.com>
|
||||
*
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2016-2025 Miran Grca.
|
||||
* Copyright 2024-2025 Jasmine Iwanek.
|
||||
*/
|
||||
|
||||
#ifndef EMU_SOUND_H
|
||||
@@ -132,6 +134,12 @@ extern const device_t cmi8738_device;
|
||||
extern const device_t cmi8738_onboard_device;
|
||||
extern const device_t cmi8738_6ch_onboard_device;
|
||||
|
||||
/* Covox ISA */
|
||||
extern const device_t voicemasterkey_device;
|
||||
extern const device_t soundmasterplus_device;
|
||||
extern const device_t isadacr0_device;
|
||||
extern const device_t isadacr1_device;
|
||||
|
||||
/* Creative Labs Game Blaster */
|
||||
extern const device_t cms_device;
|
||||
|
||||
@@ -214,6 +222,9 @@ extern const device_t pasplus_device;
|
||||
extern const device_t pas16_device;
|
||||
extern const device_t pas16d_device;
|
||||
|
||||
/* Rainbow Arts PC-Soundman */
|
||||
extern const device_t soundman_device;
|
||||
|
||||
/* Tandy PSSJ */
|
||||
extern const device_t pssj_device;
|
||||
extern const device_t pssj_isa_device;
|
||||
|
||||
@@ -49,7 +49,7 @@ extern int ui_msgbox_header(int flags, void *header, void *message);
|
||||
#define SB_CARTRIDGE 0x10
|
||||
#define SB_FLOPPY 0x20
|
||||
#define SB_CDROM 0x30
|
||||
#define SB_ZIP 0x40
|
||||
#define SB_RDISK 0x40
|
||||
#define SB_MO 0x50
|
||||
#define SB_HDD 0x60
|
||||
#define SB_NETWORK 0x70
|
||||
@@ -67,6 +67,7 @@ extern void ui_sb_update_tip(int meaning);
|
||||
extern void ui_sb_update_icon(int tag, int active);
|
||||
extern void ui_sb_update_icon_write(int tag, int write);
|
||||
extern void ui_sb_update_icon_state(int tag, int state);
|
||||
extern void ui_sb_update_icon_wp(int tag, int state);
|
||||
extern void ui_sb_set_text_w(wchar_t *wstr);
|
||||
extern void ui_sb_set_text(char *str);
|
||||
extern void ui_sb_bugui(char *str);
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
typedef struct colorplus_t {
|
||||
cga_t cga;
|
||||
uint8_t control;
|
||||
|
||||
lpt_t * lpt;
|
||||
} colorplus_t;
|
||||
|
||||
void colorplus_init(colorplus_t *colorplus);
|
||||
|
||||
@@ -60,6 +60,7 @@ typedef struct {
|
||||
|
||||
int cols[256][2][2];
|
||||
|
||||
lpt_t *lpt;
|
||||
uint8_t *vram;
|
||||
int monitor_index;
|
||||
int prev_monitor_index;
|
||||
|
||||
@@ -119,7 +119,8 @@ typedef struct mda_t {
|
||||
int32_t prev_monitor_index;
|
||||
int32_t monitor_type; // Used for MDA Colour support (REV0 u64)
|
||||
|
||||
uint8_t *vram;
|
||||
uint8_t *vram;
|
||||
lpt_t *lpt;
|
||||
} mda_t;
|
||||
|
||||
#define VIDEO_MONITOR_PROLOGUE() \
|
||||
|
||||
@@ -138,7 +138,6 @@ typedef struct svga_t {
|
||||
int ps_bit_bug;
|
||||
int ati_4color;
|
||||
int vblankend;
|
||||
int panning_blank;
|
||||
int render_line_offset;
|
||||
int start_retrace_latch;
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
#include <86box/rom.h>
|
||||
|
||||
#define INT_START_BLKNK_ENAB (1 << 0)
|
||||
#define INT_MASK 0xf
|
||||
#define XGA_INT_START_BLKNK_ENAB (1 << 0)
|
||||
#define XGA_INT_MASK 0xf
|
||||
|
||||
typedef struct xga_hwcursor_t {
|
||||
int ena;
|
||||
@@ -152,10 +152,9 @@ typedef struct xga_t {
|
||||
int cursor_data_on;
|
||||
int pal_test;
|
||||
int a5_test;
|
||||
int test_stage;
|
||||
int type;
|
||||
int bus;
|
||||
int src_reverse_order;
|
||||
int dst_reverse_order;
|
||||
|
||||
uint32_t linear_base;
|
||||
uint32_t linear_size;
|
||||
@@ -175,6 +174,7 @@ typedef struct xga_t {
|
||||
uint32_t px_map_base;
|
||||
uint32_t pallook[512];
|
||||
uint32_t bios_diag;
|
||||
uint32_t mapping_base;
|
||||
|
||||
PALETTE xgapal;
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ add_library(mch OBJECT
|
||||
m_xt_zenith.c
|
||||
m_pcjr.c
|
||||
m_amstrad.c
|
||||
m_amstrad_pc5x86.c
|
||||
m_europc.c
|
||||
m_elt.c
|
||||
m_xt_olivetti.c
|
||||
|
||||
@@ -155,7 +155,9 @@ typedef struct amstrad_t {
|
||||
|
||||
/* Video stuff. */
|
||||
amsvid_t *vid;
|
||||
|
||||
fdc_t *fdc;
|
||||
lpt_t *lpt;
|
||||
} amstrad_t;
|
||||
|
||||
uint32_t amstrad_latch;
|
||||
@@ -2245,7 +2247,7 @@ ams_write(uint16_t port, uint8_t val, void *priv)
|
||||
case 0x0378:
|
||||
case 0x0379:
|
||||
case 0x037a:
|
||||
lpt_write(port, val, &lpt_ports[0]);
|
||||
lpt_write(port, val, ams->lpt);
|
||||
break;
|
||||
|
||||
case 0xdead:
|
||||
@@ -2265,7 +2267,7 @@ ams_read(uint16_t port, void *priv)
|
||||
|
||||
switch (port) {
|
||||
case 0x0378:
|
||||
ret = lpt_read(port, &lpt_ports[0]);
|
||||
ret = lpt_read(port, ams->lpt);
|
||||
break;
|
||||
|
||||
case 0x0379: /* printer control, also set LK1-3.
|
||||
@@ -2279,11 +2281,11 @@ ams_read(uint16_t port, void *priv)
|
||||
* 1 Italian Language.
|
||||
* 0 Diagnostic Mode.
|
||||
*/
|
||||
ret = (lpt_read(port, &lpt_ports[0]) & 0xf8) | ams->language;
|
||||
ret = (lpt_read(port, ams->lpt) & 0xf8) | ams->language;
|
||||
break;
|
||||
|
||||
case 0x037a: /* printer status */
|
||||
ret = lpt_read(port, &lpt_ports[0]) & 0x1f;
|
||||
ret = lpt_read(port, ams->lpt) & 0x1f;
|
||||
|
||||
switch (ams->type) {
|
||||
case AMS_PC1512:
|
||||
@@ -2884,8 +2886,10 @@ machine_amstrad_init(const machine_t *model, int type)
|
||||
|
||||
nmi_init();
|
||||
|
||||
lpt1_remove_ams();
|
||||
lpt2_remove();
|
||||
ams->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
|
||||
lpt1_remove_ams(ams->lpt);
|
||||
lpt_set_next_inst(255);
|
||||
|
||||
io_sethandler(0x0378, 3,
|
||||
ams_read, NULL, NULL, ams_write, NULL, NULL, ams);
|
||||
@@ -2997,7 +3001,7 @@ machine_amstrad_init(const machine_t *model, int type)
|
||||
mouse_set_poll(ms_poll, ams);
|
||||
}
|
||||
|
||||
standalone_gameport_type = &gameport_device;
|
||||
standalone_gameport_type = &gameport_200_device;
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user