mirror of
https://github.com/86Box/86Box.git
synced 2026-02-24 02:18:20 -07:00
Merge branch 'master' of github.com:OBattler/86Box
This commit is contained in:
@@ -45,7 +45,7 @@ guide:
|
||||
7. In order to test your fresh build, replace the `86Box.exe` in your current
|
||||
86Box enviroment with your freshly built one. If you do not have a
|
||||
pre-existing 86Box environment, download the latest successful build from
|
||||
http://ci.86box.net, and the ROM set from http://tinyurl.com/rs20180312.
|
||||
http://ci.86box.net, and the ROM set from http://tinyurl.com/rs20180320.
|
||||
8. Enjoy using and testing the emulator! :)
|
||||
|
||||
If you encounter issues at any step or have additional questions, please join
|
||||
|
||||
10
src/86box.h
10
src/86box.h
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Main include file for the application.
|
||||
*
|
||||
* Version: @(#)86box.h 1.0.18 2018/03/13
|
||||
* Version: @(#)86box.h 1.0.21 2018/03/19
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
@@ -52,7 +52,7 @@
|
||||
#endif
|
||||
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
#define ABS(x) ((x) > 0 ? (x) : -(x))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -90,11 +90,11 @@ extern int vid_cga_contrast, /* (C) video */
|
||||
video_fullscreen_scale, /* (C) video */
|
||||
enable_overscan, /* (C) video */
|
||||
force_43, /* (C) video */
|
||||
gfxcard, /* (C) graphics/video card */
|
||||
video_speed; /* (C) video */
|
||||
extern int serial_enabled[], /* (C) enable serial ports */
|
||||
lpt_enabled, /* (C) enable LPT ports */
|
||||
bugger_enabled; /* (C) enable ISAbugger */
|
||||
extern int gfxcard; /* (C) graphics/video card */
|
||||
extern int sound_is_float, /* (C) sound uses FP values */
|
||||
GAMEBLASTER, /* (C) sound option */
|
||||
GUS, /* (C) sound option */
|
||||
@@ -106,6 +106,9 @@ extern int cpu_manufacturer, /* (C) cpu manufacturer */
|
||||
cpu_use_dynarec, /* (C) cpu uses/needs Dyna */
|
||||
enable_external_fpu; /* (C) enable external FPU */
|
||||
extern int enable_sync; /* (C) enable time sync */
|
||||
extern int network_type; /* (C) net provider type */
|
||||
extern int network_card; /* (C) net interface num */
|
||||
extern char network_host[512]; /* (C) host network intf */
|
||||
|
||||
|
||||
#ifdef ENABLE_LOG_TOGGLES
|
||||
@@ -131,6 +134,7 @@ extern int config_changed; /* config has changed */
|
||||
#ifdef HAVE_STDARG_H
|
||||
extern void pclog_ex(const char *fmt, va_list);
|
||||
#endif
|
||||
extern void pclog_toggle_suppr(void);
|
||||
extern void pclog(const char *fmt, ...);
|
||||
extern void fatal(const char *fmt, ...);
|
||||
extern void set_screen_size(int x, int y);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
# settings, so we can avoid changing the main one for all of
|
||||
# our local setups.
|
||||
#
|
||||
# Version: @(#)Makefile.local 1.0.9 2017/12/28
|
||||
# Version: @(#)Makefile.local 1.0.10 2018/03/20
|
||||
#
|
||||
# Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
#
|
||||
@@ -39,11 +39,14 @@ STUFF :=
|
||||
# -DENABLE_KEYBOARD_LOG=N sets logging level at N.
|
||||
# -DENABLE_PCI_LOG=N sets logging level at N.
|
||||
# -DENABLE_CDROM_LOG=N sets logging level at N.
|
||||
# -DENABLE_CDROM_IMAGE_LOG=N sets logging level at N.
|
||||
# -DENABLE_CDROM_IOCTL_LOG=N sets logging level at N.
|
||||
# -DENABLE_HDD_LOG=N sets logging level at N.
|
||||
# -DENABLE_IDE_LOG=N sets logging level at N.
|
||||
# -DENABLE_FDC_LOG=N sets logging level at N.
|
||||
# -DENABLE_D86F_LOG=N sets logging level at N.
|
||||
# -DENABLE_NIC_LOG=N sets logging level at N.
|
||||
# -DENABLE_SCAT_LOG=N sets logging level at N.
|
||||
# -DENABLE_SCSI_BUS_LOG=N sets logging level at N.
|
||||
# -DENABLE_SCSI_DISK_LOG=N sets logging level at N.
|
||||
# -DENABLE_X54X_LOG=N sets logging level at N.
|
||||
|
||||
10
src/bugger.c
10
src/bugger.c
@@ -44,10 +44,10 @@
|
||||
* configuration register (CTRL_SPCFG bit set) but have to
|
||||
* remember that stuff first...
|
||||
*
|
||||
* Version: @(#)bugger.c 1.0.9 2017/10/28
|
||||
* Version: @(#)bugger.c 1.0.10 2018/03/18
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Copyright 1989-2017 Fred N. van Kempen.
|
||||
* Copyright 1989-2018 Fred N. van Kempen.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -309,7 +309,7 @@ bug_read(uint16_t port, void *priv)
|
||||
|
||||
/* Initialize the ISA BusBugger emulator. */
|
||||
static void *
|
||||
bug_init(device_t *info)
|
||||
bug_init(const device_t *info)
|
||||
{
|
||||
pclog("%s, I/O=%04x\n", info->name, BUGGER_ADDR);
|
||||
|
||||
@@ -320,7 +320,7 @@ bug_init(device_t *info)
|
||||
bug_read, NULL, NULL, bug_write, NULL, NULL, NULL);
|
||||
|
||||
/* Just so its not NULL. */
|
||||
return(info);
|
||||
return(&bug_ctrl);
|
||||
}
|
||||
|
||||
|
||||
@@ -333,7 +333,7 @@ bug_close(UNUSED(void *priv))
|
||||
}
|
||||
|
||||
|
||||
device_t bugger_device = {
|
||||
const device_t bugger_device = {
|
||||
"ISA/PCI Bus Bugger",
|
||||
DEVICE_ISA | DEVICE_AT,
|
||||
0,
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
*
|
||||
* Definitions for the BUGGER card.
|
||||
*
|
||||
* Version: @(#)bugger.h 1.0.5 2017/10/28
|
||||
* Version: @(#)bugger.h 1.0.6 2018/03/18
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 1989-2017 Fred N. van Kempen.
|
||||
* Copyright 1989-2018 Fred N. van Kempen.
|
||||
*/
|
||||
#ifndef BUGGER_H
|
||||
# define BUGGER_H
|
||||
@@ -35,7 +35,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* Global variables. */
|
||||
extern device_t bugger_device;
|
||||
extern const device_t bugger_device;
|
||||
|
||||
|
||||
/* Functions. */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,7 @@
|
||||
* Implementation of the CD-ROM drive with SCSI(-like)
|
||||
* commands, for both ATAPI and SCSI usage.
|
||||
*
|
||||
* Version: @(#)cdrom.h 1.0.6 2018/03/15
|
||||
* Version: @(#)cdrom.h 1.0.10 2018/03/20
|
||||
*
|
||||
* Author: Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
@@ -121,6 +121,7 @@ typedef struct {
|
||||
int callback;
|
||||
|
||||
int data_pos;
|
||||
uint32_t seek_diff;
|
||||
|
||||
int cdb_len_setting;
|
||||
int cdb_len;
|
||||
@@ -150,11 +151,25 @@ typedef struct {
|
||||
int init_length;
|
||||
|
||||
int16_t cd_buffer[BUF_SIZE];
|
||||
|
||||
uint8_t rcbuf[16];
|
||||
uint8_t sub_q_data_format[16];
|
||||
uint8_t sub_q_channel_data[256];
|
||||
int last_subchannel_pos;
|
||||
|
||||
uint32_t cd_end;
|
||||
uint32_t cdrom_capacity;
|
||||
|
||||
int cd_buflen;
|
||||
int cd_state;
|
||||
|
||||
int handler_inited;
|
||||
int disc_changed;
|
||||
|
||||
int cur_speed;
|
||||
} cdrom_t;
|
||||
|
||||
typedef struct {
|
||||
int max_blocks_at_once;
|
||||
|
||||
CDROM *handler;
|
||||
|
||||
int host_drive;
|
||||
@@ -177,52 +192,31 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
int image_is_iso;
|
||||
|
||||
uint32_t last_block;
|
||||
uint32_t cdrom_capacity;
|
||||
int image_inited;
|
||||
wchar_t image_path[1024];
|
||||
wchar_t prev_image_path[1024];
|
||||
wchar_t *prev_image_path;
|
||||
FILE* image;
|
||||
int image_changed;
|
||||
|
||||
int cd_state;
|
||||
uint32_t cd_pos;
|
||||
uint32_t cd_end;
|
||||
int cd_buflen;
|
||||
} cdrom_image_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t last_block;
|
||||
uint32_t cdrom_capacity;
|
||||
int ioctl_inited;
|
||||
char ioctl_path[8];
|
||||
int tocvalid;
|
||||
int cd_state;
|
||||
uint32_t cd_end;
|
||||
int cd_buflen;
|
||||
int actual_requested_blocks;
|
||||
int last_track_pos;
|
||||
int last_track_nr;
|
||||
int capacity_read;
|
||||
uint8_t rcbuf[16];
|
||||
uint8_t sub_q_data_format[16];
|
||||
uint8_t sub_q_channel_data[256];
|
||||
int last_subchannel_pos;
|
||||
} cdrom_ioctl_t;
|
||||
|
||||
|
||||
extern cdrom_t cdrom[CDROM_NUM];
|
||||
extern cdrom_t *cdrom[CDROM_NUM];
|
||||
extern cdrom_drive_t cdrom_drives[CDROM_NUM];
|
||||
extern uint8_t atapi_cdrom_drives[8];
|
||||
extern uint8_t scsi_cdrom_drives[16][8];
|
||||
extern cdrom_image_t cdrom_image[CDROM_NUM];
|
||||
extern cdrom_ioctl_t cdrom_ioctl[CDROM_NUM];
|
||||
extern uint8_t atapi_cdrom_drives[8];
|
||||
extern uint8_t scsi_cdrom_drives[16][8];
|
||||
|
||||
#define cdrom_sense_error cdrom[id].sense[0]
|
||||
#define cdrom_sense_key cdrom[id].sense[2]
|
||||
#define cdrom_asc cdrom[id].sense[12]
|
||||
#define cdrom_ascq cdrom[id].sense[13]
|
||||
#define cdrom_sense_error cdrom[id]->sense[0]
|
||||
#define cdrom_sense_key cdrom[id]->sense[2]
|
||||
#define cdrom_asc cdrom[id]->sense[12]
|
||||
#define cdrom_ascq cdrom[id]->sense[13]
|
||||
#define cdrom_drive cdrom_drives[id].host_drive
|
||||
|
||||
|
||||
@@ -247,6 +241,7 @@ extern uint32_t cdrom_read(uint8_t channel, int length);
|
||||
extern void cdrom_write(uint8_t channel, uint32_t val, int length);
|
||||
|
||||
extern int cdrom_lba_to_msf_accurate(int lba);
|
||||
extern void cdrom_destroy_drives(void);
|
||||
|
||||
extern void cdrom_close(uint8_t id);
|
||||
extern void cdrom_reset(uint8_t id);
|
||||
@@ -254,6 +249,7 @@ extern void cdrom_set_signature(int id);
|
||||
extern void cdrom_request_sense_for_scsi(uint8_t id, uint8_t *buffer, uint8_t alloc_length);
|
||||
extern void cdrom_update_cdb(uint8_t *cdb, int lba_pos, int number_of_blocks);
|
||||
extern void cdrom_insert(uint8_t id);
|
||||
extern void cdrom_new_image(uint8_t id);
|
||||
|
||||
extern int find_cdrom_for_scsi_id(uint8_t scsi_id, uint8_t scsi_lun);
|
||||
extern int cdrom_read_capacity(uint8_t id, uint8_t *cdb, uint8_t *buffer, uint32_t *len);
|
||||
|
||||
@@ -58,41 +58,41 @@ CDROM_Interface_Image::BinaryFile::BinaryFile(const char *filename, bool &error)
|
||||
{
|
||||
memset(fn, 0, sizeof(fn));
|
||||
strcpy(fn, filename);
|
||||
error = false;
|
||||
file = fopen64(fn, "rb");
|
||||
if (file == NULL)
|
||||
error = true;
|
||||
else
|
||||
error = false;
|
||||
}
|
||||
|
||||
CDROM_Interface_Image::BinaryFile::~BinaryFile()
|
||||
{
|
||||
fclose(file);
|
||||
file = NULL;
|
||||
memset(fn, 0, sizeof(fn));
|
||||
}
|
||||
|
||||
bool CDROM_Interface_Image::BinaryFile::read(Bit8u *buffer, uint64_t seek, uint64_t count)
|
||||
{
|
||||
file = fopen64(fn, "rb");
|
||||
if (file == NULL) return 0;
|
||||
fseeko64(file, seek, SEEK_SET);
|
||||
fread(buffer, 1, count, file);
|
||||
fclose(file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint64_t CDROM_Interface_Image::BinaryFile::getLength()
|
||||
{
|
||||
uint64_t ret = 0;
|
||||
file = fopen64(fn, "rb");
|
||||
if (file == NULL) return 0;
|
||||
fseeko64(file, 0, SEEK_END);
|
||||
ret = ftello64(file);
|
||||
fclose(file);
|
||||
return ret;
|
||||
return ftello64(file);
|
||||
}
|
||||
|
||||
CDROM_Interface_Image::CDROM_Interface_Image()
|
||||
{
|
||||
printf("CDROM_Interface_Image constructor\n");
|
||||
}
|
||||
|
||||
CDROM_Interface_Image::~CDROM_Interface_Image()
|
||||
{
|
||||
printf("CDROM_Interface_Image destructor\n");
|
||||
ClearTracks();
|
||||
}
|
||||
|
||||
@@ -357,6 +357,7 @@ bool CDROM_Interface_Image::LoadCueSheet(char *cuefile)
|
||||
ifstream in;
|
||||
in.open(cuefile, ios::in);
|
||||
if (in.fail()) return false;
|
||||
int last_attr;
|
||||
|
||||
while(!in.eof()) {
|
||||
// get next line
|
||||
@@ -411,6 +412,7 @@ bool CDROM_Interface_Image::LoadCueSheet(char *cuefile)
|
||||
track.attr = DATA_TRACK;
|
||||
track.mode2 = true;
|
||||
} else if (type == "MODE2/2352") {
|
||||
track.form = 1; /* Assume this is XA Mode 2 Form 1. */
|
||||
track.sectorSize = RAW_SECTOR_SIZE;
|
||||
track.attr = DATA_TRACK;
|
||||
track.mode2 = true;
|
||||
@@ -427,6 +429,7 @@ bool CDROM_Interface_Image::LoadCueSheet(char *cuefile)
|
||||
track.attr = DATA_TRACK;
|
||||
track.mode2 = true;
|
||||
} else success = false;
|
||||
last_attr = track.attr;
|
||||
|
||||
canAddTrack = true;
|
||||
}
|
||||
@@ -480,6 +483,7 @@ bool CDROM_Interface_Image::LoadCueSheet(char *cuefile)
|
||||
track.track_number = 0xAA;
|
||||
// track.attr = 0;//sync with load iso
|
||||
track.attr = 0x16; /* Was 0x00 but I believe 0x16 is appropriate. */
|
||||
// track.attr = last_attr | 0x02;
|
||||
track.start = 0;
|
||||
track.length = 0;
|
||||
track.file = NULL;
|
||||
|
||||
@@ -57,8 +57,8 @@ void cdrom_image_log(const char *format, ...)
|
||||
va_end(ap);
|
||||
fflush(stdout);
|
||||
}
|
||||
#else
|
||||
(void)format;
|
||||
/* #else
|
||||
(void)format; */
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -66,51 +66,56 @@ void image_close(uint8_t id);
|
||||
|
||||
void image_audio_callback(uint8_t id, int16_t *output, int len)
|
||||
{
|
||||
if (!cdrom_drives[id].sound_on || (cdrom_image[id].cd_state != CD_PLAYING) || cdrom_image[id].image_is_iso)
|
||||
cdrom_t *dev = cdrom[id];
|
||||
|
||||
if (!cdrom_drives[id].sound_on || (dev->cd_state != CD_PLAYING) || cdrom_image[id].image_is_iso)
|
||||
{
|
||||
cdrom_image_log("image_audio_callback(i): Not playing\n", id);
|
||||
if (cdrom_ioctl[id].cd_state == CD_PLAYING)
|
||||
if (dev->cd_state == CD_PLAYING)
|
||||
{
|
||||
cdrom[id].seek_pos += (len >> 11);
|
||||
dev->seek_pos += (len >> 11);
|
||||
}
|
||||
memset(output, 0, len * 2);
|
||||
return;
|
||||
}
|
||||
while (cdrom_image[id].cd_buflen < len)
|
||||
while (dev->cd_buflen < len)
|
||||
{
|
||||
if (cdrom[id].seek_pos < cdrom_image[id].cd_end)
|
||||
if (dev->seek_pos < dev->cd_end)
|
||||
{
|
||||
if (!cdimg[id]->ReadSector((unsigned char*)&cdrom[id].cd_buffer[cdrom_image[id].cd_buflen], true, cdrom[id].seek_pos))
|
||||
if (!cdimg[id]->ReadSector((unsigned char*)&dev->cd_buffer[dev->cd_buflen], true, dev->seek_pos))
|
||||
{
|
||||
memset(&cdrom[id].cd_buffer[cdrom_image[id].cd_buflen], 0, (BUF_SIZE - cdrom_image[id].cd_buflen) * 2);
|
||||
cdrom_image[id].cd_state = CD_STOPPED;
|
||||
cdrom_image[id].cd_buflen = len;
|
||||
memset(&dev->cd_buffer[dev->cd_buflen], 0, (BUF_SIZE - dev->cd_buflen) * 2);
|
||||
dev->cd_state = CD_STOPPED;
|
||||
dev->cd_buflen = len;
|
||||
}
|
||||
else
|
||||
{
|
||||
cdrom[id].seek_pos++;
|
||||
cdrom_image[id].cd_buflen += (RAW_SECTOR_SIZE / 2);
|
||||
dev->seek_pos++;
|
||||
dev->cd_buflen += (RAW_SECTOR_SIZE / 2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(&cdrom[id].cd_buffer[cdrom_image[id].cd_buflen], 0, (BUF_SIZE - cdrom_image[id].cd_buflen) * 2);
|
||||
cdrom_image[id].cd_state = CD_STOPPED;
|
||||
cdrom_image[id].cd_buflen = len;
|
||||
memset(&dev->cd_buffer[dev->cd_buflen], 0, (BUF_SIZE - dev->cd_buflen) * 2);
|
||||
dev->cd_state = CD_STOPPED;
|
||||
dev->cd_buflen = len;
|
||||
}
|
||||
}
|
||||
memcpy(output, cdrom[id].cd_buffer, len * 2);
|
||||
memmove(cdrom[id].cd_buffer, &cdrom[id].cd_buffer[len], (BUF_SIZE - len) * 2);
|
||||
cdrom_image[id].cd_buflen -= len;
|
||||
memcpy(output, dev->cd_buffer, len * 2);
|
||||
memmove(dev->cd_buffer, &dev->cd_buffer[len], (BUF_SIZE - len) * 2);
|
||||
dev->cd_buflen -= len;
|
||||
}
|
||||
|
||||
void image_audio_stop(uint8_t id)
|
||||
{
|
||||
cdrom_image[id].cd_state = CD_STOPPED;
|
||||
cdrom_t *dev = cdrom[id];
|
||||
|
||||
dev->cd_state = CD_STOPPED;
|
||||
}
|
||||
|
||||
static void image_playaudio(uint8_t id, uint32_t pos, uint32_t len, int ismsf)
|
||||
{
|
||||
cdrom_t *dev = cdrom[id];
|
||||
if (!cdimg[id]) return;
|
||||
int number;
|
||||
unsigned char attr;
|
||||
@@ -120,8 +125,8 @@ static void image_playaudio(uint8_t id, uint32_t pos, uint32_t len, int ismsf)
|
||||
if (attr == DATA_TRACK)
|
||||
{
|
||||
cdrom_image_log("Can't play data track\n");
|
||||
cdrom[id].seek_pos = 0;
|
||||
cdrom_image[id].cd_state = CD_STOPPED;
|
||||
dev->seek_pos = 0;
|
||||
dev->cd_state = CD_STOPPED;
|
||||
return;
|
||||
}
|
||||
cdrom_image_log("Play audio - %08X %08X %i\n", pos, len, ismsf);
|
||||
@@ -141,7 +146,7 @@ static void image_playaudio(uint8_t id, uint32_t pos, uint32_t len, int ismsf)
|
||||
if (pos == 0xffffff)
|
||||
{
|
||||
cdrom_image_log("Playing from current position (MSF)\n");
|
||||
pos = cdrom[id].seek_pos;
|
||||
pos = dev->seek_pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -160,38 +165,46 @@ static void image_playaudio(uint8_t id, uint32_t pos, uint32_t len, int ismsf)
|
||||
if (pos == 0xffffffff)
|
||||
{
|
||||
cdrom_image_log("Playing from current position\n");
|
||||
pos = cdrom[id].seek_pos;
|
||||
pos = dev->seek_pos;
|
||||
}
|
||||
len += pos;
|
||||
}
|
||||
cdrom[id].seek_pos = pos;
|
||||
cdrom_image[id].cd_end = len;
|
||||
cdrom_image[id].cd_state = CD_PLAYING;
|
||||
cdrom_image[id].cd_buflen = 0;
|
||||
dev->seek_pos = pos;
|
||||
dev->cd_end = len;
|
||||
dev->cd_state = CD_PLAYING;
|
||||
dev->cd_buflen = 0;
|
||||
}
|
||||
|
||||
static void image_pause(uint8_t id)
|
||||
{
|
||||
cdrom_t *dev = cdrom[id];
|
||||
|
||||
if (!cdimg[id] || cdrom_image[id].image_is_iso) return;
|
||||
if (cdrom_image[id].cd_state == CD_PLAYING)
|
||||
cdrom_image[id].cd_state = CD_PAUSED;
|
||||
if (dev->cd_state == CD_PLAYING)
|
||||
dev->cd_state = CD_PAUSED;
|
||||
}
|
||||
|
||||
static void image_resume(uint8_t id)
|
||||
{
|
||||
cdrom_t *dev = cdrom[id];
|
||||
|
||||
if (!cdimg[id] || cdrom_image[id].image_is_iso) return;
|
||||
if (cdrom_image[id].cd_state == CD_PAUSED)
|
||||
cdrom_image[id].cd_state = CD_PLAYING;
|
||||
if (dev->cd_state == CD_PAUSED)
|
||||
dev->cd_state = CD_PLAYING;
|
||||
}
|
||||
|
||||
static void image_stop(uint8_t id)
|
||||
{
|
||||
cdrom_t *dev = cdrom[id];
|
||||
|
||||
if (!cdimg[id] || cdrom_image[id].image_is_iso) return;
|
||||
cdrom_image[id].cd_state = CD_STOPPED;
|
||||
dev->cd_state = CD_STOPPED;
|
||||
}
|
||||
|
||||
static int image_ready(uint8_t id)
|
||||
{
|
||||
cdrom_t *dev = cdrom[id];
|
||||
|
||||
if (!cdimg[id])
|
||||
return 0;
|
||||
|
||||
@@ -203,12 +216,6 @@ static int image_ready(uint8_t id)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (cdrom_image[id].image_changed)
|
||||
{
|
||||
cdrom_image[id].image_changed = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -239,6 +246,8 @@ static int image_get_last_block(uint8_t id, UNUSED(uint8_t starttrack), UNUSED(i
|
||||
|
||||
static int image_medium_changed(uint8_t id)
|
||||
{
|
||||
cdrom_t *dev = cdrom[id];
|
||||
|
||||
if (!cdimg[id])
|
||||
return 0;
|
||||
|
||||
@@ -252,23 +261,18 @@ static int image_medium_changed(uint8_t id)
|
||||
cdrom_drives[id].prev_host_drive = cdrom_drives[id].host_drive;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (cdrom_image[id].image_changed)
|
||||
{
|
||||
cdrom_image[id].image_changed = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint8_t image_getcurrentsubchannel(uint8_t id, uint8_t *b, int msf)
|
||||
{
|
||||
cdrom_t *dev = cdrom[id];
|
||||
if (!cdimg[id]) return 0;
|
||||
uint8_t ret;
|
||||
int pos=0;
|
||||
|
||||
uint32_t cdpos = cdrom[id].seek_pos;
|
||||
uint32_t cdpos = dev->seek_pos;
|
||||
TMSF relPos, absPos;
|
||||
unsigned char attr, track, index;
|
||||
cdimg[id]->GetAudioSub(cdpos, attr, track, index, relPos, absPos);
|
||||
@@ -279,9 +283,9 @@ static uint8_t image_getcurrentsubchannel(uint8_t id, uint8_t *b, int msf)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cdrom_image[id].cd_state == CD_PLAYING)
|
||||
if (dev->cd_state == CD_PLAYING)
|
||||
ret = 0x11;
|
||||
else if (cdrom_image[id].cd_state == CD_PAUSED)
|
||||
else if (dev->cd_state == CD_PAUSED)
|
||||
ret = 0x12;
|
||||
else
|
||||
ret = 0x13;
|
||||
@@ -762,10 +766,14 @@ read_mode2_xa_form2:
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mode2)
|
||||
goto read_mode2_non_xa;
|
||||
else
|
||||
if (mode2 && (form == 1))
|
||||
goto read_mode2_xa_form1;
|
||||
else if (!mode2)
|
||||
goto read_mode1;
|
||||
else {
|
||||
cdrom_image_log("CD-ROM %i: [Any Data] Attempting to read a data sector whose cooked size is not 2048 bytes\n", id);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
if (mode2)
|
||||
if (form == 1)
|
||||
@@ -819,7 +827,9 @@ read_mode2_xa_form2:
|
||||
|
||||
static uint32_t image_size(uint8_t id)
|
||||
{
|
||||
return cdrom_image[id].cdrom_capacity;
|
||||
cdrom_t *dev = cdrom[id];
|
||||
|
||||
return dev->cdrom_capacity;
|
||||
}
|
||||
|
||||
static int image_readtoc(uint8_t id, unsigned char *b, unsigned char starttrack, int msf, int maxlen, int single)
|
||||
@@ -953,10 +963,8 @@ static int image_readtoc_raw(uint8_t id, unsigned char *b, int maxlen)
|
||||
|
||||
cdimg[id]->GetAudioTracks(first_track, last_track, tmsf);
|
||||
|
||||
if (maxlen >= 3) b[2] = first_track;
|
||||
if (maxlen >= 4) b[3] = last_track;
|
||||
|
||||
if (maxlen <= 4) return len;
|
||||
b[2] = first_track;
|
||||
b[3] = last_track;
|
||||
|
||||
for (track = first_track; track <= last_track; track++)
|
||||
{
|
||||
@@ -996,11 +1004,12 @@ static int image_readtoc_raw(uint8_t id, unsigned char *b, int maxlen)
|
||||
|
||||
static int image_status(uint8_t id)
|
||||
{
|
||||
cdrom_t *dev = cdrom[id];
|
||||
if (!cdimg[id]) return CD_STATUS_EMPTY;
|
||||
if (cdrom_image[id].image_is_iso) return CD_STATUS_DATA_ONLY;
|
||||
if (cdimg[id]->HasAudioTracks())
|
||||
{
|
||||
switch(cdrom_image[id].cd_state)
|
||||
switch(dev->cd_state)
|
||||
{
|
||||
case CD_PLAYING:
|
||||
return CD_STATUS_PLAYING;
|
||||
@@ -1021,7 +1030,9 @@ void image_reset(UNUSED(uint8_t id))
|
||||
|
||||
void image_close(uint8_t id)
|
||||
{
|
||||
cdrom_image[id].cd_state = CD_STOPPED;
|
||||
cdrom_t *dev = cdrom[id];
|
||||
|
||||
dev->cd_state = CD_STOPPED;
|
||||
if (cdimg[id])
|
||||
{
|
||||
delete cdimg[id];
|
||||
@@ -1034,18 +1045,9 @@ static char afn[1024];
|
||||
|
||||
int image_open(uint8_t id, wchar_t *fn)
|
||||
{
|
||||
if (wcscmp(fn, cdrom_image[id].image_path) != 0)
|
||||
{
|
||||
cdrom_image[id].image_changed = 1;
|
||||
}
|
||||
cdrom_t *dev = cdrom[id];
|
||||
|
||||
/* Make sure image_changed stays when changing from an image to another image. */
|
||||
if (!cdrom_image[id].image_inited && (cdrom_drives[id].host_drive != 200)) cdrom_image[id].image_changed = 0;
|
||||
|
||||
if (!cdrom_image[id].image_inited || cdrom_image[id].image_changed)
|
||||
{
|
||||
wcscpy(cdrom_image[id].image_path, fn);
|
||||
}
|
||||
wcscpy(cdrom_image[id].image_path, fn);
|
||||
|
||||
if (! wcscasecmp(plat_get_extension(fn), L"ISO"))
|
||||
{
|
||||
@@ -1057,6 +1059,7 @@ int image_open(uint8_t id, wchar_t *fn)
|
||||
}
|
||||
|
||||
cdimg[id] = new CDROM_Interface_Image();
|
||||
memset(afn, 0, sizeof(afn));
|
||||
wcstombs(afn, fn, sizeof(afn));
|
||||
if (!cdimg[id]->SetDevice(afn, false))
|
||||
{
|
||||
@@ -1064,24 +1067,20 @@ int image_open(uint8_t id, wchar_t *fn)
|
||||
cdrom_set_null_handler(id);
|
||||
return 1;
|
||||
}
|
||||
cdrom_image[id].cd_state = CD_STOPPED;
|
||||
cdrom[id].seek_pos = 0;
|
||||
cdrom_image[id].cd_buflen = 0;
|
||||
cdrom_image[id].cdrom_capacity = image_get_last_block(id, 0, 0, 4096, 0) + 1;
|
||||
dev->cd_state = CD_STOPPED;
|
||||
dev->seek_pos = 0;
|
||||
dev->cd_buflen = 0;
|
||||
dev->cdrom_capacity = image_get_last_block(id, 0, 0, 4096, 0) + 1;
|
||||
cdrom_drives[id].handler = &image_cdrom;
|
||||
|
||||
if (!cdrom_image[id].image_inited || cdrom_image[id].image_changed)
|
||||
{
|
||||
if (!cdrom_image[id].image_inited)
|
||||
cdrom_image[id].image_inited = 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void image_exit(uint8_t id)
|
||||
{
|
||||
cdrom_image[id].image_inited = 0;
|
||||
cdrom_t *dev = cdrom[id];
|
||||
|
||||
dev->handler_inited = 0;
|
||||
}
|
||||
|
||||
/* TODO: Check for what data type a mixed CD is. */
|
||||
|
||||
34
src/config.c
34
src/config.c
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Configuration file handler.
|
||||
*
|
||||
* Version: @(#)config.c 1.0.44 2018/03/06
|
||||
* Version: @(#)config.c 1.0.46 2018/03/18
|
||||
*
|
||||
* Authors: Sarah Walker,
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -55,7 +55,6 @@
|
||||
#include "sound/sound.h"
|
||||
#include "video/video.h"
|
||||
#include "plat.h"
|
||||
#include "plat_joystick.h"
|
||||
#include "plat_midi.h"
|
||||
#include "ui.h"
|
||||
|
||||
@@ -649,22 +648,27 @@ load_network(void)
|
||||
} else
|
||||
network_type = NET_TYPE_NONE;
|
||||
|
||||
memset(network_pcap, '\0', sizeof(network_pcap));
|
||||
p = config_get_string(cat, "net_pcap_device", NULL);
|
||||
memset(network_host, '\0', sizeof(network_host));
|
||||
p = config_get_string(cat, "net_host_device", NULL);
|
||||
if (p == NULL) {
|
||||
p = config_get_string(cat, "net_host_device", NULL);
|
||||
if (p != NULL)
|
||||
config_delete_var(cat, "net_host_device");
|
||||
}
|
||||
if (p != NULL) {
|
||||
if ((network_dev_to_id(p) == -1) || (network_ndev == 1)) {
|
||||
if ((network_ndev == 1) && strcmp(network_pcap, "none")) {
|
||||
if ((network_ndev == 1) && strcmp(network_host, "none")) {
|
||||
ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2140);
|
||||
} else if (network_dev_to_id(p) == -1) {
|
||||
ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2141);
|
||||
}
|
||||
|
||||
strcpy(network_pcap, "none");
|
||||
strcpy(network_host, "none");
|
||||
} else {
|
||||
strcpy(network_pcap, p);
|
||||
strcpy(network_host, p);
|
||||
}
|
||||
} else
|
||||
strcpy(network_pcap, "none");
|
||||
strcpy(network_host, "none");
|
||||
|
||||
p = config_get_string(cat, "net_card", NULL);
|
||||
if (p != NULL)
|
||||
@@ -1095,7 +1099,6 @@ load_removable_devices(void)
|
||||
} else
|
||||
#endif
|
||||
wcsncpy(cdrom_image[c].image_path, wp, sizeof_w(cdrom_image[c].image_path));
|
||||
wcscpy(cdrom_image[c].prev_image_path, cdrom_image[c].image_path);
|
||||
|
||||
if (cdrom_drives[c].host_drive < 'A')
|
||||
cdrom_drives[c].host_drive = 0;
|
||||
@@ -1288,7 +1291,6 @@ load_other_removable_devices(void)
|
||||
} else
|
||||
#endif
|
||||
wcsncpy(cdrom_image[c].image_path, wp, sizeof_w(cdrom_image[c].image_path));
|
||||
wcscpy(cdrom_image[c].prev_image_path, cdrom_image[c].image_path);
|
||||
|
||||
if (cdrom_drives[c].host_drive < 'A')
|
||||
cdrom_drives[c].host_drive = 0;
|
||||
@@ -1754,14 +1756,14 @@ save_network(void)
|
||||
config_set_string(cat, "net_type",
|
||||
(network_type == NET_TYPE_SLIRP) ? "slirp" : "pcap");
|
||||
|
||||
if (network_pcap[0] != '\0') {
|
||||
if (! strcmp(network_pcap, "none"))
|
||||
config_delete_var(cat, "net_pcap_device");
|
||||
if (network_host[0] != '\0') {
|
||||
if (! strcmp(network_host, "none"))
|
||||
config_delete_var(cat, "net_host_device");
|
||||
else
|
||||
config_set_string(cat, "net_pcap_device", network_pcap);
|
||||
config_set_string(cat, "net_host_device", network_host);
|
||||
} else {
|
||||
/* config_set_string(cat, "net_pcap_device", "none"); */
|
||||
config_delete_var(cat, "net_pcap_device");
|
||||
/* config_set_string(cat, "net_host_device", "none"); */
|
||||
config_delete_var(cat, "net_host_device");
|
||||
}
|
||||
|
||||
if (network_card == 0)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* 808x CPU emulation.
|
||||
*
|
||||
@@ -18,13 +18,31 @@
|
||||
* 2 clocks - fetch opcode 1 2 clocks - execute
|
||||
* 2 clocks - fetch opcode 2 etc
|
||||
*
|
||||
* Version: @(#)808x.c 1.0.10 2017/12/03
|
||||
* Version: @(#)808x.c 1.0.2 2018/03/09
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Authors: Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
* Copyright 2008-2017 Sarah Walker.
|
||||
* Copyright 2016,2017 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -1212,7 +1230,7 @@ void execx86(int cycs)
|
||||
break;
|
||||
case 0x14: /*ADC AL,#8*/
|
||||
tempw=FETCH();
|
||||
setadc8(AL,tempw);
|
||||
setadc8(AL,tempw & 0xff);
|
||||
AL+=tempw+tempc;
|
||||
cycles-=4;
|
||||
break;
|
||||
@@ -2950,7 +2968,7 @@ void execx86(int cycs)
|
||||
if (temp)
|
||||
{
|
||||
tempw2=tempw%temp;
|
||||
AH=tempw2;
|
||||
AH=tempw2 & 0xff;
|
||||
tempw/=temp;
|
||||
AL=tempw&0xFF;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,39 @@
|
||||
/*
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Definitions for the code generator.
|
||||
*
|
||||
* Version: @(#)codegen.h 1.0.2 2018/03/14
|
||||
*
|
||||
* Authors: Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#ifndef _CODEGEN_H_
|
||||
#define _CODEGEN_H_
|
||||
|
||||
@@ -267,7 +303,7 @@ void codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t
|
||||
void codegen_generate_seg_restore();
|
||||
void codegen_set_op32();
|
||||
void codegen_flush();
|
||||
void codegen_check_flush(struct page_t *page, uint64_t mask, uint32_t phys_addr);
|
||||
void codegen_check_flush(page_t *page, uint64_t mask, uint32_t phys_addr);
|
||||
|
||||
extern int cpu_block_end;
|
||||
extern uint32_t codegen_endpc;
|
||||
|
||||
171
src/device.c
171
src/device.c
@@ -1,21 +1,41 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the generic device interface to handle
|
||||
* all devices attached to the emulator.
|
||||
*
|
||||
* Version: @(#)device.c 1.0.9 2018/03/02
|
||||
* Version: @(#)device.c 1.0.5 2018/03/18
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -32,8 +52,8 @@
|
||||
#define DEVICE_MAX 256 /* max # of devices */
|
||||
|
||||
|
||||
static device_t *devices[DEVICE_MAX];
|
||||
static void *device_priv[DEVICE_MAX];
|
||||
static device_t *devices[DEVICE_MAX];
|
||||
static device_t *device_current;
|
||||
|
||||
|
||||
@@ -45,48 +65,49 @@ device_init(void)
|
||||
|
||||
|
||||
void *
|
||||
device_add(device_t *d)
|
||||
device_add(const device_t *d)
|
||||
{
|
||||
void *priv = NULL;
|
||||
int c;
|
||||
|
||||
for (c=0; c<256; c++) {
|
||||
if (devices[c] == d) {
|
||||
fatal("device_add: device already exists!\n");
|
||||
break;
|
||||
if (devices[c] == (device_t *)d) {
|
||||
pclog("DEVICE: device already exists!\n");
|
||||
return(NULL);
|
||||
}
|
||||
if (devices[c] == NULL) break;
|
||||
}
|
||||
if (c >= DEVICE_MAX)
|
||||
fatal("device_add: too many devices\n");
|
||||
fatal("DEVICE: too many devices\n");
|
||||
|
||||
device_current = d;
|
||||
device_current = (device_t *)d;
|
||||
|
||||
if (d->init != NULL) {
|
||||
priv = d->init(d);
|
||||
if (priv == NULL) {
|
||||
if (d->name)
|
||||
fatal("device_add: device init failed (%s)\n", d->name);
|
||||
else
|
||||
fatal("device_add: device init failed\n");
|
||||
pclog("DEVICE: device '%s' init failed\n", d->name);
|
||||
else
|
||||
pclog("DEVICE: device init failed\n");
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
devices[c] = d;
|
||||
devices[c] = (device_t *)d;
|
||||
device_priv[c] = priv;
|
||||
|
||||
return priv;
|
||||
return(priv);
|
||||
}
|
||||
|
||||
|
||||
/* For devices that do not have an init function (internal video etc.) */
|
||||
void
|
||||
device_add_ex(device_t *d, void *priv)
|
||||
device_add_ex(const device_t *d, void *priv)
|
||||
{
|
||||
int c;
|
||||
|
||||
for (c=0; c<256; c++) {
|
||||
if (devices[c] == d) {
|
||||
if (devices[c] == (device_t *)d) {
|
||||
fatal("device_add: device already exists!\n");
|
||||
break;
|
||||
}
|
||||
@@ -95,9 +116,9 @@ device_add_ex(device_t *d, void *priv)
|
||||
if (c >= DEVICE_MAX)
|
||||
fatal("device_add: too many devices\n");
|
||||
|
||||
device_current = d;
|
||||
device_current = (device_t *)d;
|
||||
|
||||
devices[c] = d;
|
||||
devices[c] = (device_t *)d;
|
||||
device_priv[c] = priv;
|
||||
}
|
||||
|
||||
@@ -132,7 +153,7 @@ device_reset_all(void)
|
||||
|
||||
|
||||
void *
|
||||
device_get_priv(device_t *d)
|
||||
device_get_priv(const device_t *d)
|
||||
{
|
||||
int c;
|
||||
|
||||
@@ -148,7 +169,7 @@ device_get_priv(device_t *d)
|
||||
|
||||
|
||||
int
|
||||
device_available(device_t *d)
|
||||
device_available(const device_t *d)
|
||||
{
|
||||
#ifdef RELEASE_BUILD
|
||||
if (d->flags & DEVICE_NOT_WORKING) return(0);
|
||||
@@ -207,11 +228,11 @@ device_add_status_info(char *s, int max_len)
|
||||
char *
|
||||
device_get_config_string(char *s)
|
||||
{
|
||||
device_config_t *c = device_current->config;
|
||||
const device_config_t *c = device_current->config;
|
||||
|
||||
while (c && c->type != -1) {
|
||||
if (! strcmp(s, c->name))
|
||||
return(config_get_string((char *) device_current->name, s, (char *) c->default_string));
|
||||
return(config_get_string((char *)device_current->name, s, (char *)c->default_string));
|
||||
|
||||
c++;
|
||||
}
|
||||
@@ -223,11 +244,11 @@ device_get_config_string(char *s)
|
||||
int
|
||||
device_get_config_int(char *s)
|
||||
{
|
||||
device_config_t *c = device_current->config;
|
||||
const device_config_t *c = device_current->config;
|
||||
|
||||
while (c && c->type != -1) {
|
||||
if (! strcmp(s, c->name))
|
||||
return(config_get_int((char *) device_current->name, s, c->default_int));
|
||||
return(config_get_int((char *)device_current->name, s, c->default_int));
|
||||
|
||||
c++;
|
||||
}
|
||||
@@ -239,11 +260,11 @@ device_get_config_int(char *s)
|
||||
int
|
||||
device_get_config_int_ex(char *s, int default_int)
|
||||
{
|
||||
device_config_t *c = device_current->config;
|
||||
const device_config_t *c = device_current->config;
|
||||
|
||||
while (c && c->type != -1) {
|
||||
if (! strcmp(s, c->name))
|
||||
return(config_get_int((char *) device_current->name, s, default_int));
|
||||
return(config_get_int((char *)device_current->name, s, default_int));
|
||||
|
||||
c++;
|
||||
}
|
||||
@@ -255,11 +276,11 @@ device_get_config_int_ex(char *s, int default_int)
|
||||
int
|
||||
device_get_config_hex16(char *s)
|
||||
{
|
||||
device_config_t *c = device_current->config;
|
||||
const device_config_t *c = device_current->config;
|
||||
|
||||
while (c && c->type != -1) {
|
||||
if (! strcmp(s, c->name))
|
||||
return(config_get_hex16((char *) device_current->name, s, c->default_int));
|
||||
return(config_get_hex16((char *)device_current->name, s, c->default_int));
|
||||
|
||||
c++;
|
||||
}
|
||||
@@ -271,11 +292,11 @@ device_get_config_hex16(char *s)
|
||||
int
|
||||
device_get_config_hex20(char *s)
|
||||
{
|
||||
device_config_t *c = device_current->config;
|
||||
const device_config_t *c = device_current->config;
|
||||
|
||||
while (c && c->type != -1) {
|
||||
if (! strcmp(s, c->name))
|
||||
return(config_get_hex20((char *) device_current->name, s, c->default_int));
|
||||
return(config_get_hex20((char *)device_current->name, s, c->default_int));
|
||||
|
||||
c++;
|
||||
}
|
||||
@@ -287,11 +308,11 @@ device_get_config_hex20(char *s)
|
||||
int
|
||||
device_get_config_mac(char *s, int default_int)
|
||||
{
|
||||
device_config_t *c = device_current->config;
|
||||
const device_config_t *c = device_current->config;
|
||||
|
||||
while (c && c->type != -1) {
|
||||
if (! strcmp(s, c->name))
|
||||
return(config_get_mac((char *) device_current->name, s, default_int));
|
||||
return(config_get_mac((char *)device_current->name, s, default_int));
|
||||
|
||||
c++;
|
||||
}
|
||||
@@ -303,11 +324,11 @@ device_get_config_mac(char *s, int default_int)
|
||||
void
|
||||
device_set_config_int(char *s, int val)
|
||||
{
|
||||
device_config_t *c = device_current->config;
|
||||
const device_config_t *c = device_current->config;
|
||||
|
||||
while (c && c->type != -1) {
|
||||
if (! strcmp(s, c->name)) {
|
||||
config_set_int((char *) device_current->name, s, val);
|
||||
config_set_int((char *)device_current->name, s, val);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -319,11 +340,11 @@ device_set_config_int(char *s, int val)
|
||||
void
|
||||
device_set_config_hex16(char *s, int val)
|
||||
{
|
||||
device_config_t *c = device_current->config;
|
||||
const device_config_t *c = device_current->config;
|
||||
|
||||
while (c && c->type != -1) {
|
||||
if (! strcmp(s, c->name)) {
|
||||
config_set_hex16((char *) device_current->name, s, val);
|
||||
config_set_hex16((char *)device_current->name, s, val);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -335,11 +356,11 @@ device_set_config_hex16(char *s, int val)
|
||||
void
|
||||
device_set_config_hex20(char *s, int val)
|
||||
{
|
||||
device_config_t *c = device_current->config;
|
||||
const device_config_t *c = device_current->config;
|
||||
|
||||
while (c && c->type != -1) {
|
||||
if (! strcmp(s, c->name)) {
|
||||
config_set_hex20((char *) device_current->name, s, val);
|
||||
config_set_hex20((char *)device_current->name, s, val);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -351,11 +372,11 @@ device_set_config_hex20(char *s, int val)
|
||||
void
|
||||
device_set_config_mac(char *s, int val)
|
||||
{
|
||||
device_config_t *c = device_current->config;
|
||||
const device_config_t *c = device_current->config;
|
||||
|
||||
while (c && c->type != -1) {
|
||||
if (! strcmp(s, c->name)) {
|
||||
config_set_mac((char *) device_current->name, s, val);
|
||||
config_set_mac((char *)device_current->name, s, val);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -365,65 +386,43 @@ device_set_config_mac(char *s, int val)
|
||||
|
||||
|
||||
int
|
||||
device_is_valid(device_t *device, int machine_flags)
|
||||
device_is_valid(const device_t *device, int mflags)
|
||||
{
|
||||
if (!device)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (device == NULL) return(1);
|
||||
|
||||
if ((device->flags & DEVICE_AT) && !(machine_flags & MACHINE_AT)) {
|
||||
return 0;
|
||||
}
|
||||
if ((device->flags & DEVICE_AT) && !(mflags & MACHINE_AT)) return(0);
|
||||
|
||||
if ((device->flags & DEVICE_CBUS) && !(machine_flags & MACHINE_CBUS)) {
|
||||
return 0;
|
||||
}
|
||||
if ((device->flags & DEVICE_CBUS) && !(mflags & MACHINE_CBUS)) return(0);
|
||||
|
||||
if ((device->flags & DEVICE_ISA) && !(machine_flags & MACHINE_ISA)) {
|
||||
return 0;
|
||||
}
|
||||
if ((device->flags & DEVICE_ISA) && !(mflags & MACHINE_ISA)) return(0);
|
||||
|
||||
if ((device->flags & DEVICE_MCA) && !(machine_flags & MACHINE_MCA)) {
|
||||
return 0;
|
||||
}
|
||||
if ((device->flags & DEVICE_MCA) && !(mflags & MACHINE_MCA)) return(0);
|
||||
|
||||
if ((device->flags & DEVICE_EISA) && !(machine_flags & MACHINE_EISA)) {
|
||||
return 0;
|
||||
}
|
||||
if ((device->flags & DEVICE_EISA) && !(mflags & MACHINE_EISA)) return(0);
|
||||
|
||||
if ((device->flags & DEVICE_VLB) && !(machine_flags & MACHINE_VLB)) {
|
||||
return 0;
|
||||
}
|
||||
if ((device->flags & DEVICE_VLB) && !(mflags & MACHINE_VLB)) return(0);
|
||||
|
||||
if ((device->flags & DEVICE_PCI) && !(machine_flags & MACHINE_PCI)) {
|
||||
return 0;
|
||||
}
|
||||
if ((device->flags & DEVICE_PCI) && !(mflags & MACHINE_PCI)) return(0);
|
||||
|
||||
if ((device->flags & DEVICE_PS2) && !(machine_flags & MACHINE_HDC_PS2)) {
|
||||
return 0;
|
||||
}
|
||||
if ((device->flags & DEVICE_PS2) && !(mflags & MACHINE_HDC_PS2)) return(0);
|
||||
if ((device->flags & DEVICE_AGP) && !(mflags & MACHINE_AGP)) return(0);
|
||||
|
||||
if ((device->flags & DEVICE_AGP) && !(machine_flags & MACHINE_AGP)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
machine_get_config_int(char *s)
|
||||
{
|
||||
device_t *d = machine_getdevice(machine);
|
||||
device_config_t *c;
|
||||
const device_t *d = machine_getdevice(machine);
|
||||
const device_config_t *c;
|
||||
|
||||
if (d == NULL) return(0);
|
||||
|
||||
c = d->config;
|
||||
while (c && c->type != -1) {
|
||||
if (! strcmp(s, c->name))
|
||||
return(config_get_int((char *) d->name, s, c->default_int));
|
||||
return(config_get_int((char *)d->name, s, c->default_int));
|
||||
|
||||
c++;
|
||||
}
|
||||
@@ -435,15 +434,15 @@ machine_get_config_int(char *s)
|
||||
char *
|
||||
machine_get_config_string(char *s)
|
||||
{
|
||||
device_t *d = machine_getdevice(machine);
|
||||
device_config_t *c;
|
||||
const device_t *d = machine_getdevice(machine);
|
||||
const device_config_t *c;
|
||||
|
||||
if (d == NULL) return(0);
|
||||
|
||||
c = d->config;
|
||||
while (c && c->type != -1) {
|
||||
if (! strcmp(s, c->name))
|
||||
return(config_get_string((char *) d->name, s, (char *) c->default_string));
|
||||
return(config_get_string((char *)d->name, s, (char *)c->default_string));
|
||||
|
||||
c++;
|
||||
}
|
||||
|
||||
55
src/device.h
55
src/device.h
@@ -1,23 +1,40 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the generic device interface to handle
|
||||
* all devices attached to the emulator.
|
||||
* Definitions for the device handler.
|
||||
*
|
||||
* Version: @(#)device.h 1.0.8 2018/02/18
|
||||
* Version: @(#)device.h 1.0.3 2018/03/15
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#ifndef EMU_DEVICE_H
|
||||
# define EMU_DEVICE_H
|
||||
@@ -81,7 +98,7 @@ typedef struct _device_ {
|
||||
uint32_t flags; /* system flags */
|
||||
uint32_t local; /* flags local to device */
|
||||
|
||||
void *(*init)(struct _device_ *);
|
||||
void *(*init)(const struct _device_ *);
|
||||
void (*close)(void *p);
|
||||
void (*reset)(void *p);
|
||||
int (*available)(/*void*/);
|
||||
@@ -89,7 +106,7 @@ typedef struct _device_ {
|
||||
void (*force_redraw)(void *p);
|
||||
void (*add_status_info)(char *s, int max_len, void *p);
|
||||
|
||||
device_config_t *config;
|
||||
const device_config_t *config;
|
||||
} device_t;
|
||||
|
||||
|
||||
@@ -98,12 +115,12 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
extern void device_init(void);
|
||||
extern void *device_add(device_t *d);
|
||||
extern void device_add_ex(device_t *d, void *priv);
|
||||
extern void *device_add(const device_t *d);
|
||||
extern void device_add_ex(const device_t *d, void *priv);
|
||||
extern void device_close_all(void);
|
||||
extern void device_reset_all(void);
|
||||
extern void *device_get_priv(device_t *d);
|
||||
extern int device_available(device_t *d);
|
||||
extern void *device_get_priv(const device_t *d);
|
||||
extern int device_available(const device_t *d);
|
||||
extern void device_speed_changed(void);
|
||||
extern void device_force_redraw(void);
|
||||
extern void device_add_status_info(char *s, int max_len);
|
||||
@@ -118,7 +135,7 @@ extern void device_set_config_hex16(char *s, int val);
|
||||
extern void device_set_config_hex20(char *s, int val);
|
||||
extern void device_set_config_mac(char *s, int val);
|
||||
extern char *device_get_config_string(char *name);
|
||||
extern int device_is_valid(device_t *device, int machine_flags);
|
||||
extern int device_is_valid(const device_t *device, int machine_flags);
|
||||
|
||||
extern int machine_get_config_int(char *s);
|
||||
extern char *machine_get_config_string(char *s);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Common code to handle all sorts of disk controllers.
|
||||
*
|
||||
* Version: @(#)hdc.c 1.0.9 2018/02/14
|
||||
* Version: @(#)hdc.c 1.0.12 2018/03/19
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "../machine/machine.h"
|
||||
#include "../device.h"
|
||||
#include "hdc.h"
|
||||
#include "hdc_ide.h"
|
||||
|
||||
|
||||
char *hdc_name; /* configured HDC name */
|
||||
@@ -31,7 +32,7 @@ int hdc_current;
|
||||
|
||||
|
||||
static void *
|
||||
null_init(device_t *info)
|
||||
null_init(const device_t *info)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
@@ -43,7 +44,7 @@ null_close(void *priv)
|
||||
}
|
||||
|
||||
|
||||
static device_t null_device = {
|
||||
static const device_t null_device = {
|
||||
"Null HDC", 0, 0,
|
||||
null_init, null_close, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL
|
||||
@@ -51,7 +52,7 @@ static device_t null_device = {
|
||||
|
||||
|
||||
static void *
|
||||
inthdc_init(device_t *info)
|
||||
inthdc_init(const device_t *info)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
@@ -63,71 +64,71 @@ inthdc_close(void *priv)
|
||||
}
|
||||
|
||||
|
||||
static device_t inthdc_device = {
|
||||
static const device_t inthdc_device = {
|
||||
"Internal Controller", 0, 0,
|
||||
inthdc_init, inthdc_close, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
|
||||
static struct {
|
||||
char *name;
|
||||
char *internal_name;
|
||||
device_t *device;
|
||||
int is_mfm;
|
||||
static const struct {
|
||||
const char *name;
|
||||
const char *internal_name;
|
||||
const device_t *device;
|
||||
} controllers[] = {
|
||||
{ "None", "none",
|
||||
&null_device, 0 },
|
||||
&null_device },
|
||||
|
||||
{ "Internal Controller", "internal",
|
||||
&inthdc_device, 0 },
|
||||
&inthdc_device },
|
||||
|
||||
{ "[ISA] [MFM] IBM PC Fixed Disk Adapter", "mfm_xt",
|
||||
&mfm_xt_xebec_device, 1 },
|
||||
&mfm_xt_xebec_device },
|
||||
|
||||
{ "[ISA] [MFM] DTC-5150X Fixed Disk Adapter", "mfm_dtc5150x",
|
||||
&mfm_xt_dtc5150x_device, 1 },
|
||||
&mfm_xt_dtc5150x_device },
|
||||
|
||||
{ "[ISA] [MFM] IBM PC/AT Fixed Disk Adapter", "mfm_at",
|
||||
&mfm_at_wd1003_device, 1 },
|
||||
&mfm_at_wd1003_device },
|
||||
|
||||
{ "[ISA] [ESDI] PC/AT ESDI Fixed Disk Adapter", "esdi_at",
|
||||
&esdi_at_wd1007vse1_device, 0 },
|
||||
&esdi_at_wd1007vse1_device },
|
||||
|
||||
{ "[ISA] [IDE] PC/AT IDE Adapter", "ide_isa",
|
||||
&ide_isa_device, 0 },
|
||||
&ide_isa_device },
|
||||
|
||||
{ "[ISA] [IDE] PC/AT IDE Adapter (Dual-Channel)", "ide_isa_2ch",
|
||||
&ide_isa_2ch_device, 0 },
|
||||
&ide_isa_2ch_device },
|
||||
|
||||
{ "[ISA] [IDE] PC/AT XTIDE", "xtide_at",
|
||||
&xtide_at_device, 0 },
|
||||
&xtide_at_device },
|
||||
|
||||
{ "[ISA] [IDE] PS/2 AT XTIDE (1.1.5)", "xtide_at_ps2",
|
||||
&xtide_at_ps2_device, 0 },
|
||||
&xtide_at_ps2_device },
|
||||
|
||||
{ "[ISA] [XT IDE] Acculogic XT IDE", "xtide_acculogic",
|
||||
&xtide_acculogic_device, 0 },
|
||||
&xtide_acculogic_device },
|
||||
|
||||
{ "[ISA] [XT IDE] PC/XT XTIDE", "xtide",
|
||||
&xtide_device , 0 },
|
||||
&xtide_device },
|
||||
|
||||
{ "[MCA] [ESDI] IBM PS/2 ESDI Fixed Disk Adapter","esdi_mca",
|
||||
&esdi_ps2_device, 1 },
|
||||
&esdi_ps2_device },
|
||||
|
||||
{ "[PCI] [IDE] PCI IDE Adapter", "ide_pci",
|
||||
&ide_pci_device, 0 },
|
||||
&ide_pci_device },
|
||||
|
||||
{ "[PCI] [IDE] PCI IDE Adapter (Dual-Channel)", "ide_pci_2ch",
|
||||
&ide_pci_2ch_device, 0 },
|
||||
&ide_pci_2ch_device },
|
||||
|
||||
{ "[VLB] [IDE] PC/AT IDE Adapter", "vlb_isa",
|
||||
&ide_vlb_device, 0 },
|
||||
&ide_vlb_device },
|
||||
|
||||
{ "[VLB] [IDE] PC/AT IDE Adapter (Dual-Channel)", "vlb_isa_2ch",
|
||||
&ide_vlb_2ch_device, 0 },
|
||||
&ide_vlb_2ch_device },
|
||||
|
||||
{ "", "", NULL, 0 }
|
||||
{ "", "",
|
||||
NULL }
|
||||
};
|
||||
|
||||
|
||||
@@ -139,8 +140,8 @@ hdc_init(char *name)
|
||||
|
||||
pclog("HDC: initializing..\n");
|
||||
|
||||
for (c=0; controllers[c].device; c++) {
|
||||
if (! strcmp(name, controllers[c].internal_name)) {
|
||||
for (c = 0; controllers[c].device; c++) {
|
||||
if (! strcmp(name, (char *) controllers[c].internal_name)) {
|
||||
hdc_current = c;
|
||||
break;
|
||||
}
|
||||
@@ -158,24 +159,33 @@ hdc_reset(void)
|
||||
/* If we have a valid controller, add its device. */
|
||||
if (hdc_current > 1)
|
||||
device_add(controllers[hdc_current].device);
|
||||
|
||||
/* Reconfire and reset the IDE layer. */
|
||||
ide_ter_disable();
|
||||
ide_qua_disable();
|
||||
if (ide_enable[2])
|
||||
ide_ter_init();
|
||||
if (ide_enable[3])
|
||||
ide_qua_init();
|
||||
ide_reset_hard();
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
hdc_get_name(int hdc)
|
||||
{
|
||||
return(controllers[hdc].name);
|
||||
return((char *) controllers[hdc].name);
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
hdc_get_internal_name(int hdc)
|
||||
{
|
||||
return(controllers[hdc].internal_name);
|
||||
return((char *) controllers[hdc].internal_name);
|
||||
}
|
||||
|
||||
|
||||
device_t *
|
||||
const device_t *
|
||||
hdc_get_device(int hdc)
|
||||
{
|
||||
return(controllers[hdc].device);
|
||||
@@ -194,10 +204,3 @@ hdc_available(int hdc)
|
||||
{
|
||||
return(device_available(controllers[hdc].device));
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
hdc_current_is_mfm(void)
|
||||
{
|
||||
return(controllers[hdc_current].is_mfm);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Definitions for the common disk controller handler.
|
||||
*
|
||||
* Version: @(#)hdc.h 1.0.5 2018/02/14
|
||||
* Version: @(#)hdc.h 1.0.7 2018/03/19
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
@@ -32,25 +32,25 @@ extern char *hdc_name;
|
||||
extern int hdc_current;
|
||||
|
||||
|
||||
extern device_t mfm_xt_xebec_device; /* mfm_xt_xebec */
|
||||
extern device_t mfm_xt_dtc5150x_device; /* mfm_xt_dtc */
|
||||
extern device_t mfm_at_wd1003_device; /* mfm_at_wd1003 */
|
||||
extern const device_t mfm_xt_xebec_device; /* mfm_xt_xebec */
|
||||
extern const device_t mfm_xt_dtc5150x_device; /* mfm_xt_dtc */
|
||||
extern const device_t mfm_at_wd1003_device; /* mfm_at_wd1003 */
|
||||
|
||||
extern device_t esdi_at_wd1007vse1_device; /* esdi_at */
|
||||
extern device_t esdi_ps2_device; /* esdi_mca */
|
||||
extern const device_t esdi_at_wd1007vse1_device; /* esdi_at */
|
||||
extern const device_t esdi_ps2_device; /* esdi_mca */
|
||||
|
||||
extern device_t ide_isa_device; /* isa_ide */
|
||||
extern device_t ide_isa_2ch_device; /* isa_ide_2ch */
|
||||
extern device_t ide_isa_2ch_opt_device; /* isa_ide_2ch_opt */
|
||||
extern device_t ide_vlb_device; /* vlb_ide */
|
||||
extern device_t ide_vlb_2ch_device; /* vlb_ide_2ch */
|
||||
extern device_t ide_pci_device; /* pci_ide */
|
||||
extern device_t ide_pci_2ch_device; /* pci_ide_2ch */
|
||||
extern const device_t ide_isa_device; /* isa_ide */
|
||||
extern const device_t ide_isa_2ch_device; /* isa_ide_2ch */
|
||||
extern const device_t ide_isa_2ch_opt_device; /* isa_ide_2ch_opt */
|
||||
extern const device_t ide_vlb_device; /* vlb_ide */
|
||||
extern const device_t ide_vlb_2ch_device; /* vlb_ide_2ch */
|
||||
extern const device_t ide_pci_device; /* pci_ide */
|
||||
extern const device_t ide_pci_2ch_device; /* pci_ide_2ch */
|
||||
|
||||
extern device_t xtide_device; /* xtide_xt */
|
||||
extern device_t xtide_at_device; /* xtide_at */
|
||||
extern device_t xtide_acculogic_device; /* xtide_ps2 */
|
||||
extern device_t xtide_at_ps2_device; /* xtide_at_ps2 */
|
||||
extern const device_t xtide_device; /* xtide_xt */
|
||||
extern const device_t xtide_at_device; /* xtide_at */
|
||||
extern const device_t xtide_acculogic_device; /* xtide_ps2 */
|
||||
extern const device_t xtide_at_ps2_device; /* xtide_at_ps2 */
|
||||
|
||||
|
||||
extern void hdc_init(char *name);
|
||||
@@ -58,10 +58,9 @@ extern void hdc_reset(void);
|
||||
|
||||
extern char *hdc_get_name(int hdc);
|
||||
extern char *hdc_get_internal_name(int hdc);
|
||||
extern device_t *hdc_get_device(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 int hdc_current_is_mfm(void);
|
||||
|
||||
|
||||
#endif /*EMU_HDC_H*/
|
||||
|
||||
@@ -8,15 +8,15 @@
|
||||
*
|
||||
* Driver for the ESDI controller (WD1007-vse1) for PC/AT.
|
||||
*
|
||||
* Version: @(#)hdc_esdi_at.c 1.0.8 2017/11/08
|
||||
* Version: @(#)hdc_esdi_at.c 1.0.9 2018/03/18
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2008-2017 Sarah Walker.
|
||||
* Copyright 2016,2017 Miran Grca.
|
||||
* Copyright 2017 Fred N. van Kempen.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*/
|
||||
#define _LARGEFILE_SOURCE
|
||||
#define _LARGEFILE64_SOURCE
|
||||
@@ -770,7 +770,7 @@ loadhd(esdi_t *esdi, int hdd_num, int d, const wchar_t *fn)
|
||||
|
||||
|
||||
static void *
|
||||
wd1007vse1_init(device_t *info)
|
||||
wd1007vse1_init(const device_t *info)
|
||||
{
|
||||
int c, d;
|
||||
|
||||
@@ -835,7 +835,7 @@ wd1007vse1_available(void)
|
||||
}
|
||||
|
||||
|
||||
device_t esdi_at_wd1007vse1_device = {
|
||||
const device_t esdi_at_wd1007vse1_device = {
|
||||
"Western Digital WD1007V-SE1 (ESDI)",
|
||||
DEVICE_ISA | DEVICE_AT,
|
||||
0,
|
||||
|
||||
@@ -52,13 +52,13 @@
|
||||
* however, are auto-configured by the system software as
|
||||
* shown above.
|
||||
*
|
||||
* Version: @(#)hdc_esdi_mca.c 1.0.8 2017/11/04
|
||||
* Version: @(#)hdc_esdi_mca.c 1.0.9 2018/03/18
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2008-2017 Sarah Walker.
|
||||
* Copyright 2017 Fred N. van Kempen.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -1041,7 +1041,7 @@ esdi_mca_write(int port, uint8_t val, void *priv)
|
||||
|
||||
|
||||
static void *
|
||||
esdi_init(device_t *info)
|
||||
esdi_init(const device_t *info)
|
||||
{
|
||||
drive_t *drive;
|
||||
esdi_t *dev;
|
||||
@@ -1135,7 +1135,7 @@ esdi_available(void)
|
||||
}
|
||||
|
||||
|
||||
device_t esdi_ps2_device = {
|
||||
const device_t esdi_ps2_device = {
|
||||
"IBM ESDI Fixed Disk Adapter (MCA)",
|
||||
DEVICE_MCA, 0,
|
||||
esdi_init, esdi_close, NULL,
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* Implementation of the IDE emulation for hard disks and ATAPI
|
||||
* CD-ROM devices.
|
||||
*
|
||||
* Version: @(#)hdc_ide.c 1.0.35 2018/03/16
|
||||
* Version: @(#)hdc_ide.c 1.0.43 2018/03/20
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -503,11 +503,12 @@ static void ide_atapi_zip_identify(IDE *ide)
|
||||
uint8_t zip_id;
|
||||
int32_t d;
|
||||
|
||||
memset(ide->buffer, 0, 512);
|
||||
zip_id = atapi_zip_drives[ide->channel];
|
||||
|
||||
/* Using (2<<5) below makes the ASUS P/I-P54TP4XE misdentify the ZIP drive
|
||||
as a LS-120. */
|
||||
ide->buffer[0] = 0x8000 | (0<<8) | 0x80 | (1<<5); /* ATAPI device, direct-access device, removable media, accelerated DRQ */
|
||||
ide->buffer[0] = 0x8000 | (0<<8) | 0x80 | (1<<5); /* ATAPI device, direct-access device, removable media, interrupt DRQ */
|
||||
ide_padstr((char *) (ide->buffer + 10), "", 20); /* Serial Number */
|
||||
if (zip_drives[zip_id].is_250) {
|
||||
ide_padstr((char *) (ide->buffer + 23), "42.S", 8); /* Firmware */
|
||||
@@ -516,6 +517,8 @@ static void ide_atapi_zip_identify(IDE *ide)
|
||||
ide_padstr((char *) (ide->buffer + 23), "E.08", 8); /* Firmware */
|
||||
ide_padstr((char *) (ide->buffer + 27), "IOMEGA ZIP 100 ATAPI", 40); /* Model */
|
||||
}
|
||||
|
||||
ide->buffer[48] = 1; /*Dword transfers supported*/
|
||||
ide->buffer[49] = 0x200; /* LBA supported */
|
||||
|
||||
/* Note by Kotori: Look at this if this is supported by ZIP at all. */
|
||||
@@ -543,6 +546,7 @@ static void ide_atapi_zip_identify(IDE *ide)
|
||||
ide->buffer[52] = 120;
|
||||
ide->buffer[53] = 2; /*Words 64-70 are valid*/
|
||||
ide->buffer[63] = 0x0003; /*Multi-word DMA 0 & 1*/
|
||||
ide->buffer[88] = 7;
|
||||
ide->buffer[64] = 0x0001; /*PIO Mode 3*/
|
||||
ide->buffer[65] = 120;
|
||||
ide->buffer[66] = 120;
|
||||
@@ -555,11 +559,12 @@ static void ide_atapi_zip_identify(IDE *ide)
|
||||
d <<= 8;
|
||||
if ((ide->mdma_mode & 0x300) == 0x200)
|
||||
ide->buffer[88] |= d;
|
||||
else if ((ide->mdma_mode & 0x300) == 0x100)
|
||||
ide->buffer[63] |= d;
|
||||
else if ((ide->mdma_mode & 0x300) == 0x400) {
|
||||
if ((ide->mdma_mode & 0xff) >= 3)
|
||||
ide->buffer[64] |= d;
|
||||
} else
|
||||
ide->buffer[63] |= d;
|
||||
}
|
||||
ide_log("PIDENTIFY DMA Mode: %04X, %04X\n", ide->buffer[62], ide->buffer[63]);
|
||||
}
|
||||
}
|
||||
@@ -639,8 +644,8 @@ void ide_set_signature(IDE *ide)
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom_set_signature(cdrom_id);
|
||||
ide->secount = cdrom[cdrom_id].phase;
|
||||
ide->cylinder = cdrom[cdrom_id].request_length;
|
||||
ide->secount = cdrom[cdrom_id]->phase;
|
||||
ide->cylinder = cdrom[cdrom_id]->request_length;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -685,7 +690,7 @@ static int ide_set_features(IDE *ide)
|
||||
if (!PCI || !dma || (ide->board >= 2))
|
||||
max_pio = 0;
|
||||
else
|
||||
max_pio = 2;
|
||||
max_pio = 4;
|
||||
}
|
||||
|
||||
ide_log("Features code %02X\n", features);
|
||||
@@ -832,7 +837,7 @@ void ide_reset(void)
|
||||
}
|
||||
else if ((d < 8) && ide_drive_is_cdrom(&ide_drives[d]))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[d]].status = READY_STAT | DSC_STAT;
|
||||
cdrom[atapi_cdrom_drives[d]]->status = READY_STAT | DSC_STAT;
|
||||
}
|
||||
ide_drives[d].atastat = READY_STAT | DSC_STAT;
|
||||
ide_drives[d].service = 0;
|
||||
@@ -861,16 +866,16 @@ void ide_reset(void)
|
||||
{
|
||||
ide_log("Found IDE hard disk on channel %i\n", hdd[d].ide_channel);
|
||||
loadhd(&ide_drives[hdd[d].ide_channel], d, hdd[d].fn);
|
||||
ide_drives[hdd[d].ide_channel].sector_buffer = NULL; /* Important, makes sure malloc does not reuse an existing pointer from elsewhere. */
|
||||
ide_drives[hdd[d].ide_channel].sector_buffer = (uint8_t *) malloc(256*512);
|
||||
memset(ide_drives[hdd[d].ide_channel].sector_buffer, 0, 256*512);
|
||||
if (++c >= (IDE_NUM+XTIDE_NUM)) break;
|
||||
}
|
||||
if ((hdd[d].bus==HDD_BUS_XTIDE) && (hdd[d].xtide_channel < XTIDE_NUM))
|
||||
{
|
||||
ide_log("Found XT IDE hard disk on channel %i\n", hdd[d].xtide_channel);
|
||||
loadhd(&ide_drives[hdd[d].xtide_channel | 8], d, hdd[d].fn);
|
||||
ide_drives[hdd[d].xtide_channel | 8].sector_buffer = NULL; /* Important, makes sure malloc does not reuse an existing pointer from elsewhere. */
|
||||
ide_drives[hdd[d].xtide_channel | 8].sector_buffer = (uint8_t *) malloc(256*512);
|
||||
memset(ide_drives[hdd[d].ide_channel].sector_buffer, 0, 256*512);
|
||||
if (++c >= (IDE_NUM+XTIDE_NUM)) break;
|
||||
}
|
||||
}
|
||||
@@ -884,8 +889,8 @@ void ide_reset(void)
|
||||
ide_drives[d].type = IDE_CDROM;
|
||||
|
||||
if (ide_drives[d].type != IDE_NONE) {
|
||||
ide_drives[d].buffer = NULL; /* Important, makes sure malloc does not reuse an existing pointer from elsewhere. */
|
||||
ide_drives[d].buffer = (uint16_t *) malloc(65536 * sizeof(uint16_t));
|
||||
memset(ide_drives[d].buffer, 0, 65536 * sizeof(uint16_t));
|
||||
}
|
||||
|
||||
ide_set_signature(&ide_drives[d]);
|
||||
@@ -912,6 +917,23 @@ void ide_reset(void)
|
||||
}
|
||||
|
||||
|
||||
void ide_set_all_signatures(void)
|
||||
{
|
||||
int d;
|
||||
|
||||
for (d = 0; d < IDE_NUM; d++)
|
||||
{
|
||||
ide_set_signature(&ide_drives[d]);
|
||||
|
||||
if (ide_drives[d].sector_buffer)
|
||||
memset(ide_drives[d].sector_buffer, 0, 256*512);
|
||||
|
||||
if (ide_drives[d].buffer)
|
||||
memset(ide_drives[d].buffer, 0, 65536 * sizeof(uint16_t));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ide_reset_hard(void)
|
||||
{
|
||||
int d;
|
||||
@@ -1037,7 +1059,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
ide_log("ATAPI transfer mode: %s\n", (val & 1) ? "DMA" : "PIO");
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board]]].features = val;
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board]]]->features = val;
|
||||
}
|
||||
ide->cylprecomp = val;
|
||||
|
||||
@@ -1047,7 +1069,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide_other))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board] ^ 1]].features = val;
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board] ^ 1]]->features = val;
|
||||
}
|
||||
ide_other->cylprecomp = val;
|
||||
return;
|
||||
@@ -1061,7 +1083,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
ide_log("Sector count write: %i\n", val);
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board]]].phase = val;
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board]]]->phase = val;
|
||||
}
|
||||
ide->secount = val;
|
||||
|
||||
@@ -1073,7 +1095,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
else if (ide_drive_is_cdrom(ide_other))
|
||||
{
|
||||
ide_log("Other sector count write: %i\n", val);
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board] ^ 1]].phase = val;
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board] ^ 1]]->phase = val;
|
||||
}
|
||||
ide_other->secount = val;
|
||||
return;
|
||||
@@ -1093,8 +1115,8 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board]]].request_length &= 0xFF00;
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board]]].request_length |= val;
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board]]]->request_length &= 0xFF00;
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board]]]->request_length |= val;
|
||||
}
|
||||
ide->cylinder = (ide->cylinder & 0xFF00) | val;
|
||||
ide->lba_addr = (ide->lba_addr & 0xFFF00FF) | (val << 8);
|
||||
@@ -1106,8 +1128,8 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide_other))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board] ^ 1]].request_length &= 0xFF00;
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board] ^ 1]].request_length |= val;
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board] ^ 1]]->request_length &= 0xFF00;
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board] ^ 1]]->request_length |= val;
|
||||
}
|
||||
ide_other->cylinder = (ide_other->cylinder&0xFF00) | val;
|
||||
ide_other->lba_addr = (ide_other->lba_addr&0xFFF00FF) | (val << 8);
|
||||
@@ -1121,8 +1143,8 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board]]].request_length &= 0xFF;
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board]]].request_length |= (val << 8);
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board]]]->request_length &= 0xFF;
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board]]]->request_length |= (val << 8);
|
||||
}
|
||||
ide->cylinder = (ide->cylinder & 0xFF) | (val << 8);
|
||||
ide->lba_addr = (ide->lba_addr & 0xF00FFFF) | (val << 16);
|
||||
@@ -1134,8 +1156,8 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide_other))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board] ^ 1]].request_length &= 0xFF;
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board] ^ 1]].request_length |= (val << 8);
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board] ^ 1]]->request_length &= 0xFF;
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board] ^ 1]]->request_length |= (val << 8);
|
||||
}
|
||||
ide_other->cylinder = (ide_other->cylinder & 0xFF) | (val << 8);
|
||||
ide_other->lba_addr = (ide_other->lba_addr & 0xF00FFFF) | (val << 16);
|
||||
@@ -1167,11 +1189,11 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].status = READY_STAT | DSC_STAT;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].error = 1;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].phase = 1;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].request_length = 0xEB14;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].callback = 0LL;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->status = READY_STAT | DSC_STAT;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->error = 1;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->phase = 1;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->request_length = 0xEB14;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->callback = 0LL;
|
||||
ide->cylinder = 0xEB14;
|
||||
}
|
||||
|
||||
@@ -1186,11 +1208,11 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide_other))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[ide_other->channel]].status = READY_STAT | DSC_STAT;
|
||||
cdrom[atapi_cdrom_drives[ide_other->channel]].error = 1;
|
||||
cdrom[atapi_cdrom_drives[ide_other->channel]].phase = 1;
|
||||
cdrom[atapi_cdrom_drives[ide_other->channel]].request_length = 0xEB14;
|
||||
cdrom[atapi_cdrom_drives[ide_other->channel]].callback = 0LL;
|
||||
cdrom[atapi_cdrom_drives[ide_other->channel]]->status = READY_STAT | DSC_STAT;
|
||||
cdrom[atapi_cdrom_drives[ide_other->channel]]->error = 1;
|
||||
cdrom[atapi_cdrom_drives[ide_other->channel]]->phase = 1;
|
||||
cdrom[atapi_cdrom_drives[ide_other->channel]]->request_length = 0xEB14;
|
||||
cdrom[atapi_cdrom_drives[ide_other->channel]]->callback = 0LL;
|
||||
ide->cylinder = 0xEB14;
|
||||
}
|
||||
|
||||
@@ -1228,7 +1250,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].error = 0;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->error = 0;
|
||||
}
|
||||
if (((val >= WIN_RESTORE) && (val <= 0x1F)) || ((val >= WIN_SEEK) && (val <= 0x7F)))
|
||||
{
|
||||
@@ -1238,7 +1260,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].status = READY_STAT;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->status = READY_STAT;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1251,7 +1273,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
}
|
||||
if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].callback = 100LL*IDE_TIME;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->callback = 100LL*IDE_TIME;
|
||||
}
|
||||
idecallback[ide_board]=40000LL * TIMER_USEC /*100LL*IDE_TIME*/;
|
||||
timer_update_outstanding();
|
||||
@@ -1266,7 +1288,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->status = BUSY_STAT;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1279,7 +1301,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].callback = 100LL*IDE_TIME;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->callback = 100LL*IDE_TIME;
|
||||
}
|
||||
idecallback[ide_board]=100LL*IDE_TIME;
|
||||
timer_update_outstanding();
|
||||
@@ -1303,7 +1325,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->status = BUSY_STAT;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1316,7 +1338,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].callback = 200LL*IDE_TIME;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->callback = 200LL*IDE_TIME;
|
||||
}
|
||||
idecallback[ide_board]=200LL*IDE_TIME;
|
||||
timer_update_outstanding();
|
||||
@@ -1339,8 +1361,8 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].status = DRQ_STAT | DSC_STAT | READY_STAT;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].pos = 0;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->status = DRQ_STAT | DSC_STAT | READY_STAT;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->pos = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1357,7 +1379,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->status = BUSY_STAT;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1370,7 +1392,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].callback = 200LL*IDE_TIME;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->callback = 200LL*IDE_TIME;
|
||||
}
|
||||
idecallback[ide_board]=200LL*IDE_TIME;
|
||||
timer_update_outstanding();
|
||||
@@ -1384,7 +1406,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->status = BUSY_STAT;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1397,7 +1419,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].callback = 200LL*IDE_TIME;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->callback = 200LL*IDE_TIME;
|
||||
}
|
||||
idecallback[ide_board]=200LL*IDE_TIME;
|
||||
timer_update_outstanding();
|
||||
@@ -1422,7 +1444,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->status = BUSY_STAT;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1435,7 +1457,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].callback = 30LL*IDE_TIME;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->callback = 30LL*IDE_TIME;
|
||||
}
|
||||
idecallback[ide_board]=30LL*IDE_TIME;
|
||||
timer_update_outstanding();
|
||||
@@ -1443,16 +1465,16 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
|
||||
case WIN_DRIVE_DIAGNOSTICS: /* Execute Drive Diagnostics */
|
||||
if (ide_drive_is_zip(ide))
|
||||
zip[atapi_zip_drives[ide->channel]].status = BUSY_STAT;
|
||||
zip[atapi_zip_drives[ide->channel]].status = BUSY_STAT;
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->status = BUSY_STAT;
|
||||
else
|
||||
ide->atastat = BUSY_STAT;
|
||||
|
||||
if (ide_drive_is_zip(ide_other))
|
||||
zip[atapi_zip_drives[ide_other->channel]].status = BUSY_STAT;
|
||||
else if (ide_drive_is_cdrom(ide_other))
|
||||
cdrom[atapi_cdrom_drives[ide_other->channel]].status = BUSY_STAT;
|
||||
cdrom[atapi_cdrom_drives[ide_other->channel]]->status = BUSY_STAT;
|
||||
else
|
||||
ide_other->atastat = BUSY_STAT;
|
||||
|
||||
@@ -1460,7 +1482,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
if (ide_drive_is_zip(ide))
|
||||
zip[atapi_zip_drives[ide->channel]].callback = 200LL * IDE_TIME;
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].callback = 200LL * IDE_TIME;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->callback = 200LL * IDE_TIME;
|
||||
idecallback[ide_board] = 200LL * IDE_TIME;
|
||||
timer_update_outstanding();
|
||||
return;
|
||||
@@ -1476,7 +1498,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
if (ide_drive_is_zip(ide))
|
||||
zip[atapi_zip_drives[ide->channel]].status = BUSY_STAT;
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->status = BUSY_STAT;
|
||||
else
|
||||
ide->atastat = BUSY_STAT;
|
||||
timer_process();
|
||||
@@ -1493,7 +1515,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->status = BUSY_STAT;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1506,7 +1528,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].callback = 200LL*IDE_TIME;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->callback = 200LL*IDE_TIME;
|
||||
}
|
||||
idecallback[ide_board]=200LL*IDE_TIME;
|
||||
timer_update_outstanding();
|
||||
@@ -1519,14 +1541,15 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
|
||||
zip[atapi_zip_drives[ide->channel]].packet_status = ZIP_PHASE_IDLE;
|
||||
zip[atapi_zip_drives[ide->channel]].pos=0;
|
||||
zip[atapi_zip_drives[ide->channel]].phase = 1;
|
||||
zip[atapi_zip_drives[ide->channel]].status = READY_STAT | DRQ_STAT | (zip[cur_ide[ide_board]].status & ERR_STAT);
|
||||
zip[atapi_zip_drives[ide->channel]].status = READY_STAT | DRQ_STAT;
|
||||
ide_irq_raise(ide); /* Interrupt IRQ, requires IRQ on any DRQ. */
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].packet_status = CDROM_PHASE_IDLE;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].pos=0;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].phase = 1;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].status = READY_STAT | DRQ_STAT | (cdrom[cur_ide[ide_board]].status & ERR_STAT);
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->packet_status = CDROM_PHASE_IDLE;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->pos=0;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->phase = 1;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->status = READY_STAT | DRQ_STAT;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1548,8 +1571,8 @@ ide_bad_command:
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].status = READY_STAT | ERR_STAT | DSC_STAT;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].error = ABRT_ERR;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->status = READY_STAT | ERR_STAT | DSC_STAT;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->error = ABRT_ERR;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1571,7 +1594,7 @@ ide_bad_command:
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].callback = 0LL;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->callback = 0LL;
|
||||
}
|
||||
idecallback[ide_board]=500LL*IDE_TIME;
|
||||
timer_update_outstanding();
|
||||
@@ -1590,7 +1613,7 @@ ide_bad_command:
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT;
|
||||
cdrom[atapi_cdrom_drives[ide->channel]]->status = BUSY_STAT;
|
||||
}
|
||||
ide->atastat = ide_other->atastat = BUSY_STAT;
|
||||
}
|
||||
@@ -1612,6 +1635,20 @@ uint32_t ide_read_data(int ide_board, int length)
|
||||
IDE *ide = &ide_drives[cur_ide[ide_board]];
|
||||
uint32_t temp;
|
||||
|
||||
if (!ide->buffer) {
|
||||
switch (length)
|
||||
{
|
||||
case 1:
|
||||
return 0xff;
|
||||
case 2:
|
||||
return 0xffff;
|
||||
case 4:
|
||||
return 0xffffffff;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t *idebufferb = (uint8_t *) ide->buffer;
|
||||
uint16_t *idebufferw = ide->buffer;
|
||||
uint32_t *idebufferl = (uint32_t *) ide->buffer;
|
||||
@@ -1660,8 +1697,8 @@ uint32_t ide_read_data(int ide_board, int length)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board]]].status = READY_STAT | DSC_STAT;
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board]]].packet_status = CDROM_PHASE_IDLE;
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board]]]->status = READY_STAT | DSC_STAT;
|
||||
cdrom[atapi_cdrom_drives[cur_ide[ide_board]]]->packet_status = CDROM_PHASE_IDLE;
|
||||
}
|
||||
if (ide->command == WIN_READ || ide->command == WIN_READ_NORETRY || ide->command == WIN_READ_MULTIPLE)
|
||||
{
|
||||
@@ -1723,7 +1760,7 @@ uint8_t readide(int ide_board, uint16_t addr)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
temp = cdrom[atapi_cdrom_drives[cur_ide[ide_board]]].error;
|
||||
temp = cdrom[atapi_cdrom_drives[cur_ide[ide_board]]]->error;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1752,7 +1789,7 @@ uint8_t readide(int ide_board, uint16_t addr)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
temp = cdrom[atapi_cdrom_drives[cur_ide[ide_board]]].phase;
|
||||
temp = cdrom[atapi_cdrom_drives[cur_ide[ide_board]]]->phase;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1777,7 +1814,7 @@ uint8_t readide(int ide_board, uint16_t addr)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
temp = cdrom[atapi_cdrom_drives[cur_ide[ide_board]]].request_length & 0xff;
|
||||
temp = cdrom[atapi_cdrom_drives[cur_ide[ide_board]]]->request_length & 0xff;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1799,7 +1836,7 @@ uint8_t readide(int ide_board, uint16_t addr)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
temp = cdrom[atapi_cdrom_drives[cur_ide[ide_board]]].request_length >> 8;
|
||||
temp = cdrom[atapi_cdrom_drives[cur_ide[ide_board]]]->request_length >> 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1828,7 +1865,7 @@ uint8_t readide(int ide_board, uint16_t addr)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
temp = (cdrom[atapi_cdrom_drives[cur_ide[ide_board]]].status & ~DSC_STAT) | (ide->service ? SERVICE_STAT : 0);
|
||||
temp = (cdrom[atapi_cdrom_drives[cur_ide[ide_board]]]->status & ~DSC_STAT) | (ide->service ? SERVICE_STAT : 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1850,7 +1887,7 @@ uint8_t readide(int ide_board, uint16_t addr)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
temp = (cdrom[atapi_cdrom_drives[cur_ide[ide_board]]].status & ~DSC_STAT) | (ide->service ? SERVICE_STAT : 0);
|
||||
temp = (cdrom[atapi_cdrom_drives[cur_ide[ide_board]]]->status & ~DSC_STAT) | (ide->service ? SERVICE_STAT : 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1932,10 +1969,10 @@ void callbackide(int ide_board)
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom_id = atapi_cdrom_drives[cur_ide[ide_board]];
|
||||
cdrom[cdrom_id].status = READY_STAT | DSC_STAT;
|
||||
cdrom[cdrom_id].error = 1;
|
||||
cdrom[cdrom_id].phase = 1;
|
||||
cdrom[cdrom_id].request_length=0xEB14;
|
||||
cdrom[cdrom_id]->status = READY_STAT | DSC_STAT;
|
||||
cdrom[cdrom_id]->error = 1;
|
||||
cdrom[cdrom_id]->phase = 1;
|
||||
cdrom[cdrom_id]->request_length=0xEB14;
|
||||
ide->cylinder = 0xEB14;
|
||||
if (cdrom_drives[cdrom_id].handler->stop)
|
||||
{
|
||||
@@ -1958,10 +1995,10 @@ void callbackide(int ide_board)
|
||||
else if (ide_drive_is_cdrom(ide_other))
|
||||
{
|
||||
cdrom_id_other = atapi_cdrom_drives[cur_ide[ide_board] ^ 1];
|
||||
cdrom[cdrom_id_other].status = READY_STAT | DSC_STAT;
|
||||
cdrom[cdrom_id_other].error = 1;
|
||||
cdrom[cdrom_id_other].phase = 1;
|
||||
cdrom[cdrom_id_other].request_length=0xEB14;
|
||||
cdrom[cdrom_id_other]->status = READY_STAT | DSC_STAT;
|
||||
cdrom[cdrom_id_other]->error = 1;
|
||||
cdrom[cdrom_id_other]->phase = 1;
|
||||
cdrom[cdrom_id_other]->request_length=0xEB14;
|
||||
ide_other->cylinder = 0xEB14;
|
||||
if (cdrom_drives[cdrom_id_other].handler->stop)
|
||||
{
|
||||
@@ -2018,9 +2055,9 @@ void callbackide(int ide_board)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[cdrom_id].status = READY_STAT | DSC_STAT;
|
||||
cdrom[cdrom_id].error = 1;
|
||||
cdrom[cdrom_id].phase = 1;
|
||||
cdrom[cdrom_id]->status = READY_STAT | DSC_STAT;
|
||||
cdrom[cdrom_id]->error = 1;
|
||||
cdrom[cdrom_id]->phase = 1;
|
||||
cdrom_reset(cdrom_id);
|
||||
}
|
||||
ide_irq_raise(ide);
|
||||
@@ -2040,7 +2077,7 @@ void callbackide(int ide_board)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[cdrom_id].status = READY_STAT | DSC_STAT;
|
||||
cdrom[cdrom_id]->status = READY_STAT | DSC_STAT;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2058,8 +2095,8 @@ void callbackide(int ide_board)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[cdrom_id].phase = 0xFF;
|
||||
cdrom[cdrom_id].status = READY_STAT | DSC_STAT;
|
||||
cdrom[cdrom_id]->phase = 0xFF;
|
||||
cdrom[cdrom_id]->status = READY_STAT | DSC_STAT;
|
||||
}
|
||||
ide->secount = 0xFF;
|
||||
ide->atastat = READY_STAT | DSC_STAT;
|
||||
@@ -2351,8 +2388,8 @@ void callbackide(int ide_board)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[cdrom_id].status = 0;
|
||||
cdrom[cdrom_id].error = 1;
|
||||
cdrom[cdrom_id]->status = 0;
|
||||
cdrom[cdrom_id]->error = 1;
|
||||
ide_irq_raise(ide);
|
||||
}
|
||||
else
|
||||
@@ -2372,8 +2409,8 @@ void callbackide(int ide_board)
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide_other))
|
||||
{
|
||||
cdrom[cdrom_id_other].status = 0;
|
||||
cdrom[cdrom_id_other].error = 1;
|
||||
cdrom[cdrom_id_other]->status = 0;
|
||||
cdrom[cdrom_id_other]->error = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2416,10 +2453,10 @@ void callbackide(int ide_board)
|
||||
{
|
||||
ide_atapi_identify(ide);
|
||||
ide->pos = 0;
|
||||
cdrom[cdrom_id].phase = 2;
|
||||
cdrom[cdrom_id].pos = 0;
|
||||
cdrom[cdrom_id].error = 0;
|
||||
cdrom[cdrom_id].status = DRQ_STAT | READY_STAT | DSC_STAT;
|
||||
cdrom[cdrom_id]->phase = 2;
|
||||
cdrom[cdrom_id]->pos = 0;
|
||||
cdrom[cdrom_id]->error = 0;
|
||||
cdrom[cdrom_id]->status = DRQ_STAT | READY_STAT | DSC_STAT;
|
||||
ide_irq_raise(ide);
|
||||
return;
|
||||
}
|
||||
@@ -2452,8 +2489,8 @@ void callbackide(int ide_board)
|
||||
zip[zip_id].pos = 0;
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide)) {
|
||||
cdrom[cdrom_id].status = READY_STAT | DSC_STAT;
|
||||
cdrom[cdrom_id].pos = 0;
|
||||
cdrom[cdrom_id]->status = READY_STAT | DSC_STAT;
|
||||
cdrom[cdrom_id]->pos = 0;
|
||||
}
|
||||
ide->atastat = READY_STAT | DSC_STAT;
|
||||
ide_irq_raise(ide);
|
||||
@@ -2515,9 +2552,9 @@ abort_cmd:
|
||||
}
|
||||
else if (ide_drive_is_cdrom(ide))
|
||||
{
|
||||
cdrom[cdrom_id].status = READY_STAT | ERR_STAT | DSC_STAT;
|
||||
cdrom[cdrom_id].error = ABRT_ERR;
|
||||
cdrom[cdrom_id].pos = 0;
|
||||
cdrom[cdrom_id]->status = READY_STAT | ERR_STAT | DSC_STAT;
|
||||
cdrom[cdrom_id]->error = ABRT_ERR;
|
||||
cdrom[cdrom_id]->pos = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2846,12 +2883,12 @@ void secondary_ide_check(void)
|
||||
* Initialization of standalone IDE controller instance.
|
||||
*
|
||||
* Eventually, we should clean up the whole mess by only
|
||||
* using device_t units, with configuration parameters to
|
||||
* using const device_t units, with configuration parameters to
|
||||
* indicate primary/secondary and all that, rather than
|
||||
* keeping a zillion of duplicate functions around.
|
||||
*/
|
||||
static void *
|
||||
ide_sainit(device_t *info)
|
||||
ide_sainit(const device_t *info)
|
||||
{
|
||||
switch(info->local) {
|
||||
case 0: /* ISA, single-channel */
|
||||
@@ -2881,7 +2918,7 @@ ide_sainit(device_t *info)
|
||||
break;
|
||||
}
|
||||
|
||||
return(info);
|
||||
return(ide_drives);
|
||||
}
|
||||
|
||||
|
||||
@@ -2893,7 +2930,7 @@ ide_saclose(void *priv)
|
||||
}
|
||||
|
||||
|
||||
device_t ide_isa_device = {
|
||||
const device_t ide_isa_device = {
|
||||
"ISA PC/AT IDE Controller",
|
||||
DEVICE_ISA | DEVICE_AT,
|
||||
0,
|
||||
@@ -2902,7 +2939,7 @@ device_t ide_isa_device = {
|
||||
NULL
|
||||
};
|
||||
|
||||
device_t ide_isa_2ch_device = {
|
||||
const device_t ide_isa_2ch_device = {
|
||||
"ISA PC/AT IDE Controller (Dual-Channel)",
|
||||
DEVICE_ISA | DEVICE_AT,
|
||||
2,
|
||||
@@ -2911,7 +2948,7 @@ device_t ide_isa_2ch_device = {
|
||||
NULL
|
||||
};
|
||||
|
||||
device_t ide_isa_2ch_opt_device = {
|
||||
const device_t ide_isa_2ch_opt_device = {
|
||||
"ISA PC/AT IDE Controller (Single/Dual)",
|
||||
DEVICE_ISA | DEVICE_AT,
|
||||
3,
|
||||
@@ -2920,7 +2957,7 @@ device_t ide_isa_2ch_opt_device = {
|
||||
NULL
|
||||
};
|
||||
|
||||
device_t ide_vlb_device = {
|
||||
const device_t ide_vlb_device = {
|
||||
"VLB IDE Controller",
|
||||
DEVICE_VLB | DEVICE_AT,
|
||||
4,
|
||||
@@ -2929,7 +2966,7 @@ device_t ide_vlb_device = {
|
||||
NULL
|
||||
};
|
||||
|
||||
device_t ide_vlb_2ch_device = {
|
||||
const device_t ide_vlb_2ch_device = {
|
||||
"VLB IDE Controller (Dual-Channel)",
|
||||
DEVICE_VLB | DEVICE_AT,
|
||||
6,
|
||||
@@ -2938,7 +2975,7 @@ device_t ide_vlb_2ch_device = {
|
||||
NULL
|
||||
};
|
||||
|
||||
device_t ide_pci_device = {
|
||||
const device_t ide_pci_device = {
|
||||
"PCI IDE Controller",
|
||||
DEVICE_PCI | DEVICE_AT,
|
||||
8,
|
||||
@@ -2947,7 +2984,7 @@ device_t ide_pci_device = {
|
||||
NULL
|
||||
};
|
||||
|
||||
device_t ide_pci_2ch_device = {
|
||||
const device_t ide_pci_2ch_device = {
|
||||
"PCI IDE Controller (Dual-Channel)",
|
||||
DEVICE_PCI | DEVICE_AT,
|
||||
10,
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* Implementation of the IDE emulation for hard disks and ATAPI
|
||||
* CD-ROM devices.
|
||||
*
|
||||
* Version: @(#)hdd_ide.h 1.0.7 2018/03/15
|
||||
* Version: @(#)hdd_ide.h 1.0.8 2018/03/20
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -86,6 +86,8 @@ extern void ide_init_first(void);
|
||||
extern void ide_reset(void);
|
||||
extern void ide_reset_hard(void);
|
||||
|
||||
extern void ide_set_all_signatures(void);
|
||||
|
||||
extern void ide_xtide_init(void);
|
||||
|
||||
extern void ide_pri_enable(void);
|
||||
|
||||
@@ -12,13 +12,13 @@
|
||||
* based design. Most cards were WD1003-WA2 or -WAH, where the
|
||||
* -WA2 cards had a floppy controller as well (to save space.)
|
||||
*
|
||||
* Version: @(#)hdc_mfm_at.c 1.0.12 2017/12/09
|
||||
* Version: @(#)hdc_mfm_at.c 1.0.13 2018/03/18
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2008-2017 Sarah Walker.
|
||||
* Copyright 2017 Fred N. van Kempen.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*/
|
||||
#define __USE_LARGEFILE64
|
||||
#define _LARGEFILE_SOURCE
|
||||
@@ -707,7 +707,7 @@ loadhd(mfm_t *mfm, int c, int d, const wchar_t *fn)
|
||||
|
||||
|
||||
static void *
|
||||
mfm_init(device_t *info)
|
||||
mfm_init(const device_t *info)
|
||||
{
|
||||
mfm_t *mfm;
|
||||
int c, d;
|
||||
@@ -764,7 +764,7 @@ mfm_close(void *priv)
|
||||
}
|
||||
|
||||
|
||||
device_t mfm_at_wd1003_device = {
|
||||
const device_t mfm_at_wd1003_device = {
|
||||
"WD1003 AT MFM/RLL Controller",
|
||||
DEVICE_ISA | DEVICE_AT,
|
||||
0,
|
||||
|
||||
@@ -41,13 +41,13 @@
|
||||
* Since all controllers (including the ones made by DTC) use
|
||||
* (mostly) the same API, we keep them all in this module.
|
||||
*
|
||||
* Version: @(#)hdc_mfm_xt.c 1.0.13 2017/11/06
|
||||
* Version: @(#)hdc_mfm_xt.c 1.0.14 2018/03/18
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2008-2017 Sarah Walker.
|
||||
* Copyright 2017 Fred N. van Kempen.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*/
|
||||
#define __USE_LARGEFILE64
|
||||
#define _LARGEFILE_SOURCE
|
||||
@@ -808,7 +808,7 @@ mfm_set_switches(mfm_t *mfm)
|
||||
|
||||
|
||||
static void *
|
||||
xebec_init(device_t *info)
|
||||
xebec_init(const device_t *info)
|
||||
{
|
||||
int i, c = 0;
|
||||
|
||||
@@ -863,7 +863,7 @@ xebec_available(void)
|
||||
}
|
||||
|
||||
|
||||
device_t mfm_xt_xebec_device = {
|
||||
const device_t mfm_xt_xebec_device = {
|
||||
"IBM PC Fixed Disk Adapter",
|
||||
DEVICE_ISA,
|
||||
0,
|
||||
@@ -874,7 +874,7 @@ device_t mfm_xt_xebec_device = {
|
||||
|
||||
|
||||
static void *
|
||||
dtc5150x_init(device_t *info)
|
||||
dtc5150x_init(const device_t *info)
|
||||
{
|
||||
int i, c = 0;
|
||||
|
||||
@@ -918,7 +918,7 @@ dtc5150x_available(void)
|
||||
}
|
||||
|
||||
|
||||
device_t mfm_xt_dtc5150x_device = {
|
||||
const device_t mfm_xt_dtc5150x_device = {
|
||||
"DTC 5150X",
|
||||
DEVICE_ISA,
|
||||
0,
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* already on their way out, the newer IDE standard based on the
|
||||
* PC/AT controller and 16b design became the IDE we now know.
|
||||
*
|
||||
* Version: @(#)hdc_xtide.c 1.0.11 2018/02/14
|
||||
* Version: @(#)hdc_xtide.c 1.0.11 2018/03/18
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -127,7 +127,7 @@ xtide_read(uint16_t port, void *priv)
|
||||
|
||||
|
||||
static void *
|
||||
xtide_init(device_t *info)
|
||||
xtide_init(const device_t *info)
|
||||
{
|
||||
xtide_t *xtide = malloc(sizeof(xtide_t));
|
||||
|
||||
@@ -154,7 +154,7 @@ xtide_available(void)
|
||||
|
||||
|
||||
static void *
|
||||
xtide_at_init(device_t *info)
|
||||
xtide_at_init(const device_t *info)
|
||||
{
|
||||
xtide_t *xtide = malloc(sizeof(xtide_t));
|
||||
|
||||
@@ -177,7 +177,7 @@ xtide_at_available(void)
|
||||
|
||||
|
||||
static void *
|
||||
xtide_acculogic_init(device_t *info)
|
||||
xtide_acculogic_init(const device_t *info)
|
||||
{
|
||||
xtide_t *xtide = malloc(sizeof(xtide_t));
|
||||
|
||||
@@ -204,7 +204,7 @@ xtide_acculogic_available(void)
|
||||
|
||||
|
||||
static void *
|
||||
xtide_at_ps2_init(device_t *info)
|
||||
xtide_at_ps2_init(const device_t *info)
|
||||
{
|
||||
xtide_t *xtide = malloc(sizeof(xtide_t));
|
||||
|
||||
@@ -235,7 +235,7 @@ xtide_close(void *priv)
|
||||
}
|
||||
|
||||
|
||||
device_t xtide_device = {
|
||||
const device_t xtide_device = {
|
||||
"XTIDE",
|
||||
DEVICE_ISA,
|
||||
0,
|
||||
@@ -244,7 +244,7 @@ device_t xtide_device = {
|
||||
NULL
|
||||
};
|
||||
|
||||
device_t xtide_at_device = {
|
||||
const device_t xtide_at_device = {
|
||||
"XTIDE (AT)",
|
||||
DEVICE_ISA | DEVICE_AT,
|
||||
0,
|
||||
@@ -253,7 +253,7 @@ device_t xtide_at_device = {
|
||||
NULL
|
||||
};
|
||||
|
||||
device_t xtide_acculogic_device = {
|
||||
const device_t xtide_acculogic_device = {
|
||||
"XTIDE (Acculogic)",
|
||||
DEVICE_ISA,
|
||||
0,
|
||||
@@ -262,7 +262,7 @@ device_t xtide_acculogic_device = {
|
||||
NULL
|
||||
};
|
||||
|
||||
device_t xtide_at_ps2_device = {
|
||||
const device_t xtide_at_ps2_device = {
|
||||
"XTIDE (AT) (1.1.5)",
|
||||
DEVICE_ISA | DEVICE_PS2,
|
||||
0,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Handling of hard disk image files.
|
||||
*
|
||||
* Version: @(#)hdd_image.c 1.0.12 2018/02/08
|
||||
* Version: @(#)hdd_image.c 1.0.13 2018/03/19
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
@@ -288,29 +288,29 @@ int hdd_image_load(int id)
|
||||
if (ftello64(hdd_images[id].file) < (full_size + hdd_images[id].base)) {
|
||||
s = (full_size + hdd_images[id].base) - ftello64(hdd_images[id].file);
|
||||
prepare_new_hard_disk:
|
||||
s >>= 9;
|
||||
t = (s >> 11) << 11;
|
||||
s -= t;
|
||||
t >>= 11;
|
||||
t = s >> 20; /* Amount of 1 MB blocks. */
|
||||
s &= 0xfffff; /* 1 MB mask. */
|
||||
|
||||
empty_sector_1mb = (char *) malloc(1048576);
|
||||
memset(empty_sector_1mb, 0, 1048576);
|
||||
|
||||
/* Temporarily switch off suppression of seen messages so that the
|
||||
progress gets displayed. */
|
||||
pclog_toggle_suppr();
|
||||
pclog("Writing image sectors: [");
|
||||
if (s > 0) {
|
||||
for (i = 0; i < s; i++) {
|
||||
|
||||
/* First, write all the 1 MB blocks. */
|
||||
if (t > 0) {
|
||||
for (i = 0; i < t; i++) {
|
||||
fwrite(empty_sector_1mb, 1, 1045876, hdd_images[id].file);
|
||||
pclog("#");
|
||||
fwrite(empty_sector, 1, 512, hdd_images[id].file);
|
||||
}
|
||||
}
|
||||
|
||||
if (t > 0) {
|
||||
for (i = 0; i < t; i++) {
|
||||
pclog("#");
|
||||
fwrite(empty_sector_1mb, 1, 1045876, hdd_images[id].file);
|
||||
}
|
||||
}
|
||||
pclog("]\n");
|
||||
/* Then, write the remainder. */
|
||||
fwrite(empty_sector_1mb, 1, s, hdd_images[id].file);
|
||||
pclog("#]\n");
|
||||
pclog_toggle_suppr();
|
||||
|
||||
free(empty_sector_1mb);
|
||||
}
|
||||
|
||||
159
src/disk/zip.c
159
src/disk/zip.c
@@ -9,7 +9,7 @@
|
||||
* Implementation of the Iomega ZIP drive with SCSI(-like)
|
||||
* commands, for both ATAPI and SCSI usage.
|
||||
*
|
||||
* Version: @(#)zip.c 1.0.9 2018/03/15
|
||||
* Version: @(#)zip.c 1.0.19 2018/03/21
|
||||
*
|
||||
* Author: Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
@@ -70,7 +70,7 @@ uint8_t scsi_zip_drives[16][8] = { { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0
|
||||
|
||||
|
||||
/* Table of all SCSI commands and their flags, needed for the new disc change / not ready handler. */
|
||||
uint8_t zip_command_flags[0x100] =
|
||||
const uint8_t zip_command_flags[0x100] =
|
||||
{
|
||||
IMPLEMENTED | CHECK_READY | NONDATA, /* 0x00 */
|
||||
IMPLEMENTED | ALLOW_UA | NONDATA | SCSI_ONLY, /* 0x01 */
|
||||
@@ -99,7 +99,9 @@ uint8_t zip_command_flags[0x100] =
|
||||
0,
|
||||
IMPLEMENTED, /* 0x1D */
|
||||
IMPLEMENTED | CHECK_READY, /* 0x1E */
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
IMPLEMENTED | ATAPI_ONLY, /* 0x23 */
|
||||
0,
|
||||
IMPLEMENTED | CHECK_READY, /* 0x25 */
|
||||
0, 0,
|
||||
IMPLEMENTED | CHECK_READY, /* 0x28 */
|
||||
@@ -654,7 +656,6 @@ void zip_init(int id, int cdb_len_setting)
|
||||
zip_log("ZIP %i: Bus type %i, bus mode %i\n", id, zip_drives[id].bus_type, zip_drives[id].bus_mode);
|
||||
if (zip_drives[id].bus_type < ZIP_BUS_SCSI)
|
||||
zip_set_signature(id);
|
||||
zip_drives[id].max_blocks_at_once = 85;
|
||||
zip[id].status = READY_STAT | DSC_STAT;
|
||||
zip[id].pos = 0;
|
||||
zip[id].packet_status = 0xff;
|
||||
@@ -952,12 +953,12 @@ static void zip_command_common(uint8_t id)
|
||||
bytes_per_second = 8333333.333333333333333; /* 8.3 MB/s PIO-2 speed */
|
||||
} else
|
||||
bytes_per_second = 3333333.333333333333333; /* 3.3 MB/s PIO-0 speed */
|
||||
}
|
||||
|
||||
period = 1000000.0 / bytes_per_second;
|
||||
dusec = (double) TIMER_USEC;
|
||||
dusec = dusec * period * (double) (zip[id].packet_len);
|
||||
zip[id].callback = ((int64_t) dusec);
|
||||
period = 1000000.0 / bytes_per_second;
|
||||
dusec = (double) TIMER_USEC;
|
||||
dusec = dusec * period * (double) (zip[id].packet_len);
|
||||
zip[id].callback = ((int64_t) dusec);
|
||||
}
|
||||
|
||||
zip_set_callback(id);
|
||||
}
|
||||
@@ -1152,37 +1153,12 @@ static void zip_data_phase_error(uint8_t id)
|
||||
|
||||
#define zipbufferb zip[id].buffer
|
||||
|
||||
int zip_data(uint8_t id, uint32_t *len, int out)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
if (zip[id].sector_pos >= zip_drives[id].medium_size) {
|
||||
zip_log("ZIP %i: Trying to %s beyond the end of disk\n", id, out ? "write" : "read");
|
||||
zip_lba_out_of_range(id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*len = 0;
|
||||
|
||||
for (i = 0; i < zip[id].requested_blocks; i++) {
|
||||
fseek(zip_drives[id].f, zip_drives[id].base + (zip[id].sector_pos << 9) + *len, SEEK_SET);
|
||||
if (out)
|
||||
fwrite(zipbufferb + *len, 1, 512, zip_drives[id].f);
|
||||
else
|
||||
fread(zipbufferb + *len, 1, 512, zip_drives[id].f);
|
||||
|
||||
*len += 512;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int zip_blocks(uint8_t id, uint32_t *len, int first_batch, int out)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
zip[id].data_pos = 0;
|
||||
|
||||
*len = 0;
|
||||
|
||||
if (!zip[id].sector_len) {
|
||||
zip_command_complete(id);
|
||||
return -1;
|
||||
@@ -1190,13 +1166,22 @@ int zip_blocks(uint8_t id, uint32_t *len, int first_batch, int out)
|
||||
|
||||
zip_log("%sing %i blocks starting from %i...\n", out ? "Writ" : "Read", zip[id].requested_blocks, zip[id].sector_pos);
|
||||
|
||||
ret = zip_data(id, len, out);
|
||||
if (zip[id].sector_pos >= zip_drives[id].medium_size) {
|
||||
zip_log("ZIP %i: Trying to %s beyond the end of disk\n", id, out ? "write" : "read");
|
||||
zip_lba_out_of_range(id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*len = zip[id].requested_blocks << 9;
|
||||
|
||||
fseek(zip_drives[id].f, zip_drives[id].base + (zip[id].sector_pos << 9), SEEK_SET);
|
||||
if (out)
|
||||
fwrite(zipbufferb, 1, *len, zip_drives[id].f);
|
||||
else
|
||||
fread(zipbufferb, 1, *len, zip_drives[id].f);
|
||||
|
||||
zip_log("%s %i bytes of blocks...\n", out ? "Written" : "Read", *len);
|
||||
|
||||
if (!ret)
|
||||
return 0;
|
||||
|
||||
zip[id].sector_pos += zip[id].requested_blocks;
|
||||
zip[id].sector_len -= zip[id].requested_blocks;
|
||||
|
||||
@@ -2005,7 +1990,7 @@ atapi_out:
|
||||
zip_buf_free(id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
zip_set_buf_len(id, BufLen, &len);
|
||||
|
||||
zip_data_command_finish(id, len, len, len, 0);
|
||||
@@ -2017,6 +2002,70 @@ atapi_out:
|
||||
zip_command_complete(id);
|
||||
break;
|
||||
|
||||
case GPCMD_READ_FORMAT_CAPACITIES:
|
||||
len = (cdb[7] << 8) | cdb[8];
|
||||
|
||||
zip_buf_alloc(id, len);
|
||||
memset(zipbufferb, 0, len);
|
||||
|
||||
pos = 0;
|
||||
|
||||
/* List header */
|
||||
zipbufferb[pos++] = 0;
|
||||
zipbufferb[pos++] = 0;
|
||||
zipbufferb[pos++] = 0;
|
||||
if (zip_drives[id].f != NULL)
|
||||
zipbufferb[pos++] = 16;
|
||||
else
|
||||
zipbufferb[pos++] = 8;
|
||||
|
||||
/* Current/Maximum capacity header */
|
||||
if (zip_drives[id].is_250) {
|
||||
if (zip_drives[id].f != NULL) {
|
||||
zipbufferb[pos++] = (zip_drives[id].medium_size >> 24) & 0xff;
|
||||
zipbufferb[pos++] = (zip_drives[id].medium_size >> 16) & 0xff;
|
||||
zipbufferb[pos++] = (zip_drives[id].medium_size >> 8) & 0xff;
|
||||
zipbufferb[pos++] = zip_drives[id].medium_size & 0xff;
|
||||
zipbufferb[pos++] = 2; /* Current medium capacity */
|
||||
} else {
|
||||
zipbufferb[pos++] = (ZIP_250_SECTORS >> 24) & 0xff;
|
||||
zipbufferb[pos++] = (ZIP_250_SECTORS >> 16) & 0xff;
|
||||
zipbufferb[pos++] = (ZIP_250_SECTORS >> 8) & 0xff;
|
||||
zipbufferb[pos++] = ZIP_250_SECTORS & 0xff;
|
||||
zipbufferb[pos++] = 3; /* Maximum medium capacity */
|
||||
}
|
||||
} else {
|
||||
zipbufferb[pos++] = (ZIP_SECTORS >> 24) & 0xff;
|
||||
zipbufferb[pos++] = (ZIP_SECTORS >> 16) & 0xff;
|
||||
zipbufferb[pos++] = (ZIP_SECTORS >> 8) & 0xff;
|
||||
zipbufferb[pos++] = ZIP_SECTORS & 0xff;
|
||||
if (zip_drives[id].f != NULL)
|
||||
zipbufferb[pos++] = 2;
|
||||
else
|
||||
zipbufferb[pos++] = 3;
|
||||
}
|
||||
|
||||
zipbufferb[pos++] = 512 >> 16;
|
||||
zipbufferb[pos++] = 512 >> 8;
|
||||
zipbufferb[pos++] = 512 & 0xff;
|
||||
|
||||
if (zip_drives[id].f != NULL) {
|
||||
/* Formattable capacity descriptor */
|
||||
zipbufferb[pos++] = (zip_drives[id].medium_size >> 24) & 0xff;
|
||||
zipbufferb[pos++] = (zip_drives[id].medium_size >> 16) & 0xff;
|
||||
zipbufferb[pos++] = (zip_drives[id].medium_size >> 8) & 0xff;
|
||||
zipbufferb[pos++] = zip_drives[id].medium_size & 0xff;
|
||||
zipbufferb[pos++] = 0;
|
||||
zipbufferb[pos++] = 512 >> 16;
|
||||
zipbufferb[pos++] = 512 >> 8;
|
||||
zipbufferb[pos++] = 512 & 0xff;
|
||||
}
|
||||
|
||||
zip_set_buf_len(id, BufLen, &len);
|
||||
|
||||
zip_data_command_finish(id, len, len, len, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
zip_illegal_opcode(id);
|
||||
break;
|
||||
@@ -2267,14 +2316,17 @@ int zip_read_from_dma(uint8_t id)
|
||||
|
||||
ret = zip_phase_data_out(id);
|
||||
|
||||
if (ret) {
|
||||
if (ret || (zip_drives[id].bus_type == ZIP_BUS_SCSI)) {
|
||||
zip_buf_free(id);
|
||||
zip[id].packet_status = ZIP_PHASE_COMPLETE;
|
||||
zip[id].status = READY_STAT;
|
||||
zip[id].phase = 3;
|
||||
ui_sb_update_icon(SB_ZIP | id, 0);
|
||||
zip_irq_raise(id);
|
||||
return 1;
|
||||
if (ret)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
@@ -2322,14 +2374,17 @@ int zip_write_to_dma(uint8_t id)
|
||||
} else
|
||||
ret = zip_write_to_ide_dma(zip_drives[id].ide_channel);
|
||||
|
||||
if (ret) {
|
||||
if (ret || (zip_drives[id].bus_type == ZIP_BUS_SCSI)) {
|
||||
zip_buf_free(id);
|
||||
zip[id].packet_status = ZIP_PHASE_COMPLETE;
|
||||
zip[id].status = READY_STAT;
|
||||
zip[id].phase = 3;
|
||||
ui_sb_update_icon(SB_ZIP | id, 0);
|
||||
zip_irq_raise(id);
|
||||
return 1;
|
||||
if (ret)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
@@ -2382,6 +2437,7 @@ void zip_phase_callback(uint8_t id)
|
||||
zip_log("ZIP %i: ZIP_PHASE_ERROR\n", id);
|
||||
zip[id].status = READY_STAT | ERR_STAT;
|
||||
zip[id].phase = 3;
|
||||
zip[id].packet_status = 0xFF;
|
||||
zip_irq_raise(id);
|
||||
ui_sb_update_icon(SB_ZIP | id, 0);
|
||||
return;
|
||||
@@ -2505,15 +2561,6 @@ void zip_write(uint8_t channel, uint32_t val, int length)
|
||||
}
|
||||
}
|
||||
|
||||
void zip_hard_reset(void)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (i=0; i<ZIP_NUM; i++)
|
||||
zip_mode_sense_load(i);
|
||||
}
|
||||
|
||||
|
||||
/* Peform a master init on the entire module. */
|
||||
void
|
||||
zip_global_init(void)
|
||||
@@ -2525,7 +2572,7 @@ zip_global_init(void)
|
||||
|
||||
|
||||
void
|
||||
zip_global_reset(void)
|
||||
zip_hard_reset(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
@@ -2536,5 +2583,7 @@ zip_global_reset(void)
|
||||
zip_log("ZIP global_reset drive=%d host=%02x\n", c, zip_drives[c].host_drive);
|
||||
if (wcslen(zip_drives[c].image_path))
|
||||
zip_load(c, zip_drives[c].image_path);
|
||||
|
||||
zip_mode_sense_load(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* Implementation of the Iomega ZIP drive with SCSI(-like)
|
||||
* commands, for both ATAPI and SCSI usage.
|
||||
*
|
||||
* Version: @(#)zip.h 1.0.2 2018/02/27
|
||||
* Version: @(#)zip.h 1.0.4 2018/03/20
|
||||
*
|
||||
* Author: Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
@@ -122,8 +122,6 @@ typedef struct {
|
||||
} zip_t;
|
||||
|
||||
typedef struct {
|
||||
int max_blocks_at_once;
|
||||
|
||||
int host_drive;
|
||||
int prev_host_drive;
|
||||
|
||||
@@ -199,7 +197,6 @@ extern int find_zip_for_scsi_id(uint8_t scsi_id, uint8_t scsi_lun);
|
||||
extern int zip_read_capacity(uint8_t id, uint8_t *cdb, uint8_t *buffer, uint32_t *len);
|
||||
|
||||
extern void zip_global_init(void);
|
||||
extern void zip_global_reset(void);
|
||||
extern void zip_hard_reset(void);
|
||||
|
||||
extern int zip_load(uint8_t id, wchar_t *fn);
|
||||
|
||||
@@ -1,21 +1,39 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the NEC uPD-765 and compatible floppy disk
|
||||
* controller.
|
||||
*
|
||||
* Version: @(#)fdc->c 1.0.18 2018/03/08
|
||||
* Version: @(#)fdc.c 1.0.5 2018/03/16
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -42,7 +60,7 @@
|
||||
extern int64_t motoron[FDD_NUM];
|
||||
|
||||
|
||||
int command_has_drivesel[256] = {
|
||||
const int command_has_drivesel[256] = {
|
||||
0, 0,
|
||||
1, /* READ TRACK */
|
||||
0,
|
||||
@@ -1147,7 +1165,6 @@ fdc_read(uint16_t addr, void *priv)
|
||||
{
|
||||
fdc_t *fdc = (fdc_t *) priv;
|
||||
uint8_t ret;
|
||||
|
||||
int drive;
|
||||
|
||||
cycles -= ISA_CYCLES(8);
|
||||
@@ -2020,7 +2037,7 @@ fdc_close(void *priv)
|
||||
|
||||
|
||||
static void *
|
||||
fdc_init(device_t *info)
|
||||
fdc_init(const device_t *info)
|
||||
{
|
||||
fdc_t *fdc = (fdc_t *) malloc(sizeof(fdc_t));
|
||||
memset(fdc, 0, sizeof(fdc_t));
|
||||
@@ -2058,7 +2075,7 @@ fdc_3f1_enable(fdc_t *fdc, int enable)
|
||||
}
|
||||
|
||||
|
||||
device_t fdc_xt_device = {
|
||||
const device_t fdc_xt_device = {
|
||||
"PC/XT Floppy Drive Controller",
|
||||
0,
|
||||
0,
|
||||
@@ -2068,7 +2085,7 @@ device_t fdc_xt_device = {
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
device_t fdc_pcjr_device = {
|
||||
const device_t fdc_pcjr_device = {
|
||||
"PCjr Floppy Drive Controller",
|
||||
0,
|
||||
FDC_FLAG_PCJR,
|
||||
@@ -2078,7 +2095,7 @@ device_t fdc_pcjr_device = {
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
device_t fdc_at_device = {
|
||||
const device_t fdc_at_device = {
|
||||
"PC/AT Floppy Drive Controller",
|
||||
0,
|
||||
FDC_FLAG_AT,
|
||||
@@ -2088,7 +2105,7 @@ device_t fdc_at_device = {
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
device_t fdc_at_actlow_device = {
|
||||
const device_t fdc_at_actlow_device = {
|
||||
"PC/AT Floppy Drive Controller (Active low)",
|
||||
0,
|
||||
FDC_FLAG_DISKCHG_ACTLOW | FDC_FLAG_AT,
|
||||
@@ -2098,7 +2115,7 @@ device_t fdc_at_actlow_device = {
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
device_t fdc_at_ps1_device = {
|
||||
const device_t fdc_at_ps1_device = {
|
||||
"PC/AT Floppy Drive Controller (PS/1, PS/2 ISA)",
|
||||
0,
|
||||
FDC_FLAG_DISKCHG_ACTLOW | FDC_FLAG_AT | FDC_FLAG_PS1,
|
||||
@@ -2108,7 +2125,7 @@ device_t fdc_at_ps1_device = {
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
device_t fdc_at_smc_device = {
|
||||
const device_t fdc_at_smc_device = {
|
||||
"PC/AT Floppy Drive Controller (SM(s)C FDC37Cxxx)",
|
||||
0,
|
||||
FDC_FLAG_AT | FDC_FLAG_SUPERIO,
|
||||
@@ -2118,7 +2135,7 @@ device_t fdc_at_smc_device = {
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
device_t fdc_at_winbond_device = {
|
||||
const device_t fdc_at_winbond_device = {
|
||||
"PC/AT Floppy Drive Controller (Winbond W83x77F)",
|
||||
0,
|
||||
FDC_FLAG_AT | FDC_FLAG_SUPERIO | FDC_FLAG_START_RWC_1 | FDC_FLAG_MORE_TRACKS,
|
||||
@@ -2128,7 +2145,7 @@ device_t fdc_at_winbond_device = {
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
device_t fdc_at_nsc_device = {
|
||||
const device_t fdc_at_nsc_device = {
|
||||
"PC/AT Floppy Drive Controller (NSC PC8730x)",
|
||||
0,
|
||||
FDC_FLAG_AT | FDC_FLAG_MORE_TRACKS | FDC_FLAG_NSC,
|
||||
|
||||
@@ -1,20 +1,41 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the NEC uPD-765 and compatible floppy disk
|
||||
* controller.
|
||||
*
|
||||
* Version: @(#)fdc.h 1.0.5 2018/03/02
|
||||
* Version: @(#)fdc.h 1.0.3 2018/03/17
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#ifndef EMU_FDC_H
|
||||
# define EMU_FDC_H
|
||||
@@ -29,8 +50,8 @@
|
||||
#define FDC_FLAG_MORE_TRACKS 0x40 /* W83877F, W83977F, PC87306, PC87309 */
|
||||
#define FDC_FLAG_NSC 0x80 /* PC87306, PC87309 */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
typedef struct {
|
||||
uint8_t dor, stat, command, dat, st0, swap;
|
||||
uint8_t swwp, disable_write;
|
||||
uint8_t params[256], res[256];
|
||||
@@ -79,6 +100,7 @@ typedef struct
|
||||
int64_t watchdog_timer, watchdog_count;
|
||||
} fdc_t;
|
||||
|
||||
|
||||
extern void fdc_remove(fdc_t *fdc);
|
||||
extern void fdc_poll(fdc_t *fdc);
|
||||
extern void fdc_abort(fdc_t *fdc);
|
||||
@@ -148,7 +170,9 @@ extern void fdc_set_base(fdc_t *fdc, int base);
|
||||
extern int fdc_getdata(fdc_t *fdc, int last);
|
||||
extern int fdc_data(fdc_t *fdc, uint8_t data);
|
||||
|
||||
extern void fdc_sectorid(fdc_t *fdc, uint8_t track, uint8_t side, uint8_t sector, uint8_t size, uint8_t crc1, uint8_t crc2);
|
||||
extern void fdc_sectorid(fdc_t *fdc, uint8_t track, uint8_t side,
|
||||
uint8_t sector, uint8_t size, uint8_t crc1,
|
||||
uint8_t crc2);
|
||||
|
||||
extern uint8_t fdc_read(uint16_t addr, void *priv);
|
||||
extern void fdc_reset(void *priv);
|
||||
@@ -156,14 +180,14 @@ extern void fdc_reset(void *priv);
|
||||
extern uint8_t fdc_ps1_525(void);
|
||||
|
||||
#ifdef EMU_DEVICE_H
|
||||
extern device_t fdc_xt_device;
|
||||
extern device_t fdc_pcjr_device;
|
||||
extern device_t fdc_at_device;
|
||||
extern device_t fdc_at_actlow_device;
|
||||
extern device_t fdc_at_ps1_device;
|
||||
extern device_t fdc_at_smc_device;
|
||||
extern device_t fdc_at_winbond_device;
|
||||
extern device_t fdc_at_nsc_device;
|
||||
extern const device_t fdc_xt_device;
|
||||
extern const device_t fdc_pcjr_device;
|
||||
extern const device_t fdc_at_device;
|
||||
extern const device_t fdc_at_actlow_device;
|
||||
extern const device_t fdc_at_ps1_device;
|
||||
extern const device_t fdc_at_smc_device;
|
||||
extern const device_t fdc_at_winbond_device;
|
||||
extern const device_t fdc_at_nsc_device;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,20 +1,40 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the floppy drive emulation.
|
||||
*
|
||||
* Version: @(#)fdd.c 1.0.9 2018/03/14
|
||||
* Version: @(#)fdd.c 1.0.5 2018/03/16
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -66,8 +86,9 @@ int fdc_indexcount = 52;
|
||||
|
||||
fdc_t *fdd_fdc;
|
||||
|
||||
d86f_handler_t d86f_handler[FDD_NUM];
|
||||
|
||||
static struct
|
||||
static const struct
|
||||
{
|
||||
wchar_t *ext;
|
||||
void (*load)(int drive, wchar_t *fn);
|
||||
@@ -150,7 +171,7 @@ int ui_writeprot[FDD_NUM] = {0, 0, 0, 0};
|
||||
#define FLAG_IGNORE_DENSEL 512
|
||||
#define FLAG_PS2 1024
|
||||
|
||||
static struct
|
||||
static const struct
|
||||
{
|
||||
int max_track;
|
||||
int flags;
|
||||
@@ -207,12 +228,12 @@ static struct
|
||||
|
||||
char *fdd_getname(int type)
|
||||
{
|
||||
return drive_types[type].name;
|
||||
return (char *)drive_types[type].name;
|
||||
}
|
||||
|
||||
char *fdd_get_internal_name(int type)
|
||||
{
|
||||
return drive_types[type].internal_name;
|
||||
return (char *)drive_types[type].internal_name;
|
||||
}
|
||||
|
||||
int fdd_get_from_internal_name(char *s)
|
||||
@@ -221,7 +242,7 @@ int fdd_get_from_internal_name(char *s)
|
||||
|
||||
while (strlen(drive_types[c].internal_name))
|
||||
{
|
||||
if (!strcmp(drive_types[c].internal_name, s))
|
||||
if (!strcmp((char *)drive_types[c].internal_name, s))
|
||||
return c;
|
||||
c++;
|
||||
}
|
||||
@@ -433,6 +454,9 @@ void fdd_load(int drive, wchar_t *fn)
|
||||
int c = 0, size;
|
||||
wchar_t *p;
|
||||
FILE *f;
|
||||
|
||||
pclog("FDD: loading drive %d with '%ls'\n", drive, fn);
|
||||
|
||||
if (!fn) return;
|
||||
p = plat_get_extension(fn);
|
||||
if (!p) return;
|
||||
@@ -447,7 +471,7 @@ void fdd_load(int drive, wchar_t *fn)
|
||||
{
|
||||
driveloaders[drive] = c;
|
||||
memcpy(floppyfns[drive], fn, (wcslen(fn) << 1) + 2);
|
||||
d86f_initialize_linked_lists(drive);
|
||||
d86f_setup(drive);
|
||||
loaders[c].load(drive, floppyfns[drive]);
|
||||
drive_empty[drive] = 0;
|
||||
fdd_forced_seek(drive, 0);
|
||||
@@ -456,7 +480,7 @@ void fdd_load(int drive, wchar_t *fn)
|
||||
}
|
||||
c++;
|
||||
}
|
||||
pclog("Couldn't load %ls %s\n",fn,p);
|
||||
pclog("FDD: could not load '%ls' %s\n",fn,p);
|
||||
drive_empty[drive] = 1;
|
||||
fdd_set_head(drive, 0);
|
||||
memset(floppyfns[drive], 0, sizeof(floppyfns[drive]));
|
||||
@@ -465,12 +489,13 @@ void fdd_load(int drive, wchar_t *fn)
|
||||
|
||||
void fdd_close(int drive)
|
||||
{
|
||||
pclog("FDD: closing drive %d\n", drive);
|
||||
|
||||
if (loaders[driveloaders[drive]].close) loaders[driveloaders[drive]].close(drive);
|
||||
drive_empty[drive] = 1;
|
||||
fdd_set_head(drive, 0);
|
||||
floppyfns[drive][0] = 0;
|
||||
d86f_destroy_linked_lists(drive, 0);
|
||||
d86f_destroy_linked_lists(drive, 1);
|
||||
d86f_destroy(drive);
|
||||
drives[drive].hole = NULL;
|
||||
drives[drive].poll = NULL;
|
||||
drives[drive].seek = NULL;
|
||||
@@ -526,18 +551,7 @@ double fdd_real_period(int drive)
|
||||
return (32.0 * dusec);
|
||||
}
|
||||
|
||||
#if defined(DEV_BRANCH) && defined(USE_MRTHOR)
|
||||
if (romset == ROM_MRTHOR)
|
||||
{
|
||||
return (ddbp * dusec) / 4.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (ddbp * dusec);
|
||||
}
|
||||
#else
|
||||
return (ddbp * dusec);
|
||||
#endif
|
||||
}
|
||||
|
||||
void fdd_poll(int drive)
|
||||
@@ -705,6 +719,7 @@ void fdd_init(void)
|
||||
d86f_init();
|
||||
td0_init();
|
||||
imd_init();
|
||||
json_init();
|
||||
|
||||
fdd_load(0, floppyfns[0]);
|
||||
fdd_load(1, floppyfns[1]);
|
||||
|
||||
271
src/floppy/fdd.h
271
src/floppy/fdd.h
@@ -1,34 +1,54 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the floppy drive emulation.
|
||||
* Definitions for the floppy drive emulation.
|
||||
*
|
||||
* Version: @(#)fdd.h 1.0.5 2018/01/18
|
||||
* Version: @(#)fdd.h 1.0.3 2018/03/17
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#ifndef EMU_FDD_H
|
||||
# define EMU_FDD_H
|
||||
|
||||
|
||||
#define FDD_NUM 4
|
||||
#define SEEK_RECALIBRATE -999
|
||||
#define FDD_NUM 4
|
||||
#define SEEK_RECALIBRATE -999
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int fdd_swap;
|
||||
extern int fdd_swap;
|
||||
|
||||
|
||||
extern void fdd_do_seek(int drive, int track);
|
||||
@@ -65,16 +85,19 @@ extern int fdd_current_track(int drive);
|
||||
|
||||
|
||||
typedef struct {
|
||||
void (*seek)(int drive, int track);
|
||||
void (*readsector)(int drive, int sector, int track, int side, int density, int sector_size);
|
||||
void (*writesector)(int drive, int sector, int track, int side, int density, int sector_size);
|
||||
void (*comparesector)(int drive, int sector, int track, int side, int density, int sector_size);
|
||||
void (*readaddress)(int drive, int side, int density);
|
||||
void (*format)(int drive, int side, int density, uint8_t fill);
|
||||
int (*hole)(int drive);
|
||||
double (*byteperiod)(int drive);
|
||||
void (*stop)(int drive);
|
||||
void (*poll)(int drive);
|
||||
void (*seek)(int drive, int track);
|
||||
void (*readsector)(int drive, int sector, int track, int side,
|
||||
int density, int sector_size);
|
||||
void (*writesector)(int drive, int sector, int track, int side,
|
||||
int density, int sector_size);
|
||||
void (*comparesector)(int drive, int sector, int track, int side,
|
||||
int density, int sector_size);
|
||||
void (*readaddress)(int drive, int side, int density);
|
||||
void (*format)(int drive, int side, int density, uint8_t fill);
|
||||
int (*hole)(int drive);
|
||||
double (*byteperiod)(int drive);
|
||||
void (*stop)(int drive);
|
||||
void (*poll)(int drive);
|
||||
} DRIVE;
|
||||
|
||||
|
||||
@@ -115,60 +138,24 @@ extern void fdd_stop(int drive);
|
||||
extern int fdd_empty(int drive);
|
||||
extern void fdd_set_rate(int drive, int drvden, int rate);
|
||||
|
||||
extern int motorspin;
|
||||
extern int64_t motoron[FDD_NUM];
|
||||
extern int motorspin;
|
||||
extern int64_t motoron[FDD_NUM];
|
||||
|
||||
extern int swwp;
|
||||
extern int disable_write;
|
||||
extern int swwp;
|
||||
extern int disable_write;
|
||||
|
||||
extern int defaultwriteprot;
|
||||
extern int defaultwriteprot;
|
||||
|
||||
extern int writeprot[FDD_NUM], fwriteprot[FDD_NUM];
|
||||
extern int fdd_cur_track[FDD_NUM];
|
||||
extern int fdd_changed[FDD_NUM];
|
||||
extern int drive_empty[FDD_NUM];
|
||||
extern int drive_type[FDD_NUM];
|
||||
extern int writeprot[FDD_NUM], fwriteprot[FDD_NUM];
|
||||
extern int fdd_cur_track[FDD_NUM];
|
||||
extern int fdd_changed[FDD_NUM];
|
||||
extern int drive_empty[FDD_NUM];
|
||||
extern int drive_type[FDD_NUM];
|
||||
|
||||
/*Used in the Read A Track command. Only valid for fdd_readsector(). */
|
||||
#define SECTOR_FIRST -2
|
||||
#define SECTOR_NEXT -1
|
||||
|
||||
#if 0
|
||||
/* Bits 0-3 define byte type, bit 5 defines whether it is a per-track (0) or per-sector (1) byte, if bit 7 is set, the byte is the index hole. */
|
||||
#define BYTE_GAP0 0x00
|
||||
#define BYTE_GAP1 0x10
|
||||
#define BYTE_GAP4 0x20
|
||||
#define BYTE_GAP2 0x40
|
||||
#define BYTE_GAP3 0x50
|
||||
#define BYTE_I_SYNC 0x01
|
||||
#define BYTE_ID_SYNC 0x41
|
||||
#define BYTE_DATA_SYNC 0x51
|
||||
#define BYTE_IAM_SYNC 0x02
|
||||
#define BYTE_IDAM_SYNC 0x42
|
||||
#define BYTE_DATAAM_SYNC 0x52
|
||||
#define BYTE_IAM 0x03
|
||||
#define BYTE_IDAM 0x43
|
||||
#define BYTE_DATAAM 0x53
|
||||
#define BYTE_ID 0x44
|
||||
#define BYTE_DATA 0x54
|
||||
#define BYTE_ID_CRC 0x45
|
||||
#define BYTE_DATA_CRC 0x55
|
||||
|
||||
#define BYTE_IS_FUZZY 0x80
|
||||
#define BYTE_INDEX_HOLE 0x80 /* 1 = index hole, 0 = regular byte */
|
||||
#define BYTE_IS_SECTOR 0x40 /* 1 = per-sector, 0 = per-track */
|
||||
#define BYTE_IS_POST_TRACK 0x20 /* 1 = after all sectors, 0 = before or during all sectors */
|
||||
#define BYTE_IS_DATA 0x10 /* 1 = data, 0 = id */
|
||||
#define BYTE_TYPE 0x0F /* 5 = crc, 4 = data, 3 = address mark, 2 = address mark sync, 1 = sync, 0 = gap */
|
||||
|
||||
#define BYTE_TYPE_GAP 0x00
|
||||
#define BYTE_TYPE_SYNC 0x01
|
||||
#define BYTE_TYPE_AM_SYNC 0x02
|
||||
#define BYTE_TYPE_AM 0x03
|
||||
#define BYTE_TYPE_DATA 0x04
|
||||
#define BYTE_TYPE_CRC 0x05
|
||||
#endif
|
||||
|
||||
typedef union {
|
||||
uint16_t word;
|
||||
uint8_t bytes[2];
|
||||
@@ -176,94 +163,92 @@ typedef union {
|
||||
|
||||
void fdd_calccrc(uint8_t byte, crc_t *crc_var);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t (*disk_flags)(int drive);
|
||||
uint16_t (*side_flags)(int drive);
|
||||
void (*writeback)(int drive);
|
||||
void (*set_sector)(int drive, int side, uint8_t c, uint8_t h, uint8_t r, uint8_t n);
|
||||
uint8_t (*read_data)(int drive, int side, uint16_t pos);
|
||||
void (*write_data)(int drive, int side, uint16_t pos, uint8_t data);
|
||||
int (*format_conditions)(int drive);
|
||||
int32_t (*extra_bit_cells)(int drive, int side);
|
||||
uint16_t* (*encoded_data)(int drive, int side);
|
||||
void (*read_revolution)(int drive);
|
||||
uint32_t (*index_hole_pos)(int drive, int side);
|
||||
uint32_t (*get_raw_size)(int drive, int side);
|
||||
uint8_t check_crc;
|
||||
typedef struct {
|
||||
uint16_t (*disk_flags)(int drive);
|
||||
uint16_t (*side_flags)(int drive);
|
||||
void (*writeback)(int drive);
|
||||
void (*set_sector)(int drive, int side, uint8_t c, uint8_t h,
|
||||
uint8_t r, uint8_t n);
|
||||
uint8_t (*read_data)(int drive, int side, uint16_t pos);
|
||||
void (*write_data)(int drive, int side, uint16_t pos,
|
||||
uint8_t data);
|
||||
int (*format_conditions)(int drive);
|
||||
int32_t (*extra_bit_cells)(int drive, int side);
|
||||
uint16_t* (*encoded_data)(int drive, int side);
|
||||
void (*read_revolution)(int drive);
|
||||
uint32_t (*index_hole_pos)(int drive, int side);
|
||||
uint32_t (*get_raw_size)(int drive, int side);
|
||||
|
||||
uint8_t check_crc;
|
||||
} d86f_handler_t;
|
||||
|
||||
d86f_handler_t d86f_handler[FDD_NUM];
|
||||
extern const int gap3_sizes[5][8][48];
|
||||
extern d86f_handler_t d86f_handler[FDD_NUM];
|
||||
|
||||
void d86f_common_handlers(int drive);
|
||||
extern void d86f_setup(int drive);
|
||||
extern void d86f_destroy(int drive);
|
||||
extern int d86f_export(int drive, wchar_t *fn);
|
||||
extern void d86f_unregister(int drive);
|
||||
extern void d86f_common_handlers(int drive);
|
||||
extern void d86f_set_version(int drive, uint16_t version);
|
||||
extern int d86f_is_40_track(int drive);
|
||||
extern void d86f_reset_index_hole_pos(int drive, int side);
|
||||
extern uint16_t d86f_prepare_pretrack(int drive, int side, int iso);
|
||||
extern uint16_t d86f_prepare_sector(int drive, int side, int prev_pos,
|
||||
uint8_t *id_buf, uint8_t *data_buf,
|
||||
int data_len, int gap2, int gap3,
|
||||
int deleted, int bad_crc);
|
||||
extern void d86f_set_track_pos(int drive, uint32_t track_pos);
|
||||
extern void d86f_set_cur_track(int drive, int track);
|
||||
extern void d86f_zero_track(int drive);
|
||||
extern void d86f_initialize_last_sector_id(int drive, int c, int h,
|
||||
int r, int n);
|
||||
extern void d86f_initialize_linked_lists(int drive);
|
||||
extern void d86f_destroy_linked_lists(int drive, int side);
|
||||
extern uint16_t *common_encoded_data(int drive, int side);
|
||||
extern void common_read_revolution(int drive);
|
||||
extern uint32_t common_get_raw_size(int drive, int side);
|
||||
extern void null_writeback(int drive);
|
||||
extern void null_write_data(int drive, int side, uint16_t pos,
|
||||
uint8_t data);
|
||||
extern int null_format_conditions(int drive);
|
||||
extern int32_t null_extra_bit_cells(int drive, int side);
|
||||
extern void null_set_sector(int drive, int side, uint8_t c, uint8_t h,
|
||||
uint8_t r, uint8_t n);
|
||||
extern uint32_t null_index_hole_pos(int drive, int side);
|
||||
|
||||
int d86f_is_40_track(int drive);
|
||||
extern const uint8_t dmf_r[21];
|
||||
extern const uint8_t xdf_physical_sectors[2][2];
|
||||
extern const uint8_t xdf_gap3_sizes[2][2];
|
||||
extern const uint16_t xdf_trackx_spos[2][8];
|
||||
|
||||
void d86f_reset_index_hole_pos(int drive, int side);
|
||||
|
||||
uint16_t d86f_prepare_pretrack(int drive, int side, int iso);
|
||||
uint16_t d86f_prepare_sector(int drive, int side, int prev_pos, uint8_t *id_buf, uint8_t *data_buf, int data_len, int gap2, int gap3, int deleted, int bad_crc);
|
||||
|
||||
extern int gap3_sizes[5][8][48];
|
||||
|
||||
void null_writeback(int drive);
|
||||
void null_write_data(int drive, int side, uint16_t pos, uint8_t data);
|
||||
int null_format_conditions(int drive);
|
||||
void d86f_unregister(int drive);
|
||||
|
||||
extern uint8_t dmf_r[21];
|
||||
extern uint8_t xdf_physical_sectors[2][2];
|
||||
extern uint8_t xdf_gap3_sizes[2][2];
|
||||
extern uint16_t xdf_trackx_spos[2][8];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t h;
|
||||
uint8_t r;
|
||||
typedef struct {
|
||||
uint8_t h;
|
||||
uint8_t r;
|
||||
} xdf_id_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint16_t word;
|
||||
xdf_id_t id;
|
||||
typedef union {
|
||||
uint16_t word;
|
||||
xdf_id_t id;
|
||||
} xdf_sector_t;
|
||||
|
||||
extern xdf_sector_t xdf_img_layout[2][2][46];
|
||||
extern xdf_sector_t xdf_disk_layout[2][2][38];
|
||||
extern const xdf_sector_t xdf_img_layout[2][2][46];
|
||||
extern const xdf_sector_t xdf_disk_layout[2][2][38];
|
||||
|
||||
uint32_t td0_get_raw_tsize(int side_flags, int slower_rpm);
|
||||
|
||||
void d86f_set_track_pos(int drive, uint32_t track_pos);
|
||||
|
||||
int32_t null_extra_bit_cells(int drive, int side);
|
||||
uint16_t* common_encoded_data(int drive, int side);
|
||||
|
||||
void common_read_revolution(int drive);
|
||||
void null_set_sector(int drive, int side, uint8_t c, uint8_t h, uint8_t r, uint8_t n);
|
||||
|
||||
uint32_t null_index_hole_pos(int drive, int side);
|
||||
|
||||
uint32_t common_get_raw_size(int drive, int side);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t c;
|
||||
uint8_t h;
|
||||
uint8_t r;
|
||||
uint8_t n;
|
||||
typedef struct {
|
||||
uint8_t c;
|
||||
uint8_t h;
|
||||
uint8_t r;
|
||||
uint8_t n;
|
||||
} sector_id_fields_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint32_t dword;
|
||||
uint8_t byte_array[4];
|
||||
sector_id_fields_t id;
|
||||
typedef union {
|
||||
uint32_t dword;
|
||||
uint8_t byte_array[4];
|
||||
sector_id_fields_t id;
|
||||
} sector_id_t;
|
||||
|
||||
void d86f_set_version(int drive, uint16_t version);
|
||||
|
||||
void d86f_initialize_last_sector_id(int drive, int c, int h, int r, int n);
|
||||
void d86f_destroy_linked_lists(int drive, int side);
|
||||
|
||||
void d86f_set_fdc(void *fdc);
|
||||
void fdi_set_fdc(void *fdc);
|
||||
@@ -271,10 +256,6 @@ void fdd_set_fdc(void *fdc);
|
||||
void imd_set_fdc(void *fdc);
|
||||
void img_set_fdc(void *fdc);
|
||||
|
||||
extern void d86f_set_cur_track(int drive, int track);
|
||||
extern void d86f_zero_track(int drive);
|
||||
|
||||
extern int d86f_export(int drive, wchar_t *fn);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
6939
src/floppy/fdd_86f.c
6939
src/floppy/fdd_86f.c
File diff suppressed because it is too large
Load Diff
@@ -1,24 +1,46 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the 86F floppy image format (stores the
|
||||
* data in the form of FM/MFM-encoded transitions) which also
|
||||
* forms the core of the emulator's floppy disk emulation.
|
||||
* Definitions for the 86F floppy image format.
|
||||
*
|
||||
* Version: @(#)floppy_86f.h 1.0.5 2018/03/14
|
||||
* Version: @(#)floppy_86f.h 1.0.4 2018/03/17
|
||||
*
|
||||
* Author: Miran Grca, <mgrca8@gmail.com>
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#ifndef EMU_FLOPPY_86F_H
|
||||
# define EMU_FLOPPY_86F_H
|
||||
|
||||
|
||||
#define D86FVER 0x020B
|
||||
|
||||
|
||||
extern void d86f_init(void);
|
||||
extern void d86f_load(int drive, wchar_t *fn);
|
||||
extern void d86f_close(int drive);
|
||||
@@ -39,6 +61,10 @@ extern void d86f_prepare_track_layout(int drive, int side);
|
||||
extern void d86f_set_version(int drive, uint16_t version);
|
||||
extern uint16_t d86f_side_flags(int drive);
|
||||
extern uint16_t d86f_track_flags(int drive);
|
||||
extern void d86f_initialize_last_sector_id(int drive, int c, int h,
|
||||
int r, int n);
|
||||
extern void d86f_initialize_linked_lists(int drive);
|
||||
extern void d86f_destroy_linked_lists(int drive, int side);
|
||||
|
||||
#define length_gap0 80
|
||||
#define length_gap1 50
|
||||
@@ -59,19 +85,5 @@ extern uint16_t d86f_track_flags(int drive);
|
||||
#define pre_data length_sync + length_am
|
||||
#define post_gap length_crc
|
||||
|
||||
#if 0
|
||||
extern int raw_tsize[2];
|
||||
extern int gap2_size[2];
|
||||
extern int gap3_size[2];
|
||||
extern int gap4_size[2];
|
||||
#endif
|
||||
|
||||
#define D86FVER 0x020B
|
||||
|
||||
extern void d86f_initialize_last_sector_id(int drive, int c, int h, int r, int n);
|
||||
|
||||
extern void d86f_initialize_linked_lists(int drive);
|
||||
extern void d86f_destroy_linked_lists(int drive, int side);
|
||||
|
||||
|
||||
#endif /*EMU_FLOPPY_86F_H*/
|
||||
|
||||
@@ -1,17 +1,36 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Shared code for all the floppy modules.
|
||||
*
|
||||
* Version: @(#)fdd_common.c 1.0.5 2018/01/16
|
||||
* Version: @(#)fdd_common.c 1.0.2 2018/03/16
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -23,11 +42,11 @@
|
||||
#include "fdd_common.h"
|
||||
|
||||
|
||||
uint8_t fdd_holes[6] = { 0, 0, 0, 1, 1, 2 };
|
||||
const uint8_t fdd_holes[6] = { 0, 0, 0, 1, 1, 2 };
|
||||
|
||||
uint8_t fdd_rates[6] = { 2, 2, 1, 4, 0, 3 };
|
||||
const uint8_t fdd_rates[6] = { 2, 2, 1, 4, 0, 3 };
|
||||
|
||||
double fdd_bit_rates_300[6] = {
|
||||
const double fdd_bit_rates_300[6] = {
|
||||
(250.0 * 300.0) / 360.0,
|
||||
250.0,
|
||||
300.0,
|
||||
@@ -46,7 +65,7 @@ double fdd_bit_rates_300[6] = {
|
||||
* Disks formatted at 300 kbps @ 300 RPM can be read with any 300 RPM
|
||||
* single-RPM drive by setting the rate to 300 kbps.
|
||||
*/
|
||||
uint8_t fdd_max_sectors[8][6] = {
|
||||
const uint8_t fdd_max_sectors[8][6] = {
|
||||
{ 26, 31, 38, 53, 64, 118 }, /* 128 */
|
||||
{ 15, 19, 23, 32, 38, 73 }, /* 256 */
|
||||
{ 7, 10, 12, 17, 22, 41 }, /* 512 */
|
||||
@@ -57,12 +76,12 @@ uint8_t fdd_max_sectors[8][6] = {
|
||||
{ 0, 0, 0, 0, 0, 1 } /* 16384 */
|
||||
};
|
||||
|
||||
uint8_t fdd_dmf_r[21] = {
|
||||
const uint8_t fdd_dmf_r[21] = {
|
||||
12,2,13,3,14,4,15,5,16,6,17,7,18,8,19,9,20,10,21,11,1
|
||||
};
|
||||
|
||||
|
||||
static uint8_t fdd_gap3_sizes[5][8][48] = {
|
||||
static const uint8_t fdd_gap3_sizes[5][8][48] = {
|
||||
{ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* [0][0] */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
@@ -346,7 +365,6 @@ static uint8_t fdd_gap3_sizes[5][8][48] = {
|
||||
};
|
||||
|
||||
|
||||
|
||||
int
|
||||
fdd_get_gap3_size(int rate, int size, int sector)
|
||||
{
|
||||
|
||||
@@ -1,27 +1,46 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Shared code for all the floppy modules.
|
||||
*
|
||||
* Version: @(#)fdd_common.h 1.0.2 2018/01/16
|
||||
* Version: @(#)fdd_common.h 1.0.2 2018/03/16
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#ifndef fdd_COMMON_H
|
||||
# define fdd_COMMON_H
|
||||
#ifndef FDD_COMMON_H
|
||||
# define FDD_COMMON_H
|
||||
|
||||
|
||||
extern uint8_t fdd_holes[6];
|
||||
extern uint8_t fdd_rates[6];
|
||||
extern double fdd_bit_rates_300[6];
|
||||
extern uint8_t fdd_max_sectors[8][6];
|
||||
extern uint8_t fdd_dmf_r[21];
|
||||
extern const uint8_t fdd_holes[6];
|
||||
extern const uint8_t fdd_rates[6];
|
||||
extern const double fdd_bit_rates_300[6];
|
||||
extern const uint8_t fdd_max_sectors[8][6];
|
||||
extern const uint8_t fdd_dmf_r[21];
|
||||
|
||||
|
||||
extern int fdd_get_gap3_size(int rate, int size, int sector);
|
||||
@@ -31,4 +50,4 @@ extern int fdd_bps_valid(uint16_t bps);
|
||||
extern int fdd_interleave(int sector, int skew, int spt);
|
||||
|
||||
|
||||
#endif /*fdd_COMMON_H*/
|
||||
#endif /*FDD_COMMON_H*/
|
||||
|
||||
@@ -1,25 +1,46 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the FDI floppy stream image format
|
||||
* interface to the FDI2RAW module.
|
||||
*
|
||||
* Version: @(#)fdd_fdi.c 1.0.7 2018/01/16
|
||||
* Version: @(#)fdd_fdi.c 1.0.2 2018/03/17
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include "../86box.h"
|
||||
#include "../plat.h"
|
||||
@@ -31,317 +52,355 @@
|
||||
#include "fdi2raw.h"
|
||||
|
||||
|
||||
static struct
|
||||
typedef struct {
|
||||
FILE *f;
|
||||
FDI *h;
|
||||
|
||||
int lasttrack;
|
||||
int sides;
|
||||
int track;
|
||||
int tracklen[2][4];
|
||||
int trackindex[2][4];
|
||||
|
||||
uint8_t track_data[2][4][256*1024];
|
||||
uint8_t track_timing[2][4][256*1024];
|
||||
} fdi_t;
|
||||
|
||||
|
||||
static fdi_t *fdi[FDD_NUM];
|
||||
static fdc_t *fdi_fdc;
|
||||
|
||||
|
||||
static uint16_t
|
||||
disk_flags(int drive)
|
||||
{
|
||||
FILE *f;
|
||||
FDI *h;
|
||||
uint8_t track_data[2][4][256*1024];
|
||||
uint8_t track_timing[2][4][256*1024];
|
||||
|
||||
int sides;
|
||||
int track;
|
||||
int tracklen[2][4];
|
||||
int trackindex[2][4];
|
||||
|
||||
int lasttrack;
|
||||
} fdi[FDD_NUM];
|
||||
fdi_t *dev = fdi[drive];
|
||||
uint16_t temp_disk_flags = 0x80; /* We ALWAYS claim to have extra bit cells, even if the actual amount is 0. */
|
||||
|
||||
static fdc_t *fdi_fdc;
|
||||
switch (fdi2raw_get_bit_rate(dev->h)) {
|
||||
case 500:
|
||||
temp_disk_flags |= 2;
|
||||
break;
|
||||
|
||||
uint16_t fdi_disk_flags(int drive)
|
||||
{
|
||||
uint16_t temp_disk_flags = 0x80; /* We ALWAYS claim to have extra bit cells, even if the actual amount is 0. */
|
||||
case 300:
|
||||
case 250:
|
||||
temp_disk_flags |= 0;
|
||||
break;
|
||||
|
||||
switch (fdi2raw_get_bit_rate(fdi[drive].h))
|
||||
{
|
||||
case 500:
|
||||
temp_disk_flags |= 2;
|
||||
break;
|
||||
case 300:
|
||||
case 250:
|
||||
temp_disk_flags |= 0;
|
||||
break;
|
||||
case 1000:
|
||||
temp_disk_flags |= 4;
|
||||
break;
|
||||
default:
|
||||
temp_disk_flags |= 0;
|
||||
}
|
||||
case 1000:
|
||||
temp_disk_flags |= 4;
|
||||
break;
|
||||
|
||||
if (fdi[drive].sides == 2)
|
||||
{
|
||||
temp_disk_flags |= 8;
|
||||
}
|
||||
default:
|
||||
temp_disk_flags |= 0;
|
||||
}
|
||||
|
||||
/* Tell the 86F handler that will handle our data to handle it in reverse byte endianness. */
|
||||
temp_disk_flags |= 0x800;
|
||||
if (dev->sides == 2)
|
||||
temp_disk_flags |= 8;
|
||||
|
||||
return temp_disk_flags;
|
||||
/*
|
||||
* Tell the 86F handler that we will handle our
|
||||
* data to handle it in reverse byte endianness.
|
||||
*/
|
||||
temp_disk_flags |= 0x800;
|
||||
|
||||
return(temp_disk_flags);
|
||||
}
|
||||
|
||||
uint16_t fdi_side_flags(int drive)
|
||||
|
||||
static uint16_t
|
||||
side_flags(int drive)
|
||||
{
|
||||
uint16_t temp_side_flags = 0;
|
||||
switch (fdi2raw_get_bit_rate(fdi[drive].h))
|
||||
{
|
||||
case 500:
|
||||
temp_side_flags = 0;
|
||||
break;
|
||||
case 300:
|
||||
temp_side_flags = 1;
|
||||
break;
|
||||
case 250:
|
||||
temp_side_flags = 2;
|
||||
break;
|
||||
case 1000:
|
||||
temp_side_flags = 3;
|
||||
break;
|
||||
default:
|
||||
temp_side_flags = 2;
|
||||
}
|
||||
if (fdi2raw_get_rotation(fdi[drive].h) == 360)
|
||||
{
|
||||
temp_side_flags |= 0x20;
|
||||
}
|
||||
fdi_t *dev = fdi[drive];
|
||||
uint16_t temp_side_flags = 0;
|
||||
|
||||
/* Set the encoding value to match that provided by the FDC. Then if it's wrong, it will sector not found anyway. */
|
||||
temp_side_flags |= 0x08;
|
||||
switch (fdi2raw_get_bit_rate(dev->h)) {
|
||||
case 500:
|
||||
temp_side_flags = 0;
|
||||
break;
|
||||
|
||||
return temp_side_flags;
|
||||
case 300:
|
||||
temp_side_flags = 1;
|
||||
break;
|
||||
|
||||
case 250:
|
||||
temp_side_flags = 2;
|
||||
break;
|
||||
|
||||
case 1000:
|
||||
temp_side_flags = 3;
|
||||
break;
|
||||
|
||||
default:
|
||||
temp_side_flags = 2;
|
||||
}
|
||||
|
||||
if (fdi2raw_get_rotation(dev->h) == 360)
|
||||
temp_side_flags |= 0x20;
|
||||
|
||||
/*
|
||||
* Set the encoding value to match that provided by the FDC.
|
||||
* Then if it's wrong, it will sector not found anyway.
|
||||
*/
|
||||
temp_side_flags |= 0x08;
|
||||
|
||||
return(temp_side_flags);
|
||||
}
|
||||
|
||||
int fdi_density()
|
||||
{
|
||||
if (!fdc_is_mfm(fdi_fdc))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (fdc_get_bit_rate(fdi_fdc))
|
||||
{
|
||||
case 0:
|
||||
return 2;
|
||||
case 1:
|
||||
return 1;
|
||||
case 2:
|
||||
return 1;
|
||||
case 3:
|
||||
case 5:
|
||||
return 3;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
static int
|
||||
fdi_density(void)
|
||||
{
|
||||
if (! fdc_is_mfm(fdi_fdc)) return(0);
|
||||
|
||||
switch (fdc_get_bit_rate(fdi_fdc)) {
|
||||
case 0:
|
||||
return(2);
|
||||
|
||||
case 1:
|
||||
return(1);
|
||||
|
||||
case 2:
|
||||
return(1);
|
||||
|
||||
case 3:
|
||||
case 5:
|
||||
return(3);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return(1);
|
||||
}
|
||||
|
||||
int32_t fdi_extra_bit_cells(int drive, int side)
|
||||
|
||||
static int32_t
|
||||
extra_bit_cells(int drive, int side)
|
||||
{
|
||||
int density = 0;
|
||||
fdi_t *dev = fdi[drive];
|
||||
int density = 0;
|
||||
int raw_size = 0;
|
||||
int is_300_rpm = 0;
|
||||
|
||||
int raw_size = 0;
|
||||
density = fdi_density();
|
||||
|
||||
int is_300_rpm = 0;
|
||||
is_300_rpm = (fdd_getrpm(drive) == 300);
|
||||
|
||||
density = fdi_density();
|
||||
switch (fdc_get_bit_rate(fdi_fdc)) {
|
||||
case 0:
|
||||
raw_size = is_300_rpm ? 200000 : 166666;
|
||||
break;
|
||||
|
||||
is_300_rpm = (fdd_getrpm(drive) == 300);
|
||||
case 1:
|
||||
raw_size = is_300_rpm ? 120000 : 100000;
|
||||
break;
|
||||
|
||||
switch (fdc_get_bit_rate(fdi_fdc))
|
||||
{
|
||||
case 0:
|
||||
raw_size = is_300_rpm ? 200000 : 166666;
|
||||
break;
|
||||
case 1:
|
||||
raw_size = is_300_rpm ? 120000 : 100000;
|
||||
break;
|
||||
case 2:
|
||||
raw_size = is_300_rpm ? 100000 : 83333;
|
||||
case 3:
|
||||
case 5:
|
||||
raw_size = is_300_rpm ? 400000 : 333333;
|
||||
break;
|
||||
default:
|
||||
raw_size = is_300_rpm ? 100000 : 83333;
|
||||
case 2:
|
||||
raw_size = is_300_rpm ? 100000 : 83333;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
case 5:
|
||||
raw_size = is_300_rpm ? 400000 : 333333;
|
||||
break;
|
||||
|
||||
default:
|
||||
raw_size = is_300_rpm ? 100000 : 83333;
|
||||
}
|
||||
|
||||
return((dev->tracklen[side][density] - raw_size));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
read_revolution(int drive)
|
||||
{
|
||||
fdi_t *dev = fdi[drive];
|
||||
int c, den, side;
|
||||
int track = dev->track;
|
||||
|
||||
if (track > dev->lasttrack) {
|
||||
for (den = 0; den < 4; den++) {
|
||||
memset(dev->track_data[0][den], 0, 106096);
|
||||
memset(dev->track_data[1][den], 0, 106096);
|
||||
dev->tracklen[0][den] = dev->tracklen[1][den] = 100000;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for (den = 0; den < 4; den++) {
|
||||
for (side = 0; side < dev->sides; side++) {
|
||||
c = fdi2raw_loadtrack(dev->h,
|
||||
(uint16_t *)dev->track_data[side][den],
|
||||
(uint16_t *)dev->track_timing[side][den],
|
||||
(track * dev->sides) + side,
|
||||
&dev->tracklen[side][den],
|
||||
&dev->trackindex[side][den], NULL, den);
|
||||
if (! c)
|
||||
memset(dev->track_data[side][den], 0, dev->tracklen[side][den]);
|
||||
}
|
||||
|
||||
return (fdi[drive].tracklen[side][density] - raw_size);
|
||||
}
|
||||
|
||||
int fdi_hole(int drive)
|
||||
{
|
||||
switch (fdi2raw_get_bit_rate(fdi[drive].h))
|
||||
{
|
||||
case 1000:
|
||||
return 2;
|
||||
case 500:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
if (dev->sides == 1) {
|
||||
memset(dev->track_data[1][den], 0, 106096);
|
||||
dev->tracklen[1][den] = 100000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void fdi_read_revolution(int drive)
|
||||
|
||||
static uint32_t
|
||||
index_hole_pos(int drive, int side)
|
||||
{
|
||||
int density;
|
||||
int track = fdi[drive].track;
|
||||
fdi_t *dev = fdi[drive];
|
||||
int density;
|
||||
|
||||
int side = 0;
|
||||
density = fdi_density();
|
||||
|
||||
if (track > fdi[drive].lasttrack)
|
||||
{
|
||||
for (density = 0; density < 4; density++)
|
||||
{
|
||||
memset(fdi[drive].track_data[0][density], 0, 106096);
|
||||
memset(fdi[drive].track_data[1][density], 0, 106096);
|
||||
fdi[drive].tracklen[0][density] = fdi[drive].tracklen[1][density] = 100000;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for (density = 0; density < 4; density++)
|
||||
{
|
||||
for (side = 0; side < fdi[drive].sides; side++)
|
||||
{
|
||||
int c = fdi2raw_loadtrack(fdi[drive].h, (uint16_t *)fdi[drive].track_data[side][density],
|
||||
(uint16_t *)fdi[drive].track_timing[side][density],
|
||||
(track * fdi[drive].sides) + side,
|
||||
&fdi[drive].tracklen[side][density],
|
||||
&fdi[drive].trackindex[side][density], NULL, density);
|
||||
if (!c)
|
||||
memset(fdi[drive].track_data[side][density], 0, fdi[drive].tracklen[side][density]);
|
||||
}
|
||||
|
||||
if (fdi[drive].sides == 1)
|
||||
{
|
||||
memset(fdi[drive].track_data[1][density], 0, 106096);
|
||||
fdi[drive].tracklen[1][density] = 100000;
|
||||
}
|
||||
}
|
||||
return(dev->trackindex[side][density]);
|
||||
}
|
||||
|
||||
uint32_t fdi_index_hole_pos(int drive, int side)
|
||||
|
||||
static uint32_t
|
||||
get_raw_size(int drive, int side)
|
||||
{
|
||||
int density;
|
||||
fdi_t *dev = fdi[drive];
|
||||
int density;
|
||||
|
||||
density = fdi_density();
|
||||
density = fdi_density();
|
||||
|
||||
return fdi[drive].trackindex[side][density];
|
||||
return(dev->tracklen[side][density]);
|
||||
}
|
||||
|
||||
uint32_t fdi_get_raw_size(int drive, int side)
|
||||
|
||||
static uint16_t *
|
||||
encoded_data(int drive, int side)
|
||||
{
|
||||
int density;
|
||||
fdi_t *dev = fdi[drive];
|
||||
int density = 0;
|
||||
|
||||
density = fdi_density();
|
||||
density = fdi_density();
|
||||
|
||||
return fdi[drive].tracklen[side][density];
|
||||
return((uint16_t *)dev->track_data[side][density]);
|
||||
}
|
||||
|
||||
uint16_t* fdi_encoded_data(int drive, int side)
|
||||
|
||||
void
|
||||
fdi_seek(int drive, int track)
|
||||
{
|
||||
int density = 0;
|
||||
fdi_t *dev = fdi[drive];
|
||||
|
||||
density = fdi_density();
|
||||
if (fdd_doublestep_40(drive)) {
|
||||
if (fdi2raw_get_tpi(dev->h) < 2)
|
||||
track /= 2;
|
||||
}
|
||||
|
||||
return (uint16_t *)fdi[drive].track_data[side][density];
|
||||
}
|
||||
d86f_set_cur_track(drive, track);
|
||||
|
||||
void d86f_register_fdi(int drive)
|
||||
{
|
||||
d86f_handler[drive].disk_flags = fdi_disk_flags;
|
||||
d86f_handler[drive].side_flags = fdi_side_flags;
|
||||
d86f_handler[drive].writeback = null_writeback;
|
||||
d86f_handler[drive].set_sector = null_set_sector;
|
||||
d86f_handler[drive].write_data = null_write_data;
|
||||
d86f_handler[drive].format_conditions = null_format_conditions;
|
||||
d86f_handler[drive].extra_bit_cells = fdi_extra_bit_cells;
|
||||
d86f_handler[drive].encoded_data = fdi_encoded_data;
|
||||
d86f_handler[drive].read_revolution = fdi_read_revolution;
|
||||
d86f_handler[drive].index_hole_pos = fdi_index_hole_pos;
|
||||
d86f_handler[drive].get_raw_size = fdi_get_raw_size;
|
||||
d86f_handler[drive].check_crc = 1;
|
||||
d86f_set_version(drive, D86FVER);
|
||||
}
|
||||
if (dev->f == NULL) return;
|
||||
|
||||
void fdi_load(int drive, wchar_t *fn)
|
||||
{
|
||||
char header[26];
|
||||
|
||||
writeprot[drive] = fwriteprot[drive] = 1;
|
||||
fdi[drive].f = plat_fopen(fn, L"rb");
|
||||
if (!fdi[drive].f)
|
||||
{
|
||||
memset(floppyfns[drive], 0, sizeof(floppyfns[drive]));
|
||||
return;
|
||||
}
|
||||
|
||||
d86f_unregister(drive);
|
||||
|
||||
fread(header, 1, 25, fdi[drive].f);
|
||||
fseek(fdi[drive].f, 0, SEEK_SET);
|
||||
header[25] = 0;
|
||||
if (strcmp(header, "Formatted Disk Image file") != 0)
|
||||
{
|
||||
/* This is a Japanese FDI file. */
|
||||
pclog("fdi_load(): Japanese FDI file detected, redirecting to IMG loader\n");
|
||||
fclose(fdi[drive].f);
|
||||
fdi[drive].f = NULL;
|
||||
img_load(drive, fn);
|
||||
return;
|
||||
}
|
||||
|
||||
fdi[drive].h = fdi2raw_header(fdi[drive].f);
|
||||
fdi[drive].lasttrack = fdi2raw_get_last_track(fdi[drive].h);
|
||||
fdi[drive].sides = fdi2raw_get_last_head(fdi[drive].h) + 1;
|
||||
|
||||
d86f_register_fdi(drive);
|
||||
|
||||
drives[drive].seek = fdi_seek;
|
||||
d86f_common_handlers(drive);
|
||||
|
||||
pclog("Loaded as FDI\n");
|
||||
}
|
||||
|
||||
void fdi_close(int drive)
|
||||
{
|
||||
d86f_unregister(drive);
|
||||
drives[drive].seek = NULL;
|
||||
if (fdi[drive].h)
|
||||
fdi2raw_header_free(fdi[drive].h);
|
||||
if (fdi[drive].f)
|
||||
{
|
||||
fclose(fdi[drive].f);
|
||||
fdi[drive].f = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void fdi_seek(int drive, int track)
|
||||
{
|
||||
if (fdd_doublestep_40(drive))
|
||||
{
|
||||
if (fdi2raw_get_tpi(fdi[drive].h) < 2)
|
||||
{
|
||||
track /= 2;
|
||||
}
|
||||
}
|
||||
|
||||
d86f_set_cur_track(drive, track);
|
||||
|
||||
if (!fdi[drive].f)
|
||||
return;
|
||||
if (track < 0)
|
||||
track = 0;
|
||||
if (track < 0)
|
||||
track = 0;
|
||||
|
||||
#if 0
|
||||
if (track > fdi[drive].lasttrack)
|
||||
track = fdi[drive].lasttrack - 1;
|
||||
if (track > dev->lasttrack)
|
||||
track = dev->lasttrack - 1;
|
||||
#endif
|
||||
|
||||
fdi[drive].track = track;
|
||||
dev->track = track;
|
||||
|
||||
fdi_read_revolution(drive);
|
||||
read_revolution(drive);
|
||||
}
|
||||
|
||||
void fdi_set_fdc(void *fdc)
|
||||
|
||||
void
|
||||
fdi_load(int drive, wchar_t *fn)
|
||||
{
|
||||
fdi_fdc = (fdc_t *) fdc;
|
||||
char header[26];
|
||||
fdi_t *dev;
|
||||
|
||||
writeprot[drive] = fwriteprot[drive] = 1;
|
||||
|
||||
/* Allocate a drive block. */
|
||||
dev = (fdi_t *)malloc(sizeof(fdi_t));
|
||||
memset(dev, 0x00, sizeof(fdi_t));
|
||||
|
||||
dev->f = plat_fopen(fn, L"rb");
|
||||
if (dev == NULL) {
|
||||
free(dev);
|
||||
memset(floppyfns[drive], 0, sizeof(floppyfns[drive]));
|
||||
return;
|
||||
}
|
||||
|
||||
d86f_unregister(drive);
|
||||
|
||||
fread(header, 1, 25, dev->f);
|
||||
fseek(dev->f, 0, SEEK_SET);
|
||||
header[25] = 0;
|
||||
if (strcmp(header, "Formatted Disk Image file") != 0) {
|
||||
/* This is a Japanese FDI file. */
|
||||
pclog("fdi_load(): Japanese FDI file detected, redirecting to IMG loader\n");
|
||||
fclose(dev->f);
|
||||
free(dev);
|
||||
img_load(drive, fn);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Set up the drive unit. */
|
||||
fdi[drive] = dev;
|
||||
|
||||
dev->h = fdi2raw_header(dev->f);
|
||||
dev->lasttrack = fdi2raw_get_last_track(dev->h);
|
||||
dev->sides = fdi2raw_get_last_head(dev->h) + 1;
|
||||
|
||||
/* Attach this format to the D86F engine. */
|
||||
d86f_handler[drive].disk_flags = disk_flags;
|
||||
d86f_handler[drive].side_flags = side_flags;
|
||||
d86f_handler[drive].writeback = null_writeback;
|
||||
d86f_handler[drive].set_sector = null_set_sector;
|
||||
d86f_handler[drive].write_data = null_write_data;
|
||||
d86f_handler[drive].format_conditions = null_format_conditions;
|
||||
d86f_handler[drive].extra_bit_cells = extra_bit_cells;
|
||||
d86f_handler[drive].encoded_data = encoded_data;
|
||||
d86f_handler[drive].read_revolution = read_revolution;
|
||||
d86f_handler[drive].index_hole_pos = index_hole_pos;
|
||||
d86f_handler[drive].get_raw_size = get_raw_size;
|
||||
d86f_handler[drive].check_crc = 1;
|
||||
d86f_set_version(drive, D86FVER);
|
||||
|
||||
d86f_common_handlers(drive);
|
||||
|
||||
drives[drive].seek = fdi_seek;
|
||||
|
||||
pclog("Loaded as FDI\n");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
fdi_close(int drive)
|
||||
{
|
||||
fdi_t *dev = fdi[drive];
|
||||
|
||||
if (dev == NULL) return;
|
||||
|
||||
d86f_unregister(drive);
|
||||
|
||||
drives[drive].seek = NULL;
|
||||
|
||||
if (dev->h)
|
||||
fdi2raw_header_free(dev->h);
|
||||
|
||||
if (dev->f)
|
||||
fclose(dev->f);
|
||||
|
||||
/* Release the memory. */
|
||||
free(dev);
|
||||
fdi[drive] = NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
fdi_set_fdc(void *fdc)
|
||||
{
|
||||
fdi_fdc = (fdc_t *)fdc;
|
||||
}
|
||||
|
||||
@@ -1,38 +1,49 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the FDI floppy stream image format
|
||||
* interface to the FDI2RAW module.
|
||||
*
|
||||
* Version: @(#)floppy_fdi.h 1.0.3 2017/12/14
|
||||
* Version: @(#)floppy_fdi.h 1.0.2 2018/03/17
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2008-2017 Sarah Walker.
|
||||
* Copyright 2016,2017 Miran Grca.
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#ifndef EMU_FLOPPY_FDI_H
|
||||
# define EMU_FLOPPY_FDI_H
|
||||
|
||||
|
||||
extern void fdi_load(int drive, wchar_t *fn);
|
||||
extern void fdi_close(int drive);
|
||||
extern void fdi_seek(int drive, int track);
|
||||
extern void fdi_readsector(int drive, int sector, int track, int side, int density, int sector_size);
|
||||
extern void fdi_writesector(int drive, int sector, int track, int side, int density, int sector_size);
|
||||
extern void fdi_comparesector(int drive, int sector, int track, int side, int density, int sector_size);
|
||||
extern void fdi_readaddress(int drive, int sector, int side, int density);
|
||||
extern void fdi_format(int drive, int sector, int side, int density, uint8_t fill);
|
||||
extern int fdi_hole(int drive);
|
||||
extern double fdi_byteperiod(int drive);
|
||||
extern void fdi_stop(void);
|
||||
extern void fdi_poll(void);
|
||||
extern void fdi_seek(int drive, int track);
|
||||
extern void fdi_load(int drive, wchar_t *fn);
|
||||
extern void fdi_close(int drive);
|
||||
|
||||
|
||||
#endif /*EMU_FLOPPY_FDI_H*/
|
||||
|
||||
1558
src/floppy/fdd_imd.c
1558
src/floppy/fdd_imd.c
File diff suppressed because it is too large
Load Diff
@@ -1,17 +1,38 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the IMD floppy image format.
|
||||
* Definitions for the IMD floppy image format.
|
||||
*
|
||||
* Version: @(#)floppy_imd.h 1.0.2 2017/09/03
|
||||
* Version: @(#)floppy_imd.h 1.0.2 2018/03/17
|
||||
*
|
||||
* Author: Miran Grca, <mgrca8@gmail.com>
|
||||
* Copyright 2016,2017 Miran Grca.
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#ifndef EMU_FLOPPY_IMD_H
|
||||
# define EMU_FLOPPY_IMD_H
|
||||
@@ -20,7 +41,6 @@
|
||||
extern void imd_init(void);
|
||||
extern void imd_load(int drive, wchar_t *fn);
|
||||
extern void imd_close(int drive);
|
||||
extern void imd_seek(int drive, int track);
|
||||
|
||||
|
||||
#endif /*EMU_FLOPPY_IMD_H*/
|
||||
|
||||
1888
src/floppy/fdd_img.c
1888
src/floppy/fdd_img.c
File diff suppressed because it is too large
Load Diff
@@ -1,29 +1,49 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the raw sector-based floppy image format,
|
||||
* as well as the Japanese FDI, CopyQM, and FDF formats.
|
||||
*
|
||||
* Version: @(#)floppy_img.h 1.0.2 2017/09/03
|
||||
* Version: @(#)floppy_img.h 1.0.2 2018/03/17
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Copyright 2008-2017 Sarah Walker.
|
||||
* Copyright 2016,2017 Miran Grca.
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#ifndef EMU_FLOPPY_IMG_H
|
||||
# define EMU_FLOPPY_IMG_H
|
||||
|
||||
|
||||
extern void img_init(void);
|
||||
extern void img_load(int drive, wchar_t *fn);
|
||||
extern void img_close(int drive);
|
||||
extern void img_seek(int drive, int track);
|
||||
extern void img_init(void);
|
||||
extern void img_load(int drive, wchar_t *fn);
|
||||
extern void img_close(int drive);
|
||||
|
||||
|
||||
#endif /*EMU_FLOPPY_IMG_H*/
|
||||
|
||||
@@ -1,18 +1,48 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the PCjs JSON floppy image format.
|
||||
*
|
||||
* Version: @(#)fdd_json.c 1.0.11 2018/03/14
|
||||
* Version: @(#)fdd_json.c 1.0.4 2018/03/17
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with
|
||||
* or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the entire
|
||||
* above notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names
|
||||
* of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific
|
||||
* prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (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 <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -71,11 +101,11 @@ typedef struct {
|
||||
} json_t;
|
||||
|
||||
|
||||
static json_t images[FDD_NUM];
|
||||
static json_t *images[FDD_NUM];
|
||||
|
||||
|
||||
static void
|
||||
handle(json_t *img, char *name, char *str)
|
||||
handle(json_t *dev, char *name, char *str)
|
||||
{
|
||||
sector_t *sec = NULL;
|
||||
uint32_t l, pat;
|
||||
@@ -84,7 +114,7 @@ handle(json_t *img, char *name, char *str)
|
||||
int i, s;
|
||||
|
||||
/* Point to the currently selected sector. */
|
||||
sec = &img->sects[img->track][img->side][img->dmf-1];
|
||||
sec = &dev->sects[dev->track][dev->side][dev->dmf-1];
|
||||
|
||||
/* If no name given, assume sector is done. */
|
||||
if (name == NULL) {
|
||||
@@ -98,8 +128,8 @@ handle(json_t *img, char *name, char *str)
|
||||
sec->size = fdd_sector_size_code(sec->size);
|
||||
|
||||
/* Set up the rest of the Sector ID. */
|
||||
sec->track = img->track;
|
||||
sec->side = img->side;
|
||||
sec->track = dev->track;
|
||||
sec->side = dev->side;
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -159,13 +189,13 @@ unexpect(int c, int state, int level)
|
||||
|
||||
|
||||
static int
|
||||
load_image(json_t *img)
|
||||
load_image(json_t *dev)
|
||||
{
|
||||
char buff[4096], name[32];
|
||||
int c, i, j, state, level;
|
||||
char *ptr;
|
||||
|
||||
if (img->f == NULL) {
|
||||
if (dev->f == NULL) {
|
||||
pclog("JSON: no file loaded!\n");
|
||||
return(0);
|
||||
}
|
||||
@@ -173,17 +203,17 @@ load_image(json_t *img)
|
||||
/* Initialize. */
|
||||
for (i=0; i<NTRACKS; i++) {
|
||||
for (j=0; j<NSIDES; j++)
|
||||
memset(img->sects[i][j], 0x00, sizeof(sector_t));
|
||||
memset(dev->sects[i][j], 0x00, sizeof(sector_t));
|
||||
}
|
||||
img->track = img->side = img->dmf = 0; /* "dmf" is "sector#" */
|
||||
dev->track = dev->side = dev->dmf = 0; /* "dmf" is "sector#" */
|
||||
|
||||
/* Now run the state machine. */
|
||||
ptr = NULL;
|
||||
level = state = 0;
|
||||
while (state >= 0) {
|
||||
/* Get a character from the input. */
|
||||
c = fgetc(img->f);
|
||||
if ((c == EOF) || ferror(img->f)) {
|
||||
c = fgetc(dev->f);
|
||||
if ((c == EOF) || ferror(dev->f)) {
|
||||
state = -1;
|
||||
break;
|
||||
}
|
||||
@@ -191,7 +221,7 @@ load_image(json_t *img)
|
||||
/* Process it. */
|
||||
switch(state) {
|
||||
case 0: /* read level header */
|
||||
img->dmf = 1;
|
||||
dev->dmf = 1;
|
||||
if (c != '[') {
|
||||
state = unexpect(c, state, level);
|
||||
} else {
|
||||
@@ -239,7 +269,7 @@ load_image(json_t *img)
|
||||
case ',':
|
||||
case '}':
|
||||
*ptr = '\0';
|
||||
handle(img, name, buff);
|
||||
handle(dev, name, buff);
|
||||
|
||||
if (c == '}')
|
||||
state = 7; /* done */
|
||||
@@ -264,10 +294,10 @@ load_image(json_t *img)
|
||||
break;
|
||||
|
||||
case 7: /* sector done */
|
||||
handle(img, NULL, NULL);
|
||||
handle(dev, NULL, NULL);
|
||||
switch(c) {
|
||||
case ',': /* next sector */
|
||||
img->dmf++;
|
||||
dev->dmf++;
|
||||
state = 1;
|
||||
break;
|
||||
|
||||
@@ -297,14 +327,14 @@ load_image(json_t *img)
|
||||
default:
|
||||
state = unexpect(c, state, level);
|
||||
}
|
||||
img->spt[img->track][img->side] = img->dmf;
|
||||
img->side++;
|
||||
dev->spt[dev->track][dev->side] = dev->dmf;
|
||||
dev->side++;
|
||||
break;
|
||||
|
||||
case 9: /* track done */
|
||||
switch(c) {
|
||||
case ',': /* next track */
|
||||
img->side = 0;
|
||||
dev->side = 0;
|
||||
state = 0;
|
||||
break;
|
||||
|
||||
@@ -317,15 +347,15 @@ load_image(json_t *img)
|
||||
default:
|
||||
state = unexpect(c, state, level);
|
||||
}
|
||||
img->track++;
|
||||
dev->track++;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Save derived values. */
|
||||
img->tracks = img->track;
|
||||
img->sides = img->side;
|
||||
dev->tracks = dev->track;
|
||||
dev->sides = dev->side;
|
||||
|
||||
return(1);
|
||||
}
|
||||
@@ -336,69 +366,71 @@ static void
|
||||
json_seek(int drive, int track)
|
||||
{
|
||||
uint8_t id[4] = { 0,0,0,0 };
|
||||
json_t *img = &images[drive];
|
||||
json_t *dev = images[drive];
|
||||
int side, sector;
|
||||
int rate, gap2, gap3, pos;
|
||||
int ssize, rsec, asec;
|
||||
int interleave_type;
|
||||
|
||||
if (img->f == NULL) {
|
||||
if (dev->f == NULL) {
|
||||
pclog("JSON: seek: no file loaded!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Allow for doublestepping tracks. */
|
||||
if (! img->track_width && fdd_doublestep_40(drive)) track /= 2;
|
||||
if (! dev->track_width && fdd_doublestep_40(drive)) track /= 2;
|
||||
|
||||
/* Set the new track. */
|
||||
img->track = track;
|
||||
dev->track = track;
|
||||
d86f_set_cur_track(drive, track);
|
||||
|
||||
/* Reset the 86F state machine. */
|
||||
d86f_reset_index_hole_pos(drive, 0);
|
||||
d86f_reset_index_hole_pos(drive, 1);
|
||||
d86f_destroy_linked_lists(drive, 0);
|
||||
d86f_reset_index_hole_pos(drive, 1);
|
||||
d86f_destroy_linked_lists(drive, 1);
|
||||
|
||||
interleave_type = 0;
|
||||
|
||||
if (track > img->tracks) {
|
||||
if (track > dev->tracks) {
|
||||
d86f_zero_track(drive);
|
||||
return;
|
||||
}
|
||||
|
||||
for (side=0; side<img->sides; side++) {
|
||||
for (side=0; side<dev->sides; side++) {
|
||||
/* Get transfer rate for this side. */
|
||||
rate = img->track_flags & 0x07;
|
||||
if (!rate && (img->track_flags & 0x20)) rate = 4;
|
||||
rate = dev->track_flags & 0x07;
|
||||
if (!rate && (dev->track_flags & 0x20)) rate = 4;
|
||||
|
||||
/* Get correct GAP3 value for this side. */
|
||||
gap3 = fdd_get_gap3_size(rate,
|
||||
img->sects[track][side][0].size,
|
||||
img->spt[track][side]);
|
||||
dev->sects[track][side][0].size,
|
||||
dev->spt[track][side]);
|
||||
|
||||
/* Get correct GAP2 value for this side. */
|
||||
gap2 = ((img->track_flags & 0x07) >= 3) ? 41 : 22;
|
||||
gap2 = ((dev->track_flags & 0x07) >= 3) ? 41 : 22;
|
||||
|
||||
pos = d86f_prepare_pretrack(drive, side, 0);
|
||||
|
||||
for (sector=0; sector<img->spt[track][side]; sector++) {
|
||||
for (sector=0; sector<dev->spt[track][side]; sector++) {
|
||||
if (interleave_type == 0) {
|
||||
rsec = img->sects[track][side][sector].sector;
|
||||
rsec = dev->sects[track][side][sector].sector;
|
||||
asec = sector;
|
||||
} else {
|
||||
rsec = fdd_dmf_r[sector];
|
||||
asec = img->interleave_ordered[rsec][side];
|
||||
asec = dev->interleave_ordered[rsec][side];
|
||||
}
|
||||
id[0] = track;
|
||||
id[1] = side;
|
||||
id[2] = rsec;
|
||||
id[3] = img->sects[track][side][asec].size;
|
||||
ssize = fdd_sector_code_size(img->sects[track][side][asec].size);
|
||||
if (dev->sects[track][side][asec].size > 255)
|
||||
perror("fdd_json.c: json_seek: sector size too big.");
|
||||
id[3] = dev->sects[track][side][asec].size & 0xff;
|
||||
ssize = fdd_sector_code_size(dev->sects[track][side][asec].size & 0xff);
|
||||
|
||||
pos = d86f_prepare_sector(
|
||||
drive, side, pos, id,
|
||||
img->sects[track][side][asec].data,
|
||||
dev->sects[track][side][asec].data,
|
||||
ssize, gap2, gap3,
|
||||
0, /*deleted flag*/
|
||||
0 /*bad_crc flag*/
|
||||
@@ -414,38 +446,42 @@ json_seek(int drive, int track)
|
||||
static uint16_t
|
||||
disk_flags(int drive)
|
||||
{
|
||||
return(images[drive].disk_flags);
|
||||
json_t *dev = images[drive];
|
||||
|
||||
return(dev->disk_flags);
|
||||
}
|
||||
|
||||
|
||||
static uint16_t
|
||||
track_flags(int drive)
|
||||
{
|
||||
return(images[drive].track_flags);
|
||||
json_t *dev = images[drive];
|
||||
|
||||
return(dev->track_flags);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
set_sector(int drive, int side, uint8_t c, uint8_t h, uint8_t r, uint8_t n)
|
||||
{
|
||||
json_t *img = &images[drive];
|
||||
json_t *dev = images[drive];
|
||||
int i;
|
||||
|
||||
img->sector[side] = 0;
|
||||
dev->sector[side] = 0;
|
||||
|
||||
/* Make sure we are on the desired track. */
|
||||
if (c != img->track) return;
|
||||
if (c != dev->track) return;
|
||||
|
||||
/* Set the desired side. */
|
||||
img->side = side;
|
||||
dev->side = side;
|
||||
|
||||
/* Now loop over all sector ID's on this side to find our sector. */
|
||||
for (i=0; i<img->spt[c][side]; i++) {
|
||||
if ((img->sects[img->track][side][i].track == c) &&
|
||||
(img->sects[img->track][side][i].side == h) &&
|
||||
(img->sects[img->track][side][i].sector == r) &&
|
||||
(img->sects[img->track][side][i].size == n)) {
|
||||
img->sector[side] = i;
|
||||
for (i=0; i<dev->spt[c][side]; i++) {
|
||||
if ((dev->sects[dev->track][side][i].track == c) &&
|
||||
(dev->sects[dev->track][side][i].side == h) &&
|
||||
(dev->sects[dev->track][side][i].sector == r) &&
|
||||
(dev->sects[dev->track][side][i].size == n)) {
|
||||
dev->sector[side] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -454,10 +490,10 @@ set_sector(int drive, int side, uint8_t c, uint8_t h, uint8_t r, uint8_t n)
|
||||
static uint8_t
|
||||
poll_read_data(int drive, int side, uint16_t pos)
|
||||
{
|
||||
json_t *img = &images[drive];
|
||||
uint8_t sec = img->sector[side];
|
||||
json_t *dev = images[drive];
|
||||
uint8_t sec = dev->sector[side];
|
||||
|
||||
return(img->sects[img->track][side][sec].data[pos]);
|
||||
return(dev->sects[dev->track][side][sec].data[pos]);
|
||||
}
|
||||
|
||||
|
||||
@@ -471,21 +507,23 @@ json_init(void)
|
||||
void
|
||||
json_load(int drive, wchar_t *fn)
|
||||
{
|
||||
json_t *img = &images[drive];
|
||||
sector_t *sec;
|
||||
double bit_rate;
|
||||
int temp_rate;
|
||||
sector_t *sec;
|
||||
json_t *dev;
|
||||
int i;
|
||||
|
||||
/* Just in case- remove ourselves from 86F. */
|
||||
d86f_unregister(drive);
|
||||
|
||||
/* Zap any old data. */
|
||||
memset(img, 0x00, sizeof(json_t));
|
||||
/* Allocate a drive block. */
|
||||
dev = (json_t *)malloc(sizeof(json_t));
|
||||
memset(dev, 0x00, sizeof(json_t));
|
||||
|
||||
/* Open the image file. */
|
||||
img->f = plat_fopen(fn, L"rb");
|
||||
if (img->f == NULL) {
|
||||
dev->f = plat_fopen(fn, L"rb");
|
||||
if (dev->f == NULL) {
|
||||
free(dev);
|
||||
memset(fn, 0x00, sizeof(wchar_t));
|
||||
return;
|
||||
}
|
||||
@@ -493,66 +531,70 @@ json_load(int drive, wchar_t *fn)
|
||||
/* Our images are always RO. */
|
||||
writeprot[drive] = 1;
|
||||
|
||||
/* Set up the drive unit. */
|
||||
images[drive] = dev;
|
||||
|
||||
/* Load all sectors from the image file. */
|
||||
if (! load_image(img)) {
|
||||
if (! load_image(dev)) {
|
||||
pclog("JSON: failed to initialize\n");
|
||||
(void)fclose(img->f);
|
||||
img->f = NULL;
|
||||
(void)fclose(dev->f);
|
||||
free(dev);
|
||||
images[drive] = NULL;
|
||||
memset(fn, 0x00, sizeof(wchar_t));
|
||||
return;
|
||||
}
|
||||
|
||||
pclog("JSON(%d): %ls (%i tracks, %i sides, %i sectors)\n",
|
||||
drive, fn, img->tracks, img->sides, img->spt[0][0]);
|
||||
drive, fn, dev->tracks, dev->sides, dev->spt[0][0]);
|
||||
|
||||
/*
|
||||
* If the image has more than 43 tracks, then
|
||||
* the tracks are thin (96 tpi).
|
||||
*/
|
||||
img->track_width = (img->tracks > 43) ? 1 : 0;
|
||||
dev->track_width = (dev->tracks > 43) ? 1 : 0;
|
||||
|
||||
/* If the image has 2 sides, mark it as such. */
|
||||
img->disk_flags = 0x00;
|
||||
if (img->sides == 2)
|
||||
img->disk_flags |= 0x08;
|
||||
dev->disk_flags = 0x00;
|
||||
if (dev->sides == 2)
|
||||
dev->disk_flags |= 0x08;
|
||||
|
||||
/* JSON files are always assumed to be MFM-encoded. */
|
||||
img->track_flags = 0x08;
|
||||
dev->track_flags = 0x08;
|
||||
|
||||
img->interleave = 0;
|
||||
dev->interleave = 0;
|
||||
#if 0
|
||||
img->skew = 0;
|
||||
dev->skew = 0;
|
||||
#endif
|
||||
|
||||
temp_rate = 0xff;
|
||||
sec = &img->sects[0][0][0];
|
||||
sec = &dev->sects[0][0][0];
|
||||
for (i=0; i<6; i++) {
|
||||
if (img->spt[0][0] > fdd_max_sectors[sec->size][i]) continue;
|
||||
if (dev->spt[0][0] > fdd_max_sectors[sec->size][i]) continue;
|
||||
|
||||
bit_rate = fdd_bit_rates_300[i];
|
||||
temp_rate = fdd_rates[i];
|
||||
img->disk_flags |= (fdd_holes[i] << 1);
|
||||
dev->disk_flags |= (fdd_holes[i] << 1);
|
||||
|
||||
if ((bit_rate == 500.0) && (img->spt[0][0] == 21) &&
|
||||
(sec->size == 2) && (img->tracks >= 80) &&
|
||||
(img->tracks <= 82) && (img->sides == 2)) {
|
||||
if ((bit_rate == 500.0) && (dev->spt[0][0] == 21) &&
|
||||
(sec->size == 2) && (dev->tracks >= 80) &&
|
||||
(dev->tracks <= 82) && (dev->sides == 2)) {
|
||||
/*
|
||||
* This is a DMF floppy, set the flag so
|
||||
* we know to interleave the sectors.
|
||||
*/
|
||||
img->dmf = 1;
|
||||
dev->dmf = 1;
|
||||
} else {
|
||||
if ((bit_rate == 500.0) && (img->spt[0][0] == 22) &&
|
||||
(sec->size == 2) && (img->tracks >= 80) &&
|
||||
(img->tracks <= 82) && (img->sides == 2)) {
|
||||
if ((bit_rate == 500.0) && (dev->spt[0][0] == 22) &&
|
||||
(sec->size == 2) && (dev->tracks >= 80) &&
|
||||
(dev->tracks <= 82) && (dev->sides == 2)) {
|
||||
/*
|
||||
* This is marked specially because of the
|
||||
* track flag (a RPM slow down is needed).
|
||||
*/
|
||||
img->interleave = 2;
|
||||
dev->interleave = 2;
|
||||
}
|
||||
|
||||
img->dmf = 0;
|
||||
dev->dmf = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -560,41 +602,44 @@ json_load(int drive, wchar_t *fn)
|
||||
|
||||
if (temp_rate == 0xff) {
|
||||
pclog("JSON: invalid image (temp_rate=0xff)\n");
|
||||
(void)fclose(img->f);
|
||||
img->f = NULL;
|
||||
(void)fclose(dev->f);
|
||||
dev->f = NULL;
|
||||
free(dev);
|
||||
images[drive] = NULL;
|
||||
memset(fn, 0x00, sizeof(wchar_t));
|
||||
return;
|
||||
}
|
||||
|
||||
if (img->interleave == 2) {
|
||||
img->interleave = 1;
|
||||
img->disk_flags |= 0x60;
|
||||
if (dev->interleave == 2) {
|
||||
dev->interleave = 1;
|
||||
dev->disk_flags |= 0x60;
|
||||
}
|
||||
|
||||
img->gap2_len = (temp_rate == 3) ? 41 : 22;
|
||||
if (img->dmf) {
|
||||
img->gap3_len = 8;
|
||||
} else {
|
||||
img->gap3_len = fdd_get_gap3_size(temp_rate,sec->size,img->spt[0][0]);
|
||||
}
|
||||
dev->gap2_len = (temp_rate == 3) ? 41 : 22;
|
||||
if (dev->dmf)
|
||||
dev->gap3_len = 8;
|
||||
else
|
||||
dev->gap3_len = fdd_get_gap3_size(temp_rate,sec->size,dev->spt[0][0]);
|
||||
|
||||
if (! img->gap3_len) {
|
||||
if (! dev->gap3_len) {
|
||||
pclog("JSON: image of unknown format was inserted into drive %c:!\n",
|
||||
'C'+drive);
|
||||
(void)fclose(img->f);
|
||||
img->f = NULL;
|
||||
(void)fclose(dev->f);
|
||||
dev->f = NULL;
|
||||
free(dev);
|
||||
images[drive] = NULL;
|
||||
memset(fn, 0x00, sizeof(wchar_t));
|
||||
return;
|
||||
}
|
||||
|
||||
img->track_flags |= (temp_rate & 0x03); /* data rate */
|
||||
dev->track_flags |= (temp_rate & 0x03); /* data rate */
|
||||
if (temp_rate & 0x04)
|
||||
img->track_flags |= 0x20; /* RPM */
|
||||
dev->track_flags |= 0x20; /* RPM */
|
||||
|
||||
pclog(" disk_flags: 0x%02x, track_flags: 0x%02x, GAP3 length: %i\n",
|
||||
img->disk_flags, img->track_flags, img->gap3_len);
|
||||
dev->disk_flags, dev->track_flags, dev->gap3_len);
|
||||
pclog(" bit rate 300: %.2f, temporary rate: %i, hole: %i, DMF: %i\n",
|
||||
bit_rate, temp_rate, (img->disk_flags >> 1), img->dmf);
|
||||
bit_rate, temp_rate, (dev->disk_flags >> 1), dev->dmf);
|
||||
|
||||
/* Set up handlers for 86F layer. */
|
||||
d86f_handler[drive].disk_flags = disk_flags;
|
||||
@@ -622,26 +667,30 @@ json_load(int drive, wchar_t *fn)
|
||||
void
|
||||
json_close(int drive)
|
||||
{
|
||||
json_t *img = &images[drive];
|
||||
json_t *dev = images[drive];
|
||||
int t, h, s;
|
||||
|
||||
if (dev == NULL) return;
|
||||
|
||||
/* Unlink image from the system. */
|
||||
d86f_unregister(drive);
|
||||
|
||||
/* Release all the sector buffers. */
|
||||
for (t=0; t<256; t++) {
|
||||
for (h=0; h<2; h++) {
|
||||
memset(img->sects[t][h], 0x00, sizeof(sector_t));
|
||||
memset(dev->sects[t][h], 0x00, sizeof(sector_t));
|
||||
for (s=0; s<256; s++) {
|
||||
if (img->sects[t][h][s].data != NULL)
|
||||
free(img->sects[t][h][s].data);
|
||||
img->sects[t][h][s].data = NULL;
|
||||
if (dev->sects[t][h][s].data != NULL)
|
||||
free(dev->sects[t][h][s].data);
|
||||
dev->sects[t][h][s].data = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (img->f != NULL) {
|
||||
(void)fclose(img->f);
|
||||
img->f = NULL;
|
||||
}
|
||||
if (dev->f != NULL)
|
||||
(void)fclose(dev->f);
|
||||
|
||||
/* Release the memory. */
|
||||
free(dev);
|
||||
images[drive] = NULL;
|
||||
}
|
||||
|
||||
@@ -1,26 +1,56 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the PCjs JSON floppy image format.
|
||||
* Definitions for the PCjs JSON floppy image format.
|
||||
*
|
||||
* Version: @(#)floppy_json.h 1.0.1 2017/09/06
|
||||
* Version: @(#)floppy_json.h 1.0.2 2018/03/17
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Copyright 2017 Fred N. van Kempen.
|
||||
*
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with
|
||||
* or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the entire
|
||||
* above notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names
|
||||
* of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific
|
||||
* prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef EMU_FLOPPY_JSON_H
|
||||
# define EMU_FLOPPY_JSON_H
|
||||
|
||||
|
||||
//extern void json_init(void);
|
||||
extern void json_init(void);
|
||||
extern void json_load(int drive, wchar_t *fn);
|
||||
extern void json_close(int drive);
|
||||
//extern void json_seek(int drive, int track);
|
||||
|
||||
|
||||
#endif /*EMU_FLOPPY_JSON_H*/
|
||||
|
||||
2088
src/floppy/fdd_td0.c
2088
src/floppy/fdd_td0.c
File diff suppressed because it is too large
Load Diff
@@ -1,25 +1,38 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the Teledisk floppy image format.
|
||||
* Definitions for the Teledisk floppy image format.
|
||||
*
|
||||
* Version: @(#)floppy_td0.h 1.0.2 2017/09/03
|
||||
* Version: @(#)floppy_td0.h 1.0.2 2018/03/17
|
||||
*
|
||||
* Authors: Milodrag Milanovic,
|
||||
* Haruhiko OKUMURA,
|
||||
* Haruyasu YOSHIZAKI,
|
||||
* Kenji RIKITAKE,
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Copyright 1988-2017 Haruhiko OKUMURA.
|
||||
* Copyright 1988-2017 Haruyasu YOSHIZAKI.
|
||||
* Copyright 1988-2017 Kenji RIKITAKE.
|
||||
* Copyright 2013-2017 Milodrag Milanovic.
|
||||
* Copyright 2016,2017 Miran Grca.
|
||||
*
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#ifndef EMU_FLOPPY_TD0_H
|
||||
# define EMU_FLOPPY_TD0_H
|
||||
@@ -28,7 +41,6 @@
|
||||
extern void td0_init(void);
|
||||
extern void td0_load(int drive, wchar_t *fn);
|
||||
extern void td0_close(int drive);
|
||||
extern void td0_seek(int drive, int track);
|
||||
|
||||
|
||||
#endif /*EMU_FLOPPY_TD0_H*/
|
||||
|
||||
@@ -1,22 +1,45 @@
|
||||
/* Copyright holders: Toni Wilen
|
||||
see COPYING for more details
|
||||
*/
|
||||
/*
|
||||
|
||||
FDI to raw bit stream converter
|
||||
Copyright (c) 2001 by Toni Wilen <twilen@arabuusimiehet.com>
|
||||
FDI 2.0 support
|
||||
Copyright (c) 2003-2004 by Toni Wilen <twilen@arabuusimiehet.com>
|
||||
and Vincent Joguin
|
||||
|
||||
FDI format created by Vincent "ApH" Joguin
|
||||
|
||||
Tiny changes - function type fixes, multiple drives, addition of
|
||||
get_last_head and C++ callability - by Thomas Harte, 2001,
|
||||
T.Harte@excite.co.uk
|
||||
|
||||
*/
|
||||
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* FDI to raw bit stream converter
|
||||
* FDI format created by Vincent "ApH" Joguin
|
||||
* Tiny changes - function type fixes, multiple drives,
|
||||
* addition of get_last_head and C++ callability by Thomas
|
||||
* Harte.
|
||||
*
|
||||
* Version: @(#)fdi2raw.c 1.0.2 2018/03/12
|
||||
*
|
||||
* Authors: Toni Wilen, <twilen@arabuusimiehet.com>
|
||||
* and Vincent Joguin,
|
||||
* Thomas Harte, <T.Harte@excite.co.uk>
|
||||
*
|
||||
* Copyright 2001-2004 Toni Wilen.
|
||||
* Copyright 2001-2004 Vincent Joguin.
|
||||
* Copyright 2001 Thomas Harte.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#define STATIC_INLINE
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -1857,7 +1880,7 @@ static int decode_lowlevel_track (FDI *fdi, int track, struct fdi_cache *cache)
|
||||
indexoffset = 0;
|
||||
p1 = idxp;
|
||||
for (i = 0; i < pulses; i++) {
|
||||
if (p1[idx_off1] + p1[idx_off2] > maxidx)
|
||||
if ((uint32_t)p1[idx_off1] + (uint32_t)p1[idx_off2] > maxidx)
|
||||
maxidx = p1[idx_off1] + p1[idx_off2];
|
||||
p1 += idx_off3;
|
||||
}
|
||||
@@ -1893,7 +1916,7 @@ static int decode_lowlevel_track (FDI *fdi, int track, struct fdi_cache *cache)
|
||||
totalavg = 0;
|
||||
weakbits = 0;
|
||||
for (i = 0; i < pulses; i++) {
|
||||
int sum = p1[idx_off1] + p1[idx_off2];
|
||||
uint32_t sum = p1[idx_off1] + p1[idx_off2];
|
||||
if (sum >= maxidx) {
|
||||
totalavg += *p2;
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,41 @@
|
||||
/* Copyright holders: Toni Wilen
|
||||
see COPYING for more details
|
||||
*/
|
||||
/*
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Definitions for the FDI floppy file format.
|
||||
*
|
||||
* Version: @(#)fdi2raw.h 1.0.1 2018/02/14
|
||||
*
|
||||
* Authors: Toni Wilen, <twilen@arabuusimiehet.com>
|
||||
* and Vincent Joguin,
|
||||
* Thomas Harte, <T.Harte@excite.co.uk>
|
||||
*
|
||||
* Copyright 2001-2004 Toni Wilen.
|
||||
* Copyright 2001-2004 Vincent Joguin.
|
||||
* Copyright 2001 Thomas Harte.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#ifndef __FDI2RAW_H
|
||||
#define __FDI2RAW_H
|
||||
|
||||
|
||||
@@ -1,6 +1,39 @@
|
||||
/* Copyright holders: Sarah Walker
|
||||
see COPYING for more details
|
||||
*/
|
||||
/*
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of a generic Game Port.
|
||||
*
|
||||
* Version: @(#)gameport.c 1.0.4 2018/03/19
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
@@ -17,261 +50,286 @@
|
||||
#include "joystick_standard.h"
|
||||
#include "joystick_sw_pad.h"
|
||||
#include "joystick_tm_fcs.h"
|
||||
#include "../plat_joystick.h"
|
||||
|
||||
|
||||
int joystick_type;
|
||||
typedef struct {
|
||||
int64_t count;
|
||||
int axis_nr;
|
||||
struct _gameport_ *gameport;
|
||||
} g_axis_t;
|
||||
|
||||
typedef struct _gameport_ {
|
||||
uint8_t state;
|
||||
|
||||
joystick_if_t joystick_none =
|
||||
{
|
||||
"No joystick",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
g_axis_t axis[4];
|
||||
|
||||
static joystick_if_t *joystick_list[] =
|
||||
{
|
||||
&joystick_standard,
|
||||
&joystick_standard_4button,
|
||||
&joystick_standard_6button,
|
||||
&joystick_standard_8button,
|
||||
&joystick_ch_flightstick_pro,
|
||||
&joystick_sw_pad,
|
||||
&joystick_tm_fcs,
|
||||
&joystick_none,
|
||||
NULL
|
||||
};
|
||||
|
||||
char *joystick_get_name(int64_t joystick)
|
||||
{
|
||||
if (!joystick_list[joystick])
|
||||
return NULL;
|
||||
return (char *) joystick_list[joystick]->name;
|
||||
}
|
||||
|
||||
int64_t joystick_get_max_joysticks(int64_t joystick)
|
||||
{
|
||||
return joystick_list[joystick]->max_joysticks;
|
||||
}
|
||||
|
||||
int64_t joystick_get_axis_count(int64_t joystick)
|
||||
{
|
||||
return joystick_list[joystick]->axis_count;
|
||||
}
|
||||
|
||||
int64_t joystick_get_button_count(int64_t joystick)
|
||||
{
|
||||
return joystick_list[joystick]->button_count;
|
||||
}
|
||||
|
||||
int64_t joystick_get_pov_count(int64_t joystick)
|
||||
{
|
||||
return joystick_list[joystick]->pov_count;
|
||||
}
|
||||
|
||||
char *joystick_get_axis_name(int64_t joystick, int64_t id)
|
||||
{
|
||||
return (char *) joystick_list[joystick]->axis_names[id];
|
||||
}
|
||||
|
||||
char *joystick_get_button_name(int64_t joystick, int64_t id)
|
||||
{
|
||||
return (char *) joystick_list[joystick]->button_names[id];
|
||||
}
|
||||
|
||||
char *joystick_get_pov_name(int64_t joystick, int64_t id)
|
||||
{
|
||||
return (char *) joystick_list[joystick]->pov_names[id];
|
||||
}
|
||||
|
||||
typedef struct gameport_axis_t
|
||||
{
|
||||
int64_t count;
|
||||
int64_t axis_nr;
|
||||
struct gameport_t *gameport;
|
||||
} gameport_axis_t;
|
||||
|
||||
typedef struct gameport_t
|
||||
{
|
||||
uint8_t state;
|
||||
|
||||
gameport_axis_t axis[4];
|
||||
|
||||
joystick_if_t *joystick;
|
||||
void *joystick_dat;
|
||||
const joystick_if_t *joystick;
|
||||
void *joystick_dat;
|
||||
} gameport_t;
|
||||
|
||||
|
||||
int joystick_type;
|
||||
|
||||
|
||||
static const joystick_if_t joystick_none = {
|
||||
"No joystick",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
static const joystick_if_t *joystick_list[] = {
|
||||
&joystick_standard,
|
||||
&joystick_standard_4button,
|
||||
&joystick_standard_6button,
|
||||
&joystick_standard_8button,
|
||||
&joystick_ch_flightstick_pro,
|
||||
&joystick_sw_pad,
|
||||
&joystick_tm_fcs,
|
||||
&joystick_none,
|
||||
NULL
|
||||
};
|
||||
static gameport_t *gameport_global = NULL;
|
||||
|
||||
static int64_t gameport_time(int64_t axis)
|
||||
{
|
||||
if (axis == AXIS_NOT_PRESENT)
|
||||
return 0;
|
||||
|
||||
axis += 32768;
|
||||
axis = (axis * 100) / 65; /*Axis now in ohms*/
|
||||
axis = (axis * 11) / 1000;
|
||||
return TIMER_USEC * (axis + 24); /*max = 11.115 ms*/
|
||||
char *
|
||||
joystick_get_name(int js)
|
||||
{
|
||||
if (! joystick_list[js])
|
||||
return(NULL);
|
||||
return((char *)joystick_list[js]->name);
|
||||
}
|
||||
|
||||
void gameport_write(uint16_t addr, uint8_t val, void *p)
|
||||
|
||||
int
|
||||
joystick_get_max_joysticks(int js)
|
||||
{
|
||||
gameport_t *gameport = (gameport_t *)p;
|
||||
|
||||
timer_clock();
|
||||
gameport->state |= 0x0f;
|
||||
pclog("gameport_write : joysticks_present=%i\n", joysticks_present);
|
||||
|
||||
gameport->axis[0].count = gameport_time(gameport->joystick->read_axis(gameport->joystick_dat, 0));
|
||||
gameport->axis[1].count = gameport_time(gameport->joystick->read_axis(gameport->joystick_dat, 1));
|
||||
gameport->axis[2].count = gameport_time(gameport->joystick->read_axis(gameport->joystick_dat, 2));
|
||||
gameport->axis[3].count = gameport_time(gameport->joystick->read_axis(gameport->joystick_dat, 3));
|
||||
|
||||
gameport->joystick->write(gameport->joystick_dat);
|
||||
|
||||
cycles -= ISA_CYCLES(8);
|
||||
return(joystick_list[js]->max_joysticks);
|
||||
}
|
||||
|
||||
uint8_t gameport_read(uint16_t addr, void *p)
|
||||
|
||||
int
|
||||
joystick_get_axis_count(int js)
|
||||
{
|
||||
gameport_t *gameport = (gameport_t *)p;
|
||||
uint8_t ret;
|
||||
|
||||
timer_clock();
|
||||
ret = gameport->state | gameport->joystick->read(gameport->joystick_dat);
|
||||
|
||||
cycles -= ISA_CYCLES(8);
|
||||
|
||||
return ret;
|
||||
return(joystick_list[js]->axis_count);
|
||||
}
|
||||
|
||||
void gameport_timer_over(void *p)
|
||||
|
||||
int
|
||||
joystick_get_button_count(int js)
|
||||
{
|
||||
gameport_axis_t *axis = (gameport_axis_t *)p;
|
||||
gameport_t *gameport = axis->gameport;
|
||||
|
||||
gameport->state &= ~(1 << axis->axis_nr);
|
||||
axis->count = 0;
|
||||
|
||||
if (axis == &gameport->axis[0])
|
||||
gameport->joystick->a0_over(gameport->joystick_dat);
|
||||
return(joystick_list[js]->button_count);
|
||||
}
|
||||
|
||||
void *gameport_init_common(void)
|
||||
{
|
||||
gameport_t *gameport = malloc(sizeof(gameport_t));
|
||||
|
||||
memset(gameport, 0, sizeof(gameport_t));
|
||||
|
||||
gameport->axis[0].gameport = gameport;
|
||||
gameport->axis[1].gameport = gameport;
|
||||
gameport->axis[2].gameport = gameport;
|
||||
gameport->axis[3].gameport = gameport;
|
||||
|
||||
gameport->axis[0].axis_nr = 0;
|
||||
gameport->axis[1].axis_nr = 1;
|
||||
gameport->axis[2].axis_nr = 2;
|
||||
gameport->axis[3].axis_nr = 3;
|
||||
|
||||
timer_add(gameport_timer_over, &gameport->axis[0].count, &gameport->axis[0].count, &gameport->axis[0]);
|
||||
timer_add(gameport_timer_over, &gameport->axis[1].count, &gameport->axis[1].count, &gameport->axis[1]);
|
||||
timer_add(gameport_timer_over, &gameport->axis[2].count, &gameport->axis[2].count, &gameport->axis[2]);
|
||||
timer_add(gameport_timer_over, &gameport->axis[3].count, &gameport->axis[3].count, &gameport->axis[3]);
|
||||
|
||||
gameport->joystick = joystick_list[joystick_type];
|
||||
gameport->joystick_dat = gameport->joystick->init();
|
||||
|
||||
gameport_global = gameport;
|
||||
|
||||
return gameport;
|
||||
int
|
||||
joystick_get_pov_count(int js)
|
||||
{
|
||||
return(joystick_list[js]->pov_count);
|
||||
}
|
||||
|
||||
void gameport_update_joystick_type(void)
|
||||
|
||||
char *
|
||||
joystick_get_axis_name(int js, int id)
|
||||
{
|
||||
gameport_t *gameport = gameport_global;
|
||||
|
||||
if (gameport)
|
||||
{
|
||||
gameport->joystick->close(gameport->joystick_dat);
|
||||
gameport->joystick = joystick_list[joystick_type];
|
||||
gameport->joystick_dat = gameport->joystick->init();
|
||||
}
|
||||
return((char *)joystick_list[js]->axis_names[id]);
|
||||
}
|
||||
|
||||
void *gameport_init(device_t *info)
|
||||
|
||||
char *
|
||||
joystick_get_button_name(int js, int id)
|
||||
{
|
||||
gameport_t *gameport = NULL;
|
||||
|
||||
if (joystick_type == 7)
|
||||
{
|
||||
gameport = NULL;
|
||||
return gameport;
|
||||
}
|
||||
|
||||
gameport = gameport_init_common();
|
||||
|
||||
io_sethandler(0x0200, 0x0008, gameport_read, NULL, NULL, gameport_write, NULL, NULL, gameport);
|
||||
|
||||
return gameport;
|
||||
return((char *)joystick_list[js]->button_names[id]);
|
||||
}
|
||||
|
||||
void *gameport_201_init(device_t *info)
|
||||
|
||||
char *
|
||||
joystick_get_pov_name(int js, int id)
|
||||
{
|
||||
gameport_t *gameport;
|
||||
|
||||
if (joystick_type == 7)
|
||||
{
|
||||
gameport = NULL;
|
||||
return gameport;
|
||||
}
|
||||
|
||||
gameport = gameport_init_common();
|
||||
|
||||
io_sethandler(0x0201, 0x0001, gameport_read, NULL, NULL, gameport_write, NULL, NULL, gameport);
|
||||
|
||||
return gameport;
|
||||
return (char *)joystick_list[js]->pov_names[id];
|
||||
}
|
||||
|
||||
void gameport_close(void *p)
|
||||
|
||||
static int
|
||||
gameport_time(int axis)
|
||||
{
|
||||
gameport_t *gameport = (gameport_t *)p;
|
||||
if (axis == AXIS_NOT_PRESENT) return(0);
|
||||
|
||||
if (!p)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
gameport->joystick->close(gameport->joystick_dat);
|
||||
axis += 32768;
|
||||
axis = (axis * 100) / 65; /*Axis now in ohms*/
|
||||
axis = (axis * 11) / 1000;
|
||||
|
||||
gameport_global = NULL;
|
||||
|
||||
free(gameport);
|
||||
return(TIMER_USEC * (axis + 24)); /*max = 11.115 ms*/
|
||||
}
|
||||
|
||||
device_t gameport_device =
|
||||
|
||||
static void
|
||||
gameport_write(uint16_t addr, uint8_t val, void *priv)
|
||||
{
|
||||
"Game port",
|
||||
0, 0,
|
||||
gameport_init,
|
||||
gameport_close,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL
|
||||
gameport_t *p = (gameport_t *)priv;
|
||||
|
||||
timer_clock();
|
||||
p->state |= 0x0f;
|
||||
pclog("gameport_write : joysticks_present=%i\n", joysticks_present);
|
||||
|
||||
p->axis[0].count = gameport_time(p->joystick->read_axis(p->joystick_dat, 0));
|
||||
p->axis[1].count = gameport_time(p->joystick->read_axis(p->joystick_dat, 1));
|
||||
p->axis[2].count = gameport_time(p->joystick->read_axis(p->joystick_dat, 2));
|
||||
p->axis[3].count = gameport_time(p->joystick->read_axis(p->joystick_dat, 3));
|
||||
|
||||
p->joystick->write(p->joystick_dat);
|
||||
|
||||
cycles -= ISA_CYCLES(8);
|
||||
}
|
||||
|
||||
|
||||
static uint8_t
|
||||
gameport_read(uint16_t addr, void *priv)
|
||||
{
|
||||
gameport_t *p = (gameport_t *)priv;
|
||||
uint8_t ret;
|
||||
|
||||
timer_clock();
|
||||
ret = p->state | p->joystick->read(p->joystick_dat);
|
||||
|
||||
cycles -= ISA_CYCLES(8);
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
timer_over(void *priv)
|
||||
{
|
||||
g_axis_t *axis = (g_axis_t *)priv;
|
||||
gameport_t *p = axis->gameport;
|
||||
|
||||
p->state &= ~(1 << axis->axis_nr);
|
||||
axis->count = 0;
|
||||
|
||||
if (axis == &p->axis[0])
|
||||
p->joystick->a0_over(p->joystick_dat);
|
||||
}
|
||||
|
||||
|
||||
static void *
|
||||
init_common(void)
|
||||
{
|
||||
gameport_t *p = malloc(sizeof(gameport_t));
|
||||
|
||||
memset(p, 0x00, sizeof(gameport_t));
|
||||
|
||||
p->axis[0].gameport = p;
|
||||
p->axis[1].gameport = p;
|
||||
p->axis[2].gameport = p;
|
||||
p->axis[3].gameport = p;
|
||||
|
||||
p->axis[0].axis_nr = 0;
|
||||
p->axis[1].axis_nr = 1;
|
||||
p->axis[2].axis_nr = 2;
|
||||
p->axis[3].axis_nr = 3;
|
||||
|
||||
timer_add(timer_over, &p->axis[0].count, &p->axis[0].count, &p->axis[0]);
|
||||
timer_add(timer_over, &p->axis[1].count, &p->axis[1].count, &p->axis[1]);
|
||||
timer_add(timer_over, &p->axis[2].count, &p->axis[2].count, &p->axis[2]);
|
||||
timer_add(timer_over, &p->axis[3].count, &p->axis[3].count, &p->axis[3]);
|
||||
|
||||
p->joystick = joystick_list[joystick_type];
|
||||
p->joystick_dat = p->joystick->init();
|
||||
|
||||
gameport_global = p;
|
||||
|
||||
return(p);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gameport_update_joystick_type(void)
|
||||
{
|
||||
gameport_t *p = gameport_global;
|
||||
|
||||
if (p != NULL) {
|
||||
p->joystick->close(p->joystick_dat);
|
||||
p->joystick = joystick_list[joystick_type];
|
||||
p->joystick_dat = p->joystick->init();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void *
|
||||
gameport_init(const device_t *info)
|
||||
{
|
||||
gameport_t *p = NULL;
|
||||
|
||||
if (joystick_type == 7) {
|
||||
p = NULL;
|
||||
return(p);
|
||||
}
|
||||
|
||||
p = init_common();
|
||||
|
||||
io_sethandler(0x0200, 8,
|
||||
gameport_read,NULL,NULL, gameport_write,NULL,NULL, p);
|
||||
|
||||
return(p);
|
||||
}
|
||||
|
||||
|
||||
static void *
|
||||
gameport_201_init(const device_t *info)
|
||||
{
|
||||
gameport_t *p;
|
||||
|
||||
if (joystick_type == 7) {
|
||||
p = NULL;
|
||||
return(p);
|
||||
}
|
||||
|
||||
p = init_common();
|
||||
|
||||
io_sethandler(0x0201, 1,
|
||||
gameport_read,NULL,NULL, gameport_write,NULL,NULL, p);
|
||||
|
||||
return(p);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gameport_close(void *priv)
|
||||
{
|
||||
gameport_t *p = (gameport_t *)priv;
|
||||
|
||||
if (p == NULL) return;
|
||||
|
||||
p->joystick->close(p->joystick_dat);
|
||||
|
||||
gameport_global = NULL;
|
||||
|
||||
free(p);
|
||||
}
|
||||
|
||||
|
||||
const device_t gameport_device = {
|
||||
"Game port",
|
||||
0, 0,
|
||||
gameport_init,
|
||||
gameport_close,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
device_t gameport_201_device =
|
||||
{
|
||||
"Game port (port 201h only)",
|
||||
0, 0,
|
||||
gameport_201_init,
|
||||
gameport_close,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL
|
||||
const device_t gameport_201_device = {
|
||||
"Game port (port 201h only)",
|
||||
0, 0,
|
||||
gameport_201_init,
|
||||
gameport_close,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -1,49 +1,142 @@
|
||||
/* Copyright holders: Sarah Walker
|
||||
see COPYING for more details
|
||||
*/
|
||||
/*
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Definitions for the generic game port handlers.
|
||||
*
|
||||
* NOTE: This module needs a good cleanup someday.
|
||||
*
|
||||
* Version: @(#)gameport.h 1.0.3 2018/03/15
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2017 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#ifndef EMU_GAMEPORT_H
|
||||
# define EMU_GAMEPORT_H
|
||||
|
||||
|
||||
#define AXIS_NOT_PRESENT -99999
|
||||
#define MAX_PLAT_JOYSTICKS 8
|
||||
#define MAX_JOYSTICKS 4
|
||||
|
||||
#define POV_X 0x80000000
|
||||
#define POV_Y 0x40000000
|
||||
|
||||
#define AXIS_NOT_PRESENT -99999
|
||||
|
||||
#define JOYSTICK_PRESENT(n) (joystick_state[n].plat_joystick_nr != 0)
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *name;
|
||||
void *(*init)(void);
|
||||
void (*close)(void *p);
|
||||
uint8_t (*read)(void *p);
|
||||
void (*write)(void *p);
|
||||
int (*read_axis)(void *p, int axis);
|
||||
void (*a0_over)(void *p);
|
||||
int axis_count, button_count, pov_count;
|
||||
int max_joysticks;
|
||||
const char *axis_names[8];
|
||||
const char *button_names[32];
|
||||
const char *pov_names[4];
|
||||
typedef struct {
|
||||
char name[64];
|
||||
|
||||
int a[8];
|
||||
int b[32];
|
||||
int p[4];
|
||||
|
||||
struct {
|
||||
char name[32];
|
||||
int id;
|
||||
} axis[8];
|
||||
|
||||
struct {
|
||||
char name[32];
|
||||
int id;
|
||||
} button[32];
|
||||
|
||||
struct {
|
||||
char name[32];
|
||||
int id;
|
||||
} pov[4];
|
||||
|
||||
int nr_axes;
|
||||
int nr_buttons;
|
||||
int nr_povs;
|
||||
} plat_joystick_t;
|
||||
|
||||
typedef struct {
|
||||
int axis[8];
|
||||
int button[32];
|
||||
int pov[4];
|
||||
|
||||
int plat_joystick_nr;
|
||||
int axis_mapping[8];
|
||||
int button_mapping[32];
|
||||
int pov_mapping[4][2];
|
||||
} joystick_t;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
|
||||
void *(*init)(void);
|
||||
void (*close)(void *p);
|
||||
uint8_t (*read)(void *p);
|
||||
void (*write)(void *p);
|
||||
int (*read_axis)(void *p, int axis);
|
||||
void (*a0_over)(void *p);
|
||||
|
||||
int axis_count,
|
||||
button_count,
|
||||
pov_count;
|
||||
int max_joysticks;
|
||||
const char *axis_names[8];
|
||||
const char *button_names[32];
|
||||
const char *pov_names[4];
|
||||
} joystick_if_t;
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern device_t gameport_device;
|
||||
extern device_t gameport_201_device;
|
||||
#ifdef EMU_DEVICE_H
|
||||
extern const device_t gameport_device;
|
||||
extern const device_t gameport_201_device;
|
||||
#endif
|
||||
|
||||
extern int joystick_type;
|
||||
extern plat_joystick_t plat_joystick_state[MAX_PLAT_JOYSTICKS];
|
||||
extern joystick_t joystick_state[MAX_JOYSTICKS];
|
||||
extern int joysticks_present;
|
||||
|
||||
extern int joystick_type;
|
||||
|
||||
|
||||
extern char *joystick_get_name(int64_t joystick);
|
||||
extern int64_t joystick_get_max_joysticks(int64_t joystick);
|
||||
extern int64_t joystick_get_axis_count(int64_t joystick);
|
||||
extern int64_t joystick_get_button_count(int64_t joystick);
|
||||
extern int64_t joystick_get_pov_count(int64_t joystick);
|
||||
extern char *joystick_get_axis_name(int64_t joystick, int64_t id);
|
||||
extern char *joystick_get_button_name(int64_t joystick, int64_t id);
|
||||
extern char *joystick_get_pov_name(int64_t joystick, int64_t id);
|
||||
extern void joystick_init(void);
|
||||
extern void joystick_close(void);
|
||||
extern void joystick_process(void);
|
||||
|
||||
extern char *joystick_get_name(int js);
|
||||
extern int joystick_get_max_joysticks(int js);
|
||||
extern int joystick_get_axis_count(int js);
|
||||
extern int joystick_get_button_count(int js);
|
||||
extern int joystick_get_pov_count(int js);
|
||||
extern char *joystick_get_axis_name(int js, int id);
|
||||
extern char *joystick_get_button_name(int js, int id);
|
||||
extern char *joystick_get_pov_name(int js, int id);
|
||||
|
||||
extern void gameport_update_joystick_type(void);
|
||||
|
||||
|
||||
@@ -1,3 +1,39 @@
|
||||
/*
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the Flight Stick Pro.
|
||||
*
|
||||
* Version: @(#)flightstick_pro.c 1.0.4 2018/03/15
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
@@ -6,12 +42,11 @@
|
||||
#include "../86box.h"
|
||||
#include "../device.h"
|
||||
#include "../timer.h"
|
||||
#include "../plat_joystick.h"
|
||||
#include "gameport.h"
|
||||
#include "joystick_standard.h"
|
||||
|
||||
|
||||
static void *ch_flightstick_pro_init()
|
||||
static void *ch_flightstick_pro_init(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -78,7 +113,7 @@ static void ch_flightstick_pro_a0_over(void *p)
|
||||
{
|
||||
}
|
||||
|
||||
joystick_if_t joystick_ch_flightstick_pro =
|
||||
const joystick_if_t joystick_ch_flightstick_pro =
|
||||
{
|
||||
"CH Flightstick Pro",
|
||||
ch_flightstick_pro_init,
|
||||
|
||||
@@ -1 +1,38 @@
|
||||
extern joystick_if_t joystick_ch_flightstick_pro;
|
||||
/*
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Definitions for the Flight Stick Pro driver.
|
||||
*
|
||||
* Version: @(#)joystick_ch_flightstickpro.h 1.0.2 2018/03/15
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
|
||||
extern const joystick_if_t joystick_ch_flightstick_pro;
|
||||
|
||||
@@ -1,3 +1,39 @@
|
||||
/*
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of a standard joystick.
|
||||
*
|
||||
* Version: @(#)joystick_standard.c 1.0.4 2018/03/15
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
@@ -6,12 +42,11 @@
|
||||
#include "../86box.h"
|
||||
#include "../device.h"
|
||||
#include "../timer.h"
|
||||
#include "../plat_joystick.h"
|
||||
#include "gameport.h"
|
||||
#include "joystick_standard.h"
|
||||
|
||||
|
||||
static void *joystick_standard_init()
|
||||
static void *joystick_standard_init(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -160,7 +195,7 @@ static void joystick_standard_a0_over(void *p)
|
||||
{
|
||||
}
|
||||
|
||||
joystick_if_t joystick_standard =
|
||||
const joystick_if_t joystick_standard =
|
||||
{
|
||||
"Standard 2-button joystick(s)",
|
||||
joystick_standard_init,
|
||||
@@ -176,7 +211,7 @@ joystick_if_t joystick_standard =
|
||||
{"X axis", "Y axis"},
|
||||
{"Button 1", "Button 2"}
|
||||
};
|
||||
joystick_if_t joystick_standard_4button =
|
||||
const joystick_if_t joystick_standard_4button =
|
||||
{
|
||||
"Standard 4-button joystick",
|
||||
joystick_standard_init,
|
||||
@@ -192,7 +227,7 @@ joystick_if_t joystick_standard_4button =
|
||||
{"X axis", "Y axis"},
|
||||
{"Button 1", "Button 2", "Button 3", "Button 4"}
|
||||
};
|
||||
joystick_if_t joystick_standard_6button =
|
||||
const joystick_if_t joystick_standard_6button =
|
||||
{
|
||||
"Standard 6-button joystick",
|
||||
joystick_standard_init,
|
||||
@@ -208,7 +243,7 @@ joystick_if_t joystick_standard_6button =
|
||||
{"X axis", "Y axis"},
|
||||
{"Button 1", "Button 2", "Button 3", "Button 4", "Button 5", "Button 6"}
|
||||
};
|
||||
joystick_if_t joystick_standard_8button =
|
||||
const joystick_if_t joystick_standard_8button =
|
||||
{
|
||||
"Standard 8-button joystick",
|
||||
joystick_standard_init,
|
||||
|
||||
@@ -1,4 +1,41 @@
|
||||
extern joystick_if_t joystick_standard;
|
||||
extern joystick_if_t joystick_standard_4button;
|
||||
extern joystick_if_t joystick_standard_6button;
|
||||
extern joystick_if_t joystick_standard_8button;
|
||||
/*
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Definitions for the joystick driver.
|
||||
*
|
||||
* Version: @(#)joystick_standard.h 1.0.2 2018/03/15
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
|
||||
extern const joystick_if_t joystick_standard;
|
||||
extern const joystick_if_t joystick_standard_4button;
|
||||
extern const joystick_if_t joystick_standard_6button;
|
||||
extern const joystick_if_t joystick_standard_8button;
|
||||
|
||||
@@ -1,24 +1,60 @@
|
||||
/*Sidewinder game pad notes :
|
||||
|
||||
- Write to 0x201 starts packet transfer (5*N or 15*N bits)
|
||||
- Currently alternates between Mode A and Mode B (is there any way of
|
||||
actually controlling which is used?)
|
||||
- Windows 9x drivers require Mode B when more than 1 pad connected
|
||||
- Packet preceeded by high data (currently 50us), and followed by low
|
||||
data (currently 160us) - timings are probably wrong, but good enough
|
||||
for everything I've tried
|
||||
- Analogue inputs are only used to time ID packet request. If A0 timing
|
||||
out is followed after ~64us by another 0x201 write then an ID packet
|
||||
is triggered
|
||||
- Sidewinder game pad ID is 'H0003'
|
||||
- ID is sent in Mode A (1 bit per clock), but data bit 2 must change
|
||||
during ID packet transfer, or Windows 9x drivers won't use Mode B. I
|
||||
don't know if it oscillates, mirrors the data transfer, or something
|
||||
else - the drivers only check that it changes at least 10 times during
|
||||
the transfer
|
||||
- Some DOS stuff will write to 0x201 while a packet is being transferred.
|
||||
This seems to be ignored.
|
||||
*/
|
||||
/*
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of a Side Winder GamePad.
|
||||
*
|
||||
* Notes: - Write to 0x201 starts packet transfer (5*N or 15*N bits)
|
||||
* - Currently alternates between Mode A and Mode B (is there
|
||||
* any way of actually controlling which is used?)
|
||||
* - Windows 9x drivers require Mode B when more than 1 pad
|
||||
* connected
|
||||
* - Packet preceeded by high data (currently 50us), and
|
||||
* followed by low data (currently 160us) - timings are
|
||||
* probably wrong, but good enoughfor everything I've tried
|
||||
* - Analog inputs are only used to time ID packet request.
|
||||
* If A0 timing out is followed after ~64us by another 0x201
|
||||
* write then an ID packet is triggered
|
||||
* - Sidewinder game pad ID is 'H0003'
|
||||
* - ID is sent in Mode A (1 bit per clock), but data bit 2
|
||||
* must change during ID packet transfer, or Windows 9x
|
||||
* drivers won't use Mode B. I don't know if it oscillates,
|
||||
* mirrors the data transfer, or something else - the drivers
|
||||
* only check that it changes at least 10 times during the
|
||||
* transfer
|
||||
* - Some DOS stuff will write to 0x201 while a packet is
|
||||
* being transferred. This seems to be ignored.
|
||||
*
|
||||
* Version: @(#)sw_pad.c 1.0.5 2018/03/15
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
@@ -27,7 +63,6 @@
|
||||
#include "../86box.h"
|
||||
#include "../device.h"
|
||||
#include "../timer.h"
|
||||
#include "../plat_joystick.h"
|
||||
#include "gameport.h"
|
||||
#include "joystick_sw_pad.h"
|
||||
|
||||
@@ -90,7 +125,7 @@ static int sw_parity(uint16_t data)
|
||||
return bits_set & 1;
|
||||
}
|
||||
|
||||
static void *sw_init()
|
||||
static void *sw_init(void)
|
||||
{
|
||||
sw_data *sw = (sw_data *)malloc(sizeof(sw_data));
|
||||
memset(sw, 0, sizeof(sw_data));
|
||||
@@ -139,7 +174,7 @@ static uint8_t sw_read(void *p)
|
||||
static void sw_write(void *p)
|
||||
{
|
||||
sw_data *sw = (sw_data *)p;
|
||||
int time_since_last = sw->trigger_time / TIMER_USEC;
|
||||
int64_t time_since_last = sw->trigger_time / TIMER_USEC;
|
||||
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
return;
|
||||
@@ -177,7 +212,7 @@ static void sw_write(void *p)
|
||||
|
||||
for (c = 0; c < 4; c++)
|
||||
{
|
||||
uint64_t data = 0x3fff;
|
||||
uint16_t data = 0x3fff;
|
||||
int b;
|
||||
|
||||
if (!JOYSTICK_PRESENT(c))
|
||||
@@ -235,7 +270,7 @@ static void sw_a0_over(void *p)
|
||||
sw->trigger_time = TIMER_USEC * 10000;
|
||||
}
|
||||
|
||||
joystick_if_t joystick_sw_pad =
|
||||
const joystick_if_t joystick_sw_pad =
|
||||
{
|
||||
"Microsoft SideWinder Pad",
|
||||
sw_init,
|
||||
|
||||
@@ -1 +1,38 @@
|
||||
extern joystick_if_t joystick_sw_pad;
|
||||
/*
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Definitions for the Sidewinder Pro driver.
|
||||
*
|
||||
* Version: @(#)joystick_sw_pad.h 1.0.2 2018/03/15
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
|
||||
extern const joystick_if_t joystick_sw_pad;
|
||||
|
||||
@@ -1,3 +1,39 @@
|
||||
/*
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of Thrust Master Flight Control System.
|
||||
*
|
||||
* Version: @(#)tm_fcs.c 1.0.3 2018/03/15
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
@@ -6,7 +42,6 @@
|
||||
#include "../86box.h"
|
||||
#include "../device.h"
|
||||
#include "../timer.h"
|
||||
#include "../plat_joystick.h"
|
||||
#include "gameport.h"
|
||||
#include "joystick_standard.h"
|
||||
|
||||
@@ -77,7 +112,7 @@ static void tm_fcs_a0_over(void *p)
|
||||
{
|
||||
}
|
||||
|
||||
joystick_if_t joystick_tm_fcs =
|
||||
const joystick_if_t joystick_tm_fcs =
|
||||
{
|
||||
"Thrustmaster Flight Control System",
|
||||
tm_fcs_init,
|
||||
|
||||
@@ -1 +1,38 @@
|
||||
extern joystick_if_t joystick_tm_fcs;
|
||||
/*
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Definitions for the Flight Control System driver.
|
||||
*
|
||||
* Version: @(#)joystick_tm_fcs.h 1.0.2 2018/03/15
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
|
||||
extern const joystick_if_t joystick_tm_fcs;
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Implementation of the Intel 2 Mbit 8-bit flash devices.
|
||||
* Implementation of the Intel 1 Mbit 8-bit flash devices.
|
||||
*
|
||||
* Version: @(#)intel_flash.c 1.0.13 2018/02/09
|
||||
* Version: @(#)intel_flash.c 1.0.14 2018/03/18
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -288,7 +288,7 @@ void intel_flash_close(void *p)
|
||||
}
|
||||
|
||||
|
||||
device_t intel_flash_bxt_ami_device =
|
||||
const device_t intel_flash_bxt_ami_device =
|
||||
{
|
||||
"Intel 28F001BXT Flash BIOS",
|
||||
0, 0,
|
||||
@@ -298,7 +298,7 @@ device_t intel_flash_bxt_ami_device =
|
||||
NULL, NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
device_t intel_flash_bxb_ami_device =
|
||||
const device_t intel_flash_bxb_ami_device =
|
||||
{
|
||||
"Intel 28F001BXB Flash BIOS",
|
||||
0, 0,
|
||||
@@ -308,7 +308,7 @@ device_t intel_flash_bxb_ami_device =
|
||||
NULL, NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
device_t intel_flash_bxt_device =
|
||||
const device_t intel_flash_bxt_device =
|
||||
{
|
||||
"Intel 28F001BXT Flash BIOS",
|
||||
0, 0,
|
||||
@@ -318,7 +318,7 @@ device_t intel_flash_bxt_device =
|
||||
NULL, NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
device_t intel_flash_bxb_device =
|
||||
const device_t intel_flash_bxb_device =
|
||||
{
|
||||
"Intel 28F001BXB Flash BIOS",
|
||||
0, 0,
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Implementation of the Intel 2 Mbit 8-bit flash devices.
|
||||
* Implementation of the Intel 1 Mbit 8-bit flash devices.
|
||||
*
|
||||
* Version: @(#)intel_flash.h 1.0.0 2017/05/30
|
||||
* Version: @(#)intel_flash.h 1.0.1 2018/03/14
|
||||
*
|
||||
* Author: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -16,7 +16,7 @@
|
||||
* Copyright 2016-2017 Miran Grca.
|
||||
*/
|
||||
|
||||
extern device_t intel_flash_bxt_ami_device;
|
||||
extern device_t intel_flash_bxb_ami_device;
|
||||
extern device_t intel_flash_bxt_device;
|
||||
extern device_t intel_flash_bxb_device;
|
||||
extern const device_t intel_flash_bxt_ami_device;
|
||||
extern const device_t intel_flash_bxb_ami_device;
|
||||
extern const device_t intel_flash_bxt_device;
|
||||
extern const device_t intel_flash_bxb_device;
|
||||
|
||||
@@ -8,15 +8,15 @@
|
||||
*
|
||||
* General keyboard driver interface.
|
||||
*
|
||||
* Version: @(#)keyboard.c 1.0.14 2018/02/10
|
||||
* Version: @(#)keyboard.c 1.0.15 2018/03/19
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2016,2018 Miran Grca.
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
* Copyright 2015-2018 Miran Grca.
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -61,9 +61,9 @@ keyboard_init(void)
|
||||
|
||||
|
||||
void
|
||||
keyboard_set_table(scancode *ptr)
|
||||
keyboard_set_table(const scancode *ptr)
|
||||
{
|
||||
scan_table = ptr;
|
||||
scan_table = (scancode *) ptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,15 +8,15 @@
|
||||
*
|
||||
* Definitions for the keyboard interface.
|
||||
*
|
||||
* Version: @(#)keyboard.h 1.0.11 2018/02/10
|
||||
* Version: @(#)keyboard.h 1.0.14 2018/03/22
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2016,2018 Miran Grca.
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*/
|
||||
#ifndef EMU_KEYBOARD_H
|
||||
# define EMU_KEYBOARD_H
|
||||
@@ -51,7 +51,7 @@ extern int64_t keyboard_delay;
|
||||
extern void (*keyboard_send)(uint16_t val);
|
||||
extern void kbd_adddata_process(uint16_t val, void (*adddata)(uint16_t val));
|
||||
|
||||
extern scancode scancode_xt[512];
|
||||
extern const scancode scancode_xt[512];
|
||||
|
||||
extern uint8_t keyboard_set3_flags[512];
|
||||
extern uint8_t keyboard_set3_all_repeat;
|
||||
@@ -60,20 +60,21 @@ extern int mouse_queue_start, mouse_queue_end;
|
||||
extern int mouse_scan;
|
||||
|
||||
#ifdef EMU_DEVICE_H
|
||||
extern device_t keyboard_xt_device;
|
||||
extern device_t keyboard_tandy_device;
|
||||
extern device_t keyboard_at_device;
|
||||
extern device_t keyboard_at_ami_device;
|
||||
extern device_t keyboard_at_toshiba_device;
|
||||
extern device_t keyboard_ps2_device;
|
||||
extern device_t keyboard_ps2_ami_device;
|
||||
extern device_t keyboard_ps2_mca_device;
|
||||
extern device_t keyboard_ps2_quadtel_device;
|
||||
extern const device_t keyboard_xt_device;
|
||||
extern const device_t keyboard_tandy_device;
|
||||
extern const device_t keyboard_at_device;
|
||||
extern const device_t keyboard_at_ami_device;
|
||||
extern const device_t keyboard_at_toshiba_device;
|
||||
extern const device_t keyboard_ps2_device;
|
||||
extern const device_t keyboard_ps2_ami_device;
|
||||
extern const device_t keyboard_ps2_mca_device;
|
||||
extern const device_t keyboard_ps2_mca_2_device;
|
||||
extern const device_t keyboard_ps2_quadtel_device;
|
||||
#endif
|
||||
|
||||
extern void keyboard_init(void);
|
||||
extern void keyboard_close(void);
|
||||
extern void keyboard_set_table(scancode *ptr);
|
||||
extern void keyboard_set_table(const scancode *ptr);
|
||||
extern void keyboard_poll_host(void);
|
||||
extern void keyboard_process(void);
|
||||
extern uint16_t keyboard_convert(int ch);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Intel 8042 (AT keyboard controller) emulation.
|
||||
*
|
||||
* Version: @(#)keyboard_at.c 1.0.30 2018/03/13
|
||||
* Version: @(#)keyboard_at.c 1.0.33 2018/03/22
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -154,7 +154,7 @@ static atkbd_t *CurrentKbd = NULL; // FIXME: remove!!! --FvK
|
||||
|
||||
|
||||
/* Non-translated to translated scan codes. */
|
||||
static uint8_t nont_to_t[256] = {
|
||||
static const uint8_t nont_to_t[256] = {
|
||||
0xFF, 0x43, 0x41, 0x3F, 0x3D, 0x3B, 0x3C, 0x58,
|
||||
0x64, 0x44, 0x42, 0x40, 0x3E, 0x0F, 0x29, 0x59,
|
||||
0x65, 0x38, 0x2A, 0x70, 0x1D, 0x10, 0x02, 0x5A,
|
||||
@@ -189,7 +189,7 @@ static uint8_t nont_to_t[256] = {
|
||||
0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
|
||||
};
|
||||
|
||||
static scancode scancode_set1[512] = {
|
||||
static const scancode scancode_set1[512] = {
|
||||
{ { -1},{ -1} }, { { 0x01,-1},{ 0x81,-1} }, { { 0x02,-1},{ 0x82,-1} }, { { 0x03,-1},{ 0x83,-1} }, /*000*/
|
||||
{ { 0x04,-1},{ 0x84,-1} }, { { 0x05,-1},{ 0x85,-1} }, { { 0x06,-1},{ 0x86,-1} }, { { 0x07,-1},{ 0x87,-1} }, /*004*/
|
||||
{ { 0x08,-1},{ 0x88,-1} }, { { 0x09,-1},{ 0x89,-1} }, { { 0x0a,-1},{ 0x8a,-1} }, { { 0x0b,-1},{ 0x8b,-1} }, /*008*/
|
||||
@@ -319,7 +319,7 @@ static scancode scancode_set1[512] = {
|
||||
{ { -1},{ -1} }, { { -1},{ -1} }, { {0xe0,0xfe,-1},{ -1} }, { {0xe0,0xff,-1},{ -1} } /*1fc*/
|
||||
};
|
||||
|
||||
static scancode scancode_set2[512] = {
|
||||
static const scancode scancode_set2[512] = {
|
||||
{ { -1},{ -1} }, { { 0x76,-1},{ 0xF0,0x76,-1} }, { { 0x16,-1},{ 0xF0,0x16,-1} }, { { 0x1E,-1},{ 0xF0,0x1E,-1} }, /*000*/
|
||||
{ { 0x26,-1},{ 0xF0,0x26,-1} }, { { 0x25,-1},{ 0xF0,0x25,-1} }, { { 0x2E,-1},{ 0xF0,0x2E,-1} }, { { 0x36,-1},{ 0xF0,0x36,-1} }, /*004*/
|
||||
{ { 0x3D,-1},{ 0xF0,0x3D,-1} }, { { 0x3E,-1},{ 0xF0,0x3E,-1} }, { { 0x46,-1},{ 0xF0,0x46,-1} }, { { 0x45,-1},{ 0xF0,0x45,-1} }, /*008*/
|
||||
@@ -449,7 +449,7 @@ static scancode scancode_set2[512] = {
|
||||
{ { -1},{ -1} }, { { -1},{ -1} }, { {0xe0,0xfe,-1},{0xe0,0xF0,0xFE,-1} }, { {0xe0,0xff,-1},{0xe0,0xF0,0xFF,-1} } /*1fc*/
|
||||
};
|
||||
|
||||
static scancode scancode_set3[512] = {
|
||||
static const scancode scancode_set3[512] = {
|
||||
{ { -1},{ -1} }, { { 0x08,-1},{ 0xf0,0x08,-1} }, { { 0x16,-1},{ 0xf0,0x16,-1} }, { { 0x1E,-1},{ 0xf0,0x1E,-1} }, /*000*/
|
||||
{ { 0x26,-1},{ 0xf0,0x26,-1} }, { { 0x25,-1},{ 0xf0,0x25,-1} }, { { 0x2E,-1},{ 0xf0,0x2E,-1} }, { { 0x36,-1},{ 0xf0,0x36,-1} }, /*004*/
|
||||
{ { 0x3D,-1},{ 0xf0,0x3D,-1} }, { { 0x3E,-1},{ 0xf0,0x3E,-1} }, { { 0x46,-1},{ 0xf0,0x46,-1} }, { { 0x45,-1},{ 0xf0,0x45,-1} }, /*008*/
|
||||
@@ -598,27 +598,23 @@ kbdlog(const char *fmt, ...)
|
||||
static void
|
||||
kbd_setmap(atkbd_t *kbd)
|
||||
{
|
||||
scancode *map = NULL;
|
||||
|
||||
switch (keyboard_mode & 3) {
|
||||
case 1:
|
||||
default:
|
||||
map = scancode_set1;
|
||||
keyboard_set_table(scancode_set1);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
map = scancode_set2;
|
||||
keyboard_set_table(scancode_set2);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
map = scancode_set3;
|
||||
keyboard_set_table(scancode_set3);
|
||||
break;
|
||||
}
|
||||
|
||||
if (keyboard_mode & 0x20)
|
||||
map = scancode_set1;
|
||||
|
||||
keyboard_set_table(map);
|
||||
keyboard_set_table(scancode_set1);
|
||||
}
|
||||
|
||||
|
||||
@@ -981,11 +977,6 @@ kbd_cmd_write(atkbd_t *kbd, uint8_t val)
|
||||
|
||||
kbdlog("ATkbd: mouse interrupt is now %s\n", (val & 0x02) ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Reset scancode map. */
|
||||
kbd_setmap(kbd);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1891,7 +1882,7 @@ kbd_reset(void *priv)
|
||||
|
||||
|
||||
static void *
|
||||
kbd_init(device_t *info)
|
||||
kbd_init(const device_t *info)
|
||||
{
|
||||
atkbd_t *kbd;
|
||||
|
||||
@@ -1909,6 +1900,10 @@ kbd_init(device_t *info)
|
||||
timer_add(kbd_poll, &keyboard_delay, TIMER_ALWAYS_ENABLED, kbd);
|
||||
|
||||
if ((kbd->flags & KBC_TYPE_MASK) != KBC_TYPE_ISA) {
|
||||
if ((kbd->flags & KBC_TYPE_MASK) == KBC_TYPE_PS2_2)
|
||||
keyboard_mode &= ~0x03; /* These machines force translation off, so the keyboard
|
||||
must start in scan code set 0. */
|
||||
|
||||
timer_add(kbd_refresh,
|
||||
&kbd->refresh_time, TIMER_ALWAYS_ENABLED, kbd);
|
||||
}
|
||||
@@ -1969,7 +1964,7 @@ kbd_close(void *priv)
|
||||
}
|
||||
|
||||
|
||||
device_t keyboard_at_device = {
|
||||
const device_t keyboard_at_device = {
|
||||
"PC/AT Keyboard",
|
||||
0,
|
||||
KBC_TYPE_ISA | KBC_VEN_GENERIC,
|
||||
@@ -1979,7 +1974,7 @@ device_t keyboard_at_device = {
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
device_t keyboard_at_ami_device = {
|
||||
const device_t keyboard_at_ami_device = {
|
||||
"PC/AT Keyboard (AMI)",
|
||||
0,
|
||||
KBC_TYPE_ISA | KBC_VEN_AMI,
|
||||
@@ -1989,7 +1984,7 @@ device_t keyboard_at_ami_device = {
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
device_t keyboard_at_toshiba_device = {
|
||||
const device_t keyboard_at_toshiba_device = {
|
||||
"PC/AT Keyboard (Toshiba)",
|
||||
0,
|
||||
KBC_TYPE_ISA | KBC_VEN_TOSHIBA,
|
||||
@@ -1999,7 +1994,7 @@ device_t keyboard_at_toshiba_device = {
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
device_t keyboard_ps2_device = {
|
||||
const device_t keyboard_ps2_device = {
|
||||
"PS/2 Keyboard",
|
||||
0,
|
||||
KBC_TYPE_PS2_1 | KBC_VEN_GENERIC,
|
||||
@@ -2009,7 +2004,7 @@ device_t keyboard_ps2_device = {
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
device_t keyboard_ps2_ami_device = {
|
||||
const device_t keyboard_ps2_ami_device = {
|
||||
"PS/2 Keyboard (AMI)",
|
||||
0,
|
||||
KBC_TYPE_PS2_1 | KBC_VEN_AMI,
|
||||
@@ -2019,7 +2014,7 @@ device_t keyboard_ps2_ami_device = {
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
device_t keyboard_ps2_mca_device = {
|
||||
const device_t keyboard_ps2_mca_device = {
|
||||
"PS/2 Keyboard",
|
||||
0,
|
||||
KBC_TYPE_PS2_1 | KBC_VEN_IBM_MCA,
|
||||
@@ -2029,7 +2024,17 @@ device_t keyboard_ps2_mca_device = {
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
device_t keyboard_ps2_quadtel_device = {
|
||||
const device_t keyboard_ps2_mca_2_device = {
|
||||
"PS/2 Keyboard",
|
||||
0,
|
||||
KBC_TYPE_PS2_2 | KBC_VEN_IBM_MCA,
|
||||
kbd_init,
|
||||
kbd_close,
|
||||
kbd_reset,
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
const device_t keyboard_ps2_quadtel_device = {
|
||||
"PS/2 Keyboard (Quadtel/MegaPC)",
|
||||
0,
|
||||
KBC_TYPE_PS2_1 | KBC_VEN_QUADTEL,
|
||||
|
||||
@@ -8,15 +8,15 @@
|
||||
*
|
||||
* Implementation of the XT-style keyboard.
|
||||
*
|
||||
* Version: @(#)keyboard_xt.c 1.0.9 2018/02/24
|
||||
* Version: @(#)keyboard_xt.c 1.0.11 2018/03/19
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2016,2018 Miran Grca.
|
||||
* Copyright 2018 Fred N. van kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2017,2018 Fred N. van kempen.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -60,7 +60,7 @@ typedef struct {
|
||||
|
||||
|
||||
/*XT keyboard has no escape scancodes, and no scancodes beyond 53*/
|
||||
scancode scancode_xt[512] = {
|
||||
const scancode scancode_xt[512] = {
|
||||
{ {-1}, {-1} }, { {0x01, -1}, {0x81, -1} },
|
||||
{ {0x02, -1}, {0x82, -1} }, { {0x03, -1}, {0x83, -1} },
|
||||
{ {0x04, -1}, {0x84, -1} }, { {0x05, -1}, {0x85, -1} },
|
||||
@@ -530,7 +530,7 @@ kbd_reset(void *priv)
|
||||
|
||||
|
||||
static void *
|
||||
kbd_init(device_t *info)
|
||||
kbd_init(const device_t *info)
|
||||
{
|
||||
xtkbd_t *kbd;
|
||||
|
||||
@@ -574,7 +574,7 @@ kbd_close(void *priv)
|
||||
}
|
||||
|
||||
|
||||
device_t keyboard_xt_device = {
|
||||
const device_t keyboard_xt_device = {
|
||||
"PC/XT Keyboard",
|
||||
0,
|
||||
0,
|
||||
@@ -584,7 +584,7 @@ device_t keyboard_xt_device = {
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
device_t keyboard_tandy_device = {
|
||||
const device_t keyboard_tandy_device = {
|
||||
"Tandy 1000 Keyboard",
|
||||
0,
|
||||
1,
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
char lpt_device_names[3][16];
|
||||
|
||||
|
||||
static struct
|
||||
static const struct
|
||||
{
|
||||
const char *name;
|
||||
const char *internal_name;
|
||||
lpt_device_t *device;
|
||||
const lpt_device_t *device;
|
||||
} lpt_devices[] =
|
||||
{
|
||||
{"None", "none", NULL},
|
||||
@@ -60,7 +60,7 @@ void lpt_devices_init()
|
||||
lpt_device_ts[i] = NULL;
|
||||
else
|
||||
{
|
||||
lpt_device_ts[i] = lpt_devices[c].device;
|
||||
lpt_device_ts[i] = (lpt_device_t *) lpt_devices[c].device;
|
||||
if (lpt_device_ts[i])
|
||||
lpt_device_ps[i] = lpt_device_ts[i]->init();
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
* in alpha mode, but in highres ("ECD350") mode, it displays
|
||||
* some semi-random junk. Video-memory pointer maybe?
|
||||
*
|
||||
* Version: @(#)m_amstrad.c 1.0.10 2018/02/02
|
||||
* Version: @(#)m_amstrad.c 1.0.11 2018/03/18
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -557,7 +557,7 @@ vid_speed_change_1512(void *priv)
|
||||
}
|
||||
|
||||
|
||||
static device_t vid_1512_device = {
|
||||
static const device_t vid_1512_device = {
|
||||
"Amstrad PC1512 (video)",
|
||||
0, 0,
|
||||
NULL, vid_close_1512, NULL,
|
||||
@@ -721,7 +721,7 @@ vid_speed_changed_1640(void *priv)
|
||||
}
|
||||
|
||||
|
||||
static device_t vid_1640_device = {
|
||||
static const device_t vid_1640_device = {
|
||||
"Amstrad PC1640 (video)",
|
||||
0, 0,
|
||||
NULL, vid_close_1640, NULL,
|
||||
@@ -856,7 +856,7 @@ vid_speed_changed_200(void *priv)
|
||||
}
|
||||
|
||||
|
||||
static device_t vid_200_device = {
|
||||
static const device_t vid_200_device = {
|
||||
"Amstrad PC200 (video)",
|
||||
0, 0,
|
||||
NULL, vid_close_200, NULL,
|
||||
@@ -1198,7 +1198,7 @@ ams_read(uint16_t port, void *priv)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
machine_amstrad_init(const machine_t *model)
|
||||
{
|
||||
amstrad_t *ams;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
|
||||
void
|
||||
machine_at_common_init(machine_t *model)
|
||||
machine_at_common_init(const machine_t *model)
|
||||
{
|
||||
machine_common_init(model);
|
||||
|
||||
@@ -38,7 +38,7 @@ machine_at_common_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_init(machine_t *model)
|
||||
machine_at_init(const machine_t *model)
|
||||
{
|
||||
machine_at_common_init(model);
|
||||
|
||||
@@ -47,7 +47,7 @@ machine_at_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_ps2_init(machine_t *model)
|
||||
machine_at_ps2_init(const machine_t *model)
|
||||
{
|
||||
machine_at_common_init(model);
|
||||
|
||||
@@ -56,7 +56,7 @@ machine_at_ps2_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_common_ide_init(machine_t *model)
|
||||
machine_at_common_ide_init(const machine_t *model)
|
||||
{
|
||||
machine_at_common_init(model);
|
||||
|
||||
@@ -65,7 +65,7 @@ machine_at_common_ide_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_ide_init(machine_t *model)
|
||||
machine_at_ide_init(const machine_t *model)
|
||||
{
|
||||
machine_at_init(model);
|
||||
|
||||
@@ -74,7 +74,7 @@ machine_at_ide_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_ps2_ide_init(machine_t *model)
|
||||
machine_at_ps2_ide_init(const machine_t *model)
|
||||
{
|
||||
machine_at_ps2_init(model);
|
||||
|
||||
@@ -83,7 +83,7 @@ machine_at_ps2_ide_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_top_remap_init(machine_t *model)
|
||||
machine_at_top_remap_init(const machine_t *model)
|
||||
{
|
||||
machine_at_init(model);
|
||||
|
||||
@@ -92,7 +92,7 @@ machine_at_top_remap_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_ide_top_remap_init(machine_t *model)
|
||||
machine_at_ide_top_remap_init(const machine_t *model)
|
||||
{
|
||||
machine_at_ide_init(model);
|
||||
|
||||
@@ -101,7 +101,7 @@ machine_at_ide_top_remap_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_ibm_init(machine_t *model)
|
||||
machine_at_ibm_init(const machine_t *model)
|
||||
{
|
||||
machine_at_top_remap_init(model);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Implementation of the Intel 430FX PCISet chip.
|
||||
*
|
||||
* Version: @(#)m_at_430fx.c 1.0.13 2018/02/23
|
||||
* Version: @(#)m_at_430fx.c 1.0.14 2018/03/18
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -207,7 +207,7 @@ static void i430fx_init(void)
|
||||
|
||||
|
||||
void
|
||||
machine_at_p54tp4xe_init(machine_t *model)
|
||||
machine_at_p54tp4xe_init(const machine_t *model)
|
||||
{
|
||||
machine_at_ps2_init(model);
|
||||
|
||||
@@ -228,7 +228,7 @@ machine_at_p54tp4xe_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_endeavor_init(machine_t *model)
|
||||
machine_at_endeavor_init(const machine_t *model)
|
||||
{
|
||||
machine_at_common_init(model);
|
||||
device_add(&keyboard_ps2_ami_device);
|
||||
@@ -253,7 +253,7 @@ machine_at_endeavor_init(machine_t *model)
|
||||
}
|
||||
|
||||
|
||||
device_t *
|
||||
const device_t *
|
||||
at_endeavor_get_device(void)
|
||||
{
|
||||
return &s3_phoenix_trio64_onboard_pci_device;
|
||||
@@ -261,7 +261,7 @@ at_endeavor_get_device(void)
|
||||
|
||||
|
||||
void
|
||||
machine_at_zappa_init(machine_t *model)
|
||||
machine_at_zappa_init(const machine_t *model)
|
||||
{
|
||||
machine_at_common_init(model);
|
||||
device_add(&keyboard_ps2_ami_device);
|
||||
@@ -282,7 +282,7 @@ machine_at_zappa_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_mb500n_init(machine_t *model)
|
||||
machine_at_mb500n_init(const machine_t *model)
|
||||
{
|
||||
machine_at_ps2_init(model);
|
||||
|
||||
@@ -302,7 +302,7 @@ machine_at_mb500n_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_president_init(machine_t *model)
|
||||
machine_at_president_init(const machine_t *model)
|
||||
{
|
||||
machine_at_ps2_init(model);
|
||||
|
||||
@@ -323,7 +323,7 @@ machine_at_president_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_thor_init(machine_t *model)
|
||||
machine_at_thor_init(const machine_t *model)
|
||||
{
|
||||
machine_at_common_init(model);
|
||||
device_add(&keyboard_ps2_ami_device);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Implementation of the Intel 430HX PCISet chip.
|
||||
*
|
||||
* Version: @(#)m_at_430hx.c 1.0.11 2018/02/14
|
||||
* Version: @(#)m_at_430hx.c 1.0.11 2018/03/18
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -216,7 +216,7 @@ acerm3a_in(uint16_t port, void *p)
|
||||
|
||||
|
||||
void
|
||||
machine_at_acerm3a_init(machine_t *model)
|
||||
machine_at_acerm3a_init(const machine_t *model)
|
||||
{
|
||||
machine_at_ps2_init(model);
|
||||
|
||||
@@ -239,7 +239,7 @@ machine_at_acerm3a_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_acerv35n_init(machine_t *model)
|
||||
machine_at_acerv35n_init(const machine_t *model)
|
||||
{
|
||||
machine_at_ps2_init(model);
|
||||
|
||||
@@ -262,7 +262,7 @@ machine_at_acerv35n_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_ap53_init(machine_t *model)
|
||||
machine_at_ap53_init(const machine_t *model)
|
||||
{
|
||||
machine_at_common_init(model);
|
||||
device_add(&keyboard_ps2_ami_device);
|
||||
@@ -286,7 +286,7 @@ machine_at_ap53_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_p55t2p4_init(machine_t *model)
|
||||
machine_at_p55t2p4_init(const machine_t *model)
|
||||
{
|
||||
machine_at_ps2_init(model);
|
||||
|
||||
@@ -307,7 +307,7 @@ machine_at_p55t2p4_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_p55t2s_init(machine_t *model)
|
||||
machine_at_p55t2s_init(const machine_t *model)
|
||||
{
|
||||
machine_at_common_init(model);
|
||||
device_add(&keyboard_ps2_ami_device);
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
*
|
||||
* Implementation of the Intel 430LX and 430NX PCISet chips.
|
||||
*
|
||||
* Version: @(#)m_at_430lx_nx.c 1.0.10 2018/02/14
|
||||
* Version: @(#)m_at_430lx_nx.c 1.0.10 2018/03/18
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2016,2018 Miran Grca.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -211,7 +211,7 @@ static void i430nx_init(void)
|
||||
|
||||
|
||||
static void
|
||||
machine_at_premiere_common_init(machine_t *model)
|
||||
machine_at_premiere_common_init(const machine_t *model)
|
||||
{
|
||||
machine_at_common_init(model);
|
||||
device_add(&keyboard_ps2_ami_device);
|
||||
@@ -233,7 +233,7 @@ machine_at_premiere_common_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_batman_init(machine_t *model)
|
||||
machine_at_batman_init(const machine_t *model)
|
||||
{
|
||||
machine_at_premiere_common_init(model);
|
||||
|
||||
@@ -242,7 +242,7 @@ machine_at_batman_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_plato_init(machine_t *model)
|
||||
machine_at_plato_init(const machine_t *model)
|
||||
{
|
||||
machine_at_premiere_common_init(model);
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
*
|
||||
* Implementation of the Intel 430VX PCISet chip.
|
||||
*
|
||||
* Version: @(#)m_at_430vx.c 1.0.11 2018/02/14
|
||||
* Version: @(#)m_at_430vx.c 1.0.11 2018/03/18
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2016,2018 Miran Grca.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -193,7 +193,7 @@ void i430vx_init(void)
|
||||
|
||||
|
||||
void
|
||||
machine_at_p55tvp4_init(machine_t *model)
|
||||
machine_at_p55tvp4_init(const machine_t *model)
|
||||
{
|
||||
machine_at_ps2_init(model);
|
||||
|
||||
@@ -214,7 +214,7 @@ machine_at_p55tvp4_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_i430vx_init(machine_t *model)
|
||||
machine_at_i430vx_init(const machine_t *model)
|
||||
{
|
||||
machine_at_ps2_init(model);
|
||||
|
||||
@@ -235,7 +235,7 @@ machine_at_i430vx_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_p55va_init(machine_t *model)
|
||||
machine_at_p55va_init(const machine_t *model)
|
||||
{
|
||||
machine_at_ps2_init(model);
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
*
|
||||
* Implementation of the Intel 440FX PCISet chip.
|
||||
*
|
||||
* Version: @(#)m_at_440fx.c 1.0.10 2018/02/14
|
||||
* Version: @(#)m_at_440fx.c 1.0.11 2018/03/18
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2016,2018 Miran Grca.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -195,7 +195,7 @@ static void i440fx_init(void)
|
||||
|
||||
|
||||
void
|
||||
machine_at_i440fx_init(machine_t *model)
|
||||
machine_at_i440fx_init(const machine_t *model)
|
||||
{
|
||||
machine_at_ps2_init(model);
|
||||
|
||||
@@ -217,7 +217,7 @@ machine_at_i440fx_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_s1668_init(machine_t *model)
|
||||
machine_at_s1668_init(const machine_t *model)
|
||||
{
|
||||
machine_at_common_init(model);
|
||||
device_add(&keyboard_ps2_ami_device);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* NOTE: The NEAT 82c206 code should be moved into a 82c206 module,
|
||||
* so it can be re-used by other boards.
|
||||
*
|
||||
* Version: @(#)m_4gpv31.c 1.0.4 2018/01/16
|
||||
* Version: @(#)m_4gpv31.c 1.0.5 2018/03/18
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
@@ -143,7 +143,7 @@ neat_init(void)
|
||||
|
||||
|
||||
void
|
||||
machine_at_4gpv31_init(machine_t *model)
|
||||
machine_at_4gpv31_init(const machine_t *model)
|
||||
{
|
||||
machine_at_common_ide_init(model);
|
||||
device_add(&keyboard_at_ami_device);
|
||||
|
||||
@@ -98,7 +98,7 @@ static void ali1429_init(void)
|
||||
|
||||
|
||||
void
|
||||
machine_at_ali1429_init(machine_t *model)
|
||||
machine_at_ali1429_init(const machine_t *model)
|
||||
{
|
||||
ali1429_reset();
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ static void cbm_io_init()
|
||||
|
||||
|
||||
void
|
||||
machine_at_cmdpc_init(machine_t *model)
|
||||
machine_at_cmdpc_init(const machine_t *model)
|
||||
{
|
||||
machine_at_ide_top_remap_init(model);
|
||||
device_add(&fdc_at_device);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Emulation of various Compaq PC's.
|
||||
*
|
||||
* Version: @(#)m_at_compaq.c 1.0.4 2018/02/14
|
||||
* Version: @(#)m_at_compaq.c 1.0.5 2018/03/18
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -98,7 +98,7 @@ write_raml(uint32_t addr, uint32_t val, void *priv)
|
||||
|
||||
|
||||
void
|
||||
machine_at_compaq_init(machine_t *model)
|
||||
machine_at_compaq_init(const machine_t *model)
|
||||
{
|
||||
machine_at_top_remap_init(model);
|
||||
device_add(&fdc_at_device);
|
||||
|
||||
@@ -70,7 +70,7 @@ static void headland_init(void)
|
||||
|
||||
|
||||
void
|
||||
machine_at_headland_init(machine_t *model)
|
||||
machine_at_headland_init(const machine_t *model)
|
||||
{
|
||||
machine_at_common_ide_init(model);
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ static void neat_init(void)
|
||||
|
||||
|
||||
void
|
||||
machine_at_neat_init(machine_t *model)
|
||||
machine_at_neat_init(const machine_t *model)
|
||||
{
|
||||
machine_at_init(model);
|
||||
device_add(&fdc_at_device);
|
||||
@@ -98,7 +98,7 @@ machine_at_neat_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_neat_ami_init(machine_t *model)
|
||||
machine_at_neat_ami_init(const machine_t *model)
|
||||
{
|
||||
machine_at_common_init(model);
|
||||
|
||||
|
||||
@@ -323,7 +323,7 @@ static void opti495_init(void)
|
||||
|
||||
|
||||
void
|
||||
machine_at_opti495_init(machine_t *model)
|
||||
machine_at_opti495_init(const machine_t *model)
|
||||
{
|
||||
machine_at_common_ide_init(model);
|
||||
|
||||
@@ -335,7 +335,7 @@ machine_at_opti495_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_opti495_ami_init(machine_t *model)
|
||||
machine_at_opti495_ami_init(const machine_t *model)
|
||||
{
|
||||
machine_at_common_ide_init(model);
|
||||
|
||||
|
||||
@@ -10,13 +10,14 @@
|
||||
*
|
||||
* Re-worked version based on the 82C235 datasheet and errata.
|
||||
*
|
||||
* Version: @(#)m_at_scat.c 1.0.10 2018/03/02
|
||||
* Version: @(#)m_at_scat.c 1.0.13 2018/03/20
|
||||
*
|
||||
* Authors: Original by GreatPsycho for PCem.
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
@@ -27,6 +28,7 @@
|
||||
#include "../cpu/x86.h"
|
||||
#include "../floppy/fdd.h"
|
||||
#include "../floppy/fdc.h"
|
||||
#include "../keyboard.h"
|
||||
#include "../io.h"
|
||||
#include "../mem.h"
|
||||
#include "../nmi.h"
|
||||
@@ -83,6 +85,24 @@ static int scatsx_mem_conf_val[33] = { 0x00, 0x01, 0x03, 0x04, 0x05, 0x08, 0x06,
|
||||
uint8_t scat_read(uint16_t port, void *priv);
|
||||
void scat_write(uint16_t port, uint8_t val, void *priv);
|
||||
|
||||
|
||||
#ifdef ENABLE_SCAT_LOG
|
||||
int scat_do_log = ENABLE_SCAT_LOG;
|
||||
#endif
|
||||
|
||||
static void
|
||||
scat_log(const char *format, ...)
|
||||
{
|
||||
#ifdef ENABLE_SCAT_LOG
|
||||
if (scat_do_log) {
|
||||
va_start(ap, format);
|
||||
pclog_ex(format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void scat_shadow_state_update()
|
||||
{
|
||||
int i, val;
|
||||
@@ -185,7 +205,7 @@ void scat_set_xms_bound(uint8_t val)
|
||||
mem_mapping_disable(&scat_shadowram_mapping[i]);
|
||||
if(mem_size > 1024) mem_mapping_enable(&ram_high_mapping);
|
||||
}
|
||||
pclog("Set XMS bound(%02X) = %06X(%dKbytes for EMS access)\n", val, scat_xms_bound, (0x160000 - scat_xms_bound) >> 10);
|
||||
scat_log("Set XMS bound(%02X) = %06X(%dKbytes for EMS access)\n", val, scat_xms_bound, (0x160000 - scat_xms_bound) >> 10);
|
||||
if (scat_xms_bound > 0x100000)
|
||||
mem_set_mem_state(0x100000, scat_xms_bound - 0x100000, MEM_READ_INTERNAL | MEM_WRITE_INTERNAL);
|
||||
if (scat_xms_bound < 0x160000)
|
||||
@@ -199,7 +219,7 @@ void scat_set_xms_bound(uint8_t val)
|
||||
|
||||
if (scat_xms_bound > max_xms_size)
|
||||
scat_xms_bound = max_xms_size;
|
||||
pclog("Set XMS bound(%02X) = %06X(%dKbytes for EMS access)\n", val, scat_xms_bound, ((mem_size << 10) - scat_xms_bound) >> 10);
|
||||
scat_log("Set XMS bound(%02X) = %06X(%dKbytes for EMS access)\n", val, scat_xms_bound, ((mem_size << 10) - scat_xms_bound) >> 10);
|
||||
if (scat_xms_bound > 0x100000)
|
||||
mem_set_mem_state(0x100000, scat_xms_bound - 0x100000, MEM_READ_INTERNAL | MEM_WRITE_INTERNAL);
|
||||
if (scat_xms_bound < (mem_size << 10))
|
||||
@@ -398,12 +418,12 @@ void scat_write(uint16_t port, uint8_t val, void *priv)
|
||||
}
|
||||
if (scat_reg_valid)
|
||||
scat_regs[scat_index] = val;
|
||||
else pclog("Attemped to write unimplemented SCAT register %02X at %04X:%04X\n", scat_index, val, CS, cpu_state.pc);
|
||||
else scat_log("Attemped to write unimplemented SCAT register %02X at %04X:%04X\n", scat_index, val, CS, cpu_state.pc);
|
||||
if (scat_shadow_update)
|
||||
scat_shadow_state_update();
|
||||
if (scat_map_update)
|
||||
scat_memmap_state_update();
|
||||
// pclog("Write SCAT Register %02X to %02X at %04X:%04X\n", scat_index, val, CS, cpu_state.pc);
|
||||
// scat_log("Write SCAT Register %02X to %02X at %04X:%04X\n", scat_index, val, CS, cpu_state.pc);
|
||||
break;
|
||||
|
||||
case 0x92:
|
||||
@@ -424,7 +444,7 @@ void scat_write(uint16_t port, uint8_t val, void *priv)
|
||||
case 0x218:
|
||||
if ((scat_regs[SCAT_EMS_CONTROL] & 0x41) == (0x40 | ((port & 0x10) >> 4)))
|
||||
{
|
||||
// pclog("Write SCAT EMS Control Port %04X to %02X at %04X:%04X\n", port, val, CS, cpu_state.pc);
|
||||
// scat_log("Write SCAT EMS Control Port %04X to %02X at %04X:%04X\n", port, val, CS, cpu_state.pc);
|
||||
if((scat_regs[SCAT_VERSION] & 0xF0) == 0) index = scat_ems_reg_2xA & 0x1F;
|
||||
else index = ((scat_ems_reg_2xA & 0x40) >> 4) + (scat_ems_reg_2xA & 0x3) + 24;
|
||||
scat_stat[index].regs_2x8 = val;
|
||||
@@ -445,7 +465,7 @@ void scat_write(uint16_t port, uint8_t val, void *priv)
|
||||
case 0x219:
|
||||
if ((scat_regs[SCAT_EMS_CONTROL] & 0x41) == (0x40 | ((port & 0x10) >> 4)))
|
||||
{
|
||||
// pclog("Write SCAT EMS Control Port %04X to %02X at %04X:%04X\n", port, val, CS, cpu_state.pc);
|
||||
// scat_log("Write SCAT EMS Control Port %04X to %02X at %04X:%04X\n", port, val, CS, cpu_state.pc);
|
||||
if((scat_regs[SCAT_VERSION] & 0xF0) == 0) index = scat_ems_reg_2xA & 0x1F;
|
||||
else index = ((scat_ems_reg_2xA & 0x40) >> 4) + (scat_ems_reg_2xA & 0x3) + 24;
|
||||
scat_stat[index].regs_2x9 = val;
|
||||
@@ -462,14 +482,14 @@ void scat_write(uint16_t port, uint8_t val, void *priv)
|
||||
if(virt_addr < (mem_size << 10)) mem_mapping_set_exec(&scat_mapping[index], ram + virt_addr);
|
||||
else mem_mapping_set_exec(&scat_mapping[index], NULL);
|
||||
mem_mapping_enable(&scat_mapping[index]);
|
||||
// pclog("Map page %d(address %05X) to address %06X\n", scat_ems_reg_2xA & 0x1f, base_addr, virt_addr);
|
||||
// scat_log("Map page %d(address %05X) to address %06X\n", scat_ems_reg_2xA & 0x1f, base_addr, virt_addr);
|
||||
}
|
||||
else
|
||||
{
|
||||
mem_mapping_set_exec(&scat_mapping[index], ram + base_addr);
|
||||
mem_mapping_disable(&scat_mapping[index]);
|
||||
if(index < 24) mem_mapping_enable(&scat_4000_9FFF_mapping[index]);
|
||||
// pclog("Unmap page %d(address %06X)\n", scat_ems_reg_2xA & 0x1f, base_addr);
|
||||
// scat_log("Unmap page %d(address %06X)\n", scat_ems_reg_2xA & 0x1f, base_addr);
|
||||
}
|
||||
flushmmucache();
|
||||
}
|
||||
@@ -484,7 +504,7 @@ void scat_write(uint16_t port, uint8_t val, void *priv)
|
||||
case 0x21A:
|
||||
if ((scat_regs[SCAT_EMS_CONTROL] & 0x41) == (0x40 | ((port & 0x10) >> 4)))
|
||||
{
|
||||
// pclog("Write SCAT EMS Control Port %04X to %02X at %04X:%04X\n", port, val, CS, cpu_state.pc);
|
||||
// scat_log("Write SCAT EMS Control Port %04X to %02X at %04X:%04X\n", port, val, CS, cpu_state.pc);
|
||||
scat_ems_reg_2xA = ((scat_regs[SCAT_VERSION] & 0xF0) == 0) ? val : val & 0xc3;
|
||||
}
|
||||
break;
|
||||
@@ -511,7 +531,7 @@ uint8_t scat_read(uint16_t port, void *priv)
|
||||
val = scat_regs[scat_index];
|
||||
break;
|
||||
}
|
||||
// pclog("Read SCAT Register %02X at %04X:%04X\n", scat_index, CS, cpu_state.pc);
|
||||
// scat_log("Read SCAT Register %02X at %04X:%04X\n", scat_index, CS, cpu_state.pc);
|
||||
break;
|
||||
|
||||
case 0x92:
|
||||
@@ -522,7 +542,7 @@ uint8_t scat_read(uint16_t port, void *priv)
|
||||
case 0x218:
|
||||
if ((scat_regs[SCAT_EMS_CONTROL] & 0x41) == (0x40 | ((port & 0x10) >> 4)))
|
||||
{
|
||||
// pclog("Read SCAT EMS Control Port %04X at %04X:%04X\n", port, CS, cpu_state.pc);
|
||||
// scat_log("Read SCAT EMS Control Port %04X at %04X:%04X\n", port, CS, cpu_state.pc);
|
||||
if((scat_regs[SCAT_VERSION] & 0xF0) == 0) index = scat_ems_reg_2xA & 0x1F;
|
||||
else index = ((scat_ems_reg_2xA & 0x40) >> 4) + (scat_ems_reg_2xA & 0x3) + 24;
|
||||
val = scat_stat[index].regs_2x8;
|
||||
@@ -532,7 +552,7 @@ uint8_t scat_read(uint16_t port, void *priv)
|
||||
case 0x219:
|
||||
if ((scat_regs[SCAT_EMS_CONTROL] & 0x41) == (0x40 | ((port & 0x10) >> 4)))
|
||||
{
|
||||
// pclog("Read SCAT EMS Control Port %04X at %04X:%04X\n", port, CS, cpu_state.pc);
|
||||
// scat_log("Read SCAT EMS Control Port %04X at %04X:%04X\n", port, CS, cpu_state.pc);
|
||||
if((scat_regs[SCAT_VERSION] & 0xF0) == 0) index = scat_ems_reg_2xA & 0x1F;
|
||||
else index = ((scat_ems_reg_2xA & 0x40) >> 4) + (scat_ems_reg_2xA & 0x3) + 24;
|
||||
val = scat_stat[index].regs_2x9;
|
||||
@@ -542,7 +562,7 @@ uint8_t scat_read(uint16_t port, void *priv)
|
||||
case 0x21A:
|
||||
if ((scat_regs[SCAT_EMS_CONTROL] & 0x41) == (0x40 | ((port & 0x10) >> 4)))
|
||||
{
|
||||
// pclog("Read SCAT EMS Control Port %04X at %04X:%04X\n", port, CS, cpu_state.pc);
|
||||
// scat_log("Read SCAT EMS Control Port %04X at %04X:%04X\n", port, CS, cpu_state.pc);
|
||||
val = scat_ems_reg_2xA;
|
||||
}
|
||||
break;
|
||||
@@ -712,7 +732,7 @@ scatsx_init()
|
||||
|
||||
|
||||
void
|
||||
machine_at_scat_init(machine_t *model)
|
||||
machine_at_scat_init(const machine_t *model)
|
||||
{
|
||||
machine_at_init(model);
|
||||
device_add(&fdc_at_device);
|
||||
@@ -722,9 +742,11 @@ machine_at_scat_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_scatsx_init(machine_t *model)
|
||||
machine_at_scatsx_init(const machine_t *model)
|
||||
{
|
||||
machine_at_init(model);
|
||||
machine_at_common_init(model);
|
||||
|
||||
device_add(&keyboard_at_ami_device);
|
||||
device_add(&fdc_at_device);
|
||||
|
||||
scatsx_init();
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* SiS sis85c471 Super I/O Chip
|
||||
* Used by DTK PKM-0038S E-2
|
||||
*
|
||||
* Version: @(#)m_at_sis85c471.c 1.0.9 2018/01/16
|
||||
* Version: @(#)m_at_sis85c471.c 1.0.10 2018/03/18
|
||||
*
|
||||
* Author: Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
@@ -240,7 +240,7 @@ static void sis_85c471_init(void)
|
||||
|
||||
|
||||
void
|
||||
machine_at_dtk486_init(machine_t *model)
|
||||
machine_at_dtk486_init(const machine_t *model)
|
||||
{
|
||||
machine_at_ide_init(model);
|
||||
device_add(&fdc_at_device);
|
||||
|
||||
@@ -162,7 +162,7 @@ static void sis_85c496_init(void)
|
||||
|
||||
|
||||
static void
|
||||
machine_at_sis_85c496_common_init(machine_t *model)
|
||||
machine_at_sis_85c496_common_init(const machine_t *model)
|
||||
{
|
||||
machine_at_ps2_init(model);
|
||||
device_add(&ide_pci_device);
|
||||
@@ -180,7 +180,7 @@ machine_at_sis_85c496_common_init(machine_t *model)
|
||||
|
||||
|
||||
void
|
||||
machine_at_r418_init(machine_t *model)
|
||||
machine_at_r418_init(const machine_t *model)
|
||||
{
|
||||
machine_at_sis_85c496_common_init(model);
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
*
|
||||
* Emulation of the SiS 50x PCI chips.
|
||||
*
|
||||
* Version: @(#)m_at_sis_85c50x.c 1.0.5 2017/11/04
|
||||
* Version: @(#)m_at_sis_85c50x.c 1.0.6 2018/03/18
|
||||
*
|
||||
* Author: Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
* Copyright 2017 Miran Grca.
|
||||
* Copyright 2015-2018 Miran Grca.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -117,7 +117,7 @@
|
||||
* bit 2 set for single-pixel LCD font
|
||||
* bits 0,1 for display font
|
||||
*
|
||||
* Version: @(#)m_at_t3100e.c 1.0.3 2018/03/05
|
||||
* Version: @(#)m_at_t3100e.c 1.0.4 2018/03/18
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -716,7 +716,7 @@ static void upper_write_raml(uint32_t addr, uint32_t val, void *priv)
|
||||
|
||||
|
||||
|
||||
void machine_at_t3100e_init(machine_t *model)
|
||||
void machine_at_t3100e_init(const machine_t *model)
|
||||
{
|
||||
int pg;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Definitions for the Toshiba T3100e system.
|
||||
*
|
||||
* Version: @(#)m_at_t3100e.h 1.0.2 2018/03/05
|
||||
* Version: @(#)m_at_t3100e.h 1.0.3 2018/03/18
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -40,7 +40,7 @@
|
||||
# define MACHINE_T3100E_H
|
||||
|
||||
|
||||
extern device_t t3100e_device;
|
||||
extern const device_t t3100e_device;
|
||||
|
||||
|
||||
extern void t3100e_notify_set(uint8_t value);
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* 61 50 52 0F 19 06 19 19 02 0D 0B 0C MONO
|
||||
* 2D 28 22 0A 67 00 64 67 02 03 06 07 640x400
|
||||
*
|
||||
* Version: @(#)m_at_t3100e_vid.c 1.0.3 2018/03/07
|
||||
* Version: @(#)m_at_t3100e_vid.c 1.0.4 2018/03/18
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -703,7 +703,7 @@ void t3100e_recalcattrs(t3100e_t *t3100e)
|
||||
}
|
||||
|
||||
|
||||
void *t3100e_init(device_t *info)
|
||||
void *t3100e_init(const device_t *info)
|
||||
{
|
||||
t3100e_t *t3100e = malloc(sizeof(t3100e_t));
|
||||
memset(t3100e, 0, sizeof(t3100e_t));
|
||||
@@ -748,7 +748,7 @@ void t3100e_speed_changed(void *p)
|
||||
t3100e_recalctimings(t3100e);
|
||||
}
|
||||
|
||||
device_t t3100e_device =
|
||||
const device_t t3100e_device =
|
||||
{
|
||||
"Toshiba T3100e",
|
||||
0,
|
||||
|
||||
@@ -142,7 +142,7 @@ static void wd76c10_init(void)
|
||||
|
||||
|
||||
void
|
||||
machine_at_wd76c10_init(machine_t *model)
|
||||
machine_at_wd76c10_init(const machine_t *model)
|
||||
{
|
||||
machine_at_common_ide_init(model);
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
*
|
||||
* WARNING THIS IS A WORK-IN-PROGRESS MODULE. USE AT OWN RISK.
|
||||
*
|
||||
* Version: @(#)europc.c 1.0.2 2018/03/11
|
||||
* Version: @(#)europc.c 1.0.3 2018/03/18
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
@@ -546,7 +546,7 @@ jim_read(uint16_t addr, void *priv)
|
||||
|
||||
/* Initialize the mainboard 'device' of the machine. */
|
||||
static void *
|
||||
europc_boot(device_t *info)
|
||||
europc_boot(const device_t *info)
|
||||
{
|
||||
europc_t *sys = &europc;
|
||||
uint8_t b;
|
||||
@@ -674,7 +674,7 @@ europc_close(void *priv)
|
||||
}
|
||||
|
||||
|
||||
static device_config_t europc_config[] = {
|
||||
static const device_config_t europc_config[] = {
|
||||
{
|
||||
"js9", "JS9 Jumper (JIM)", CONFIG_INT, "", 0,
|
||||
{
|
||||
@@ -695,7 +695,7 @@ static device_config_t europc_config[] = {
|
||||
};
|
||||
|
||||
|
||||
device_t europc_device = {
|
||||
const device_t europc_device = {
|
||||
"EuroPC System Board",
|
||||
0, 0,
|
||||
europc_boot, europc_close, NULL,
|
||||
@@ -713,7 +713,7 @@ device_t europc_device = {
|
||||
* user.
|
||||
*/
|
||||
void
|
||||
machine_europc_init(machine_t *model)
|
||||
machine_europc_init(const machine_t *model)
|
||||
{
|
||||
/* Clear the machine state. */
|
||||
memset(&europc, 0x00, sizeof(europc_t));
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user