Added the 3Com 3C503 Network card;

Several bug fixes;
Preliminar addition of the SDL 2 renderer (does not yet work correctly in full screen mode);
SCSI devices no longer have configurable LUN's (this matches the configurability of real SCSI devices);
SCSI LUN's are now handed by the device's handler;
Removed all unused strings;
Removed some unused code files;
Significantly rewrote the bus mouse emulation.
This commit is contained in:
OBattler
2018-07-15 01:41:53 +02:00
parent fe2ef61f84
commit 950ce8f5aa
74 changed files with 9930 additions and 9714 deletions

View File

@@ -8,7 +8,7 @@
*
* Main include file for the application.
*
* Version: @(#)86box.h 1.0.22 2018/03/28
* Version: @(#)86box.h 1.0.23 2018/05/25
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -90,8 +90,7 @@ 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 */
gfxcard; /* (C) graphics/video card */
extern int serial_enabled[], /* (C) enable serial ports */
lpt_enabled, /* (C) enable LPT ports */
bugger_enabled; /* (C) enable ISAbugger */
@@ -127,6 +126,7 @@ extern wchar_t cfg_path[1024]; /* full path of config file */
extern FILE *stdlog; /* file to log output to */
extern int scrnsz_x, /* current screen size, X */
scrnsz_y; /* current screen size, Y */
extern int efscrnsz_y;
extern int config_changed; /* config has changed */

View File

@@ -10,7 +10,7 @@
# settings, so we can avoid changing the main one for all of
# our local setups.
#
# Version: @(#)Makefile.local 1.0.13 2018/04/29
# Version: @(#)Makefile.local 1.0.14 2018/05/26
#
# Author: Fred N. van Kempen, <decwiz@yahoo.com>
#
@@ -129,6 +129,7 @@ STUFF :=
# -DENABLE_DDRAW_LOG=N sets logging level at N.
# -DENABLE_DYNLD_LOG=N sets logging level at N.
# -DENABLE_JOYSTICK_LOG=N sets logging level at N.
# -DENABLE_SDL_LOG=N sets logging level at N.
# -DENABLE_WIN_LOG=N sets logging level at N.
EXTRAS :=

View File

@@ -9,7 +9,7 @@
* Implementation of the CD-ROM drive with SCSI(-like)
* commands, for both ATAPI and SCSI usage.
*
* Version: @(#)cdrom.c 1.0.47 2018/05/10
* Version: @(#)cdrom.c 1.0.48 2018/05/28
*
* Author: Miran Grca, <mgrca8@gmail.com>
*
@@ -62,22 +62,8 @@ cdrom_t *cdrom[CDROM_NUM];
cdrom_image_t cdrom_image[CDROM_NUM];
cdrom_drive_t cdrom_drives[CDROM_NUM];
uint8_t atapi_cdrom_drives[8] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
uint8_t scsi_cdrom_drives[16][8] = { { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } };
uint8_t scsi_cdrom_drives[16] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
#pragma pack(push,1)
@@ -106,90 +92,90 @@ static struct
/* Table of all SCSI commands and their flags, needed for the new disc change / not ready handler. */
const uint8_t cdrom_command_flags[0x100] =
{
IMPLEMENTED | CHECK_READY | NONDATA,
IMPLEMENTED | ALLOW_UA | NONDATA | SCSI_ONLY,
0,
IMPLEMENTED | ALLOW_UA,
0, 0, 0, 0,
IMPLEMENTED | CHECK_READY,
0, 0,
IMPLEMENTED | CHECK_READY | NONDATA,
0, 0, 0, 0, 0, 0,
IMPLEMENTED | ALLOW_UA,
IMPLEMENTED | CHECK_READY | NONDATA | SCSI_ONLY,
0,
IMPLEMENTED,
0, 0, 0, 0,
IMPLEMENTED,
IMPLEMENTED | CHECK_READY,
0, 0,
IMPLEMENTED | CHECK_READY,
0, 0, 0, 0, 0, 0,
IMPLEMENTED | CHECK_READY,
0, 0,
IMPLEMENTED | CHECK_READY,
0, 0,
IMPLEMENTED | CHECK_READY | NONDATA,
0, 0, 0,
IMPLEMENTED | CHECK_READY | NONDATA | SCSI_ONLY,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0,
IMPLEMENTED | CHECK_READY,
IMPLEMENTED | CHECK_READY, /* Read TOC - can get through UNIT_ATTENTION, per VIDE-CDD.SYS
IMPLEMENTED | CHECK_READY | NONDATA, /* 0x00 */
IMPLEMENTED | ALLOW_UA | NONDATA | SCSI_ONLY, /* 0x01 */
0, /* 0x02 */
IMPLEMENTED | ALLOW_UA, /* 0x03 */
0, 0, 0, 0, /* 0x04-0x07 */
IMPLEMENTED | CHECK_READY, /* 0x08 */
0, 0, /* 0x09-0x0A */
IMPLEMENTED | CHECK_READY | NONDATA, /* 0x0B */
0, 0, 0, 0, 0, 0, /* 0x0C-0x11 */
IMPLEMENTED | ALLOW_UA, /* 0x12 */
IMPLEMENTED | CHECK_READY | NONDATA | SCSI_ONLY, /* 0x13 */
0, /* 0x14 */
IMPLEMENTED, /* 0x15 */
0, 0, 0, 0, /* 0x16-0x19 */
IMPLEMENTED, /* 0x1A */
IMPLEMENTED | CHECK_READY, /* 0x1B */
0, 0, /* 0x1C-0x1D */
IMPLEMENTED | CHECK_READY, /* 0x1E */
0, 0, 0, 0, 0, 0, /* 0x1F-0x24 */
IMPLEMENTED | CHECK_READY, /* 0x25 */
0, 0, /* 0x26-0x27 */
IMPLEMENTED | CHECK_READY, /* 0x28 */
0, 0, /* 0x29-0x2A */
IMPLEMENTED | CHECK_READY | NONDATA, /* 0x2B */
0, 0, 0, /* 0x2C-0x2E */
IMPLEMENTED | CHECK_READY | NONDATA | SCSI_ONLY, /* 0x2F */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x30-0x3F */
0, 0, /* 0x40-0x41 */
IMPLEMENTED | CHECK_READY, /* 0x42 */
IMPLEMENTED | CHECK_READY, /* 0x43 - Read TOC - can get through UNIT_ATTENTION, per VIDE-CDD.SYS
NOTE: The ATAPI reference says otherwise, but I think this is a question of
interpreting things right - the UNIT ATTENTION condition we have here
is a tradition from not ready to ready, by definition the drive
eventually becomes ready, make the condition go away. */
IMPLEMENTED | CHECK_READY,
IMPLEMENTED | CHECK_READY,
IMPLEMENTED | ALLOW_UA,
IMPLEMENTED | CHECK_READY,
IMPLEMENTED | CHECK_READY,
0,
IMPLEMENTED | ALLOW_UA,
IMPLEMENTED | CHECK_READY,
0, 0,
IMPLEMENTED | CHECK_READY,
0, 0,
IMPLEMENTED | CHECK_READY,
IMPLEMENTED | CHECK_READY,
0, 0,
IMPLEMENTED,
0, 0, 0, 0,
IMPLEMENTED,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
IMPLEMENTED | CHECK_READY,
0, 0,
IMPLEMENTED | CHECK_READY,
0, 0, 0, 0,
IMPLEMENTED | CHECK_READY,
0,
IMPLEMENTED | CHECK_READY | NONDATA | SCSI_ONLY,
0, 0, 0, 0,
IMPLEMENTED | CHECK_READY | ATAPI_ONLY,
0, 0, 0,
IMPLEMENTED | CHECK_READY | ATAPI_ONLY,
IMPLEMENTED | CHECK_READY,
IMPLEMENTED | CHECK_READY,
IMPLEMENTED,
IMPLEMENTED | CHECK_READY,
IMPLEMENTED,
IMPLEMENTED | CHECK_READY,
IMPLEMENTED | CHECK_READY,
0, 0,
IMPLEMENTED | CHECK_READY | SCSI_ONLY,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
IMPLEMENTED | CHECK_READY | SCSI_ONLY,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
IMPLEMENTED | SCSI_ONLY,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
IMPLEMENTED | CHECK_READY, /* 0x44 */
IMPLEMENTED | CHECK_READY, /* 0x45 */
IMPLEMENTED | ALLOW_UA, /* 0x46 */
IMPLEMENTED | CHECK_READY, /* 0x47 */
IMPLEMENTED | CHECK_READY, /* 0x48 */
0, /* 0x49 */
IMPLEMENTED | ALLOW_UA, /* 0x4A */
IMPLEMENTED | CHECK_READY, /* 0x4B */
0, 0, /* 0x4C-0x4D */
IMPLEMENTED | CHECK_READY, /* 0x4E */
0, 0, /* 0x4F-0x50 */
IMPLEMENTED | CHECK_READY, /* 0x51 */
IMPLEMENTED | CHECK_READY, /* 0x52 */
0, 0, /* 0x53-0x54 */
IMPLEMENTED, /* 0x55 */
0, 0, 0, 0, /* 0x56-0x59 */
IMPLEMENTED, /* 0x5A */
0, 0, 0, 0, 0, /* 0x5B-0x5F */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60-0x6F */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70-0x7F */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x80-0x8F */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90-0x9F */
0, 0, 0, 0, 0, /* 0xA0-0xA4 */
IMPLEMENTED | CHECK_READY, /* 0xA5 */
0, 0, /* 0xA6-0xA7 */
IMPLEMENTED | CHECK_READY, /* 0xA8 */
0, 0, 0, 0, /* 0xA9-0xAC */
IMPLEMENTED | CHECK_READY, /* 0xAD */
0, /* 0xAE */
IMPLEMENTED | CHECK_READY | NONDATA | SCSI_ONLY, /* 0xAF */
0, 0, 0, 0, /* 0xB0-0xB3 */
IMPLEMENTED | CHECK_READY | ATAPI_ONLY, /* 0xB4 */
0, 0, 0, /* 0xB5-0xB7 */
IMPLEMENTED | CHECK_READY | ATAPI_ONLY, /* 0xB8 */
IMPLEMENTED | CHECK_READY, /* 0xB9 */
IMPLEMENTED | CHECK_READY, /* 0xBA */
IMPLEMENTED, /* 0xBB */
IMPLEMENTED | CHECK_READY, /* 0xBC */
IMPLEMENTED, /* 0xBD */
IMPLEMENTED | CHECK_READY, /* 0xBE */
IMPLEMENTED | CHECK_READY, /* 0xBF */
0, 0, /* 0xC0-0xC1 */
IMPLEMENTED | CHECK_READY | SCSI_ONLY, /* 0xC2 */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xC3-0xCC */
IMPLEMENTED | CHECK_READY | SCSI_ONLY, /* 0xCD */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xCE-0xD9 */
IMPLEMENTED | SCSI_ONLY, /* 0xDA */
0, 0, 0, 0, 0, /* 0xDB-0xDF */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xE0-0xEF */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 0xF0-0xFF */
};
static uint64_t cdrom_mode_sense_page_flags = (GPMODEP_R_W_ERROR_PAGE |
@@ -397,12 +383,12 @@ build_atapi_cdrom_map()
int
find_cdrom_for_scsi_id(uint8_t scsi_id, uint8_t scsi_lun)
find_cdrom_for_scsi_id(uint8_t scsi_id)
{
uint8_t i = 0;
for (i = 0; i < CDROM_NUM; i++) {
if ((cdrom_drives[i].bus_type == CDROM_BUS_SCSI) && (cdrom_drives[i].scsi_device_id == scsi_id) && (cdrom_drives[i].scsi_device_lun == scsi_lun))
if ((cdrom_drives[i].bus_type == CDROM_BUS_SCSI) && (cdrom_drives[i].scsi_device_id == scsi_id))
return i;
}
return 0xff;
@@ -413,15 +399,11 @@ void
build_scsi_cdrom_map()
{
uint8_t i = 0;
uint8_t j = 0;
memset(scsi_cdrom_drives, 0xff, 16);
for (i = 0; i < 16; i++)
memset(scsi_cdrom_drives[i], 0xff, 8);
for (i = 0; i < 16; i++) {
for (j = 0; j < 8; j++)
scsi_cdrom_drives[i][j] = find_cdrom_for_scsi_id(i, j);
}
scsi_cdrom_drives[i] = find_cdrom_for_scsi_id(i);
}
@@ -772,6 +754,8 @@ cdrom_update_request_length(cdrom_t *dev, int len, int block_len)
if ((len <= dev->max_transfer_len) && (len >= min_len))
dev->request_length = dev->max_transfer_len = len;
else if (len > dev->max_transfer_len)
dev->request_length = dev->max_transfer_len;
return;
}
@@ -1008,7 +992,7 @@ static void cdrom_data_command_finish(cdrom_t *dev, int len, int block_len, int
{
cdrom_log("CD-ROM %i: Finishing command (%02X): %i, %i, %i, %i, %i\n",
dev->id, dev->current_cdb[0], len, block_len, alloc_len, direction, dev->request_length);
dev->pos=0;
dev->pos = 0;
if (alloc_len >= 0) {
if (alloc_len < len)
len = alloc_len;
@@ -1053,12 +1037,11 @@ static void
cdrom_set_phase(cdrom_t *dev, uint8_t phase)
{
uint8_t scsi_id = dev->drv->scsi_device_id;
uint8_t scsi_lun = dev->drv->scsi_device_lun;
if (dev->drv->bus_type != CDROM_BUS_SCSI)
return;
SCSIDevices[scsi_id][scsi_lun].Phase = phase;
SCSIDevices[scsi_id].Phase = phase;
}
@@ -1482,7 +1465,7 @@ cdrom_pre_execution_check(cdrom_t *dev, uint8_t *cdb)
int ready = 0, status = 0;
if (dev->drv->bus_type == CDROM_BUS_SCSI) {
if (((dev->request_length >> 5) & 7) != dev->drv->scsi_device_lun) {
if ((cdb[0] != GPCMD_REQUEST_SENSE) && (cdb[1] & 0xe0)) {
cdrom_log("CD-ROM %i: Attempting to execute a unknown command targeted at SCSI LUN %i\n",
dev->id, ((dev->request_length >> 5) & 7));
cdrom_invalid_lun(dev);
@@ -1733,7 +1716,7 @@ cdrom_command(cdrom_t *dev, uint8_t *cdb)
uint32_t profiles[2] = { MMC_PROFILE_CD_ROM, MMC_PROFILE_DVD_ROM };
if (dev->drv->bus_type == CDROM_BUS_SCSI) {
BufLen = &SCSIDevices[dev->drv->scsi_device_id][dev->drv->scsi_device_lun].BufferLength;
BufLen = &SCSIDevices[dev->drv->scsi_device_id].BufferLength;
dev->status &= ~ERR_STAT;
} else {
BufLen = &blen;
@@ -2772,7 +2755,6 @@ cdrom_phase_data_out(cdrom_t *dev)
static void
cdrom_pio_request(cdrom_t *dev, uint8_t out)
{
int old_pos = 0;
int ret = 0;
if (dev->drv->bus_type < CDROM_BUS_SCSI) {
@@ -2807,10 +2789,13 @@ cdrom_pio_request(cdrom_t *dev, uint8_t out)
cdrom_log("CD-ROM %i: Packet length %i, request length %i\n", dev->id, dev->packet_len,
dev->max_transfer_len);
old_pos = dev->pos;
dev->packet_status = out ? CDROM_PHASE_DATA_OUT : CDROM_PHASE_DATA_IN;
cdrom_command_common(dev);
dev->pos = old_pos;
dev->status = BUSY_STAT;
dev->phase = 1;
cdrom_phase_callback(dev);
dev->callback = 0LL;
cdrom_set_callback(dev);
dev->request_pos = 0;
}
@@ -2849,12 +2834,12 @@ cdrom_read_from_ide_dma(uint8_t channel)
static int
cdrom_read_from_scsi_dma(uint8_t scsi_id, uint8_t scsi_lun)
cdrom_read_from_scsi_dma(uint8_t scsi_id)
{
cdrom_t *dev;
uint8_t id = scsi_cdrom_drives[scsi_id][scsi_lun];
int32_t *BufLen = &SCSIDevices[scsi_id][scsi_lun].BufferLength;
uint8_t id = scsi_cdrom_drives[scsi_id];
int32_t *BufLen = &SCSIDevices[scsi_id].BufferLength;
if (id > CDROM_NUM)
return 0;
@@ -2862,7 +2847,7 @@ cdrom_read_from_scsi_dma(uint8_t scsi_id, uint8_t scsi_lun)
dev = cdrom[id];
cdrom_log("Reading from SCSI DMA: SCSI ID %02X, init length %i\n", scsi_id, *BufLen);
memcpy(cdbufferb, SCSIDevices[scsi_id][scsi_lun].CmdBuffer, *BufLen);
memcpy(cdbufferb, SCSIDevices[scsi_id].CmdBuffer, *BufLen);
return 1;
}
@@ -2878,11 +2863,11 @@ cdrom_irq_raise(cdrom_t *dev)
static int
cdrom_read_from_dma(cdrom_t *dev)
{
int32_t *BufLen = &SCSIDevices[dev->drv->scsi_device_id][dev->drv->scsi_device_lun].BufferLength;
int32_t *BufLen = &SCSIDevices[dev->drv->scsi_device_id].BufferLength;
int ret = 0;
if (dev->drv->bus_type == CDROM_BUS_SCSI)
ret = cdrom_read_from_scsi_dma(dev->drv->scsi_device_id, dev->drv->scsi_device_lun);
ret = cdrom_read_from_scsi_dma(dev->drv->scsi_device_id);
else
ret = cdrom_read_from_ide_dma(dev->drv->ide_channel);
@@ -2933,12 +2918,12 @@ cdrom_write_to_ide_dma(uint8_t channel)
static int
cdrom_write_to_scsi_dma(uint8_t scsi_id, uint8_t scsi_lun)
cdrom_write_to_scsi_dma(uint8_t scsi_id)
{
cdrom_t *dev;
uint8_t id = scsi_cdrom_drives[scsi_id][scsi_lun];
int32_t *BufLen = &SCSIDevices[scsi_id][scsi_lun].BufferLength;
uint8_t id = scsi_cdrom_drives[scsi_id];
int32_t *BufLen = &SCSIDevices[scsi_id].BufferLength;
if (id > CDROM_NUM)
return 0;
@@ -2946,15 +2931,15 @@ cdrom_write_to_scsi_dma(uint8_t scsi_id, uint8_t scsi_lun)
dev = cdrom[id];
cdrom_log("Writing to SCSI DMA: SCSI ID %02X, init length %i\n", scsi_id, *BufLen);
memcpy(SCSIDevices[scsi_id][scsi_lun].CmdBuffer, cdbufferb, *BufLen);
memcpy(SCSIDevices[scsi_id].CmdBuffer, cdbufferb, *BufLen);
cdrom_log("CD-ROM %i: Data from CD buffer: %02X %02X %02X %02X %02X %02X %02X %02X\n", id,
cdbufferb[0], cdbufferb[1], cdbufferb[2], cdbufferb[3], cdbufferb[4], cdbufferb[5],
cdbufferb[6], cdbufferb[7]);
cdrom_log("CD-ROM %i: Data from SCSI DMA : %02X %02X %02X %02X %02X %02X %02X %02X\n", id,
SCSIDevices[scsi_id][scsi_lun].CmdBuffer[0], SCSIDevices[scsi_id][scsi_lun].CmdBuffer[1],
SCSIDevices[scsi_id][scsi_lun].CmdBuffer[2], SCSIDevices[scsi_id][scsi_lun].CmdBuffer[3],
SCSIDevices[scsi_id][scsi_lun].CmdBuffer[4], SCSIDevices[scsi_id][scsi_lun].CmdBuffer[5],
SCSIDevices[scsi_id][scsi_lun].CmdBuffer[6], SCSIDevices[scsi_id][scsi_lun].CmdBuffer[7]);
SCSIDevices[scsi_id].CmdBuffer[0], SCSIDevices[scsi_id].CmdBuffer[1],
SCSIDevices[scsi_id].CmdBuffer[2], SCSIDevices[scsi_id].CmdBuffer[3],
SCSIDevices[scsi_id].CmdBuffer[4], SCSIDevices[scsi_id].CmdBuffer[5],
SCSIDevices[scsi_id].CmdBuffer[6], SCSIDevices[scsi_id].CmdBuffer[7]);
return 1;
}
@@ -2962,12 +2947,12 @@ cdrom_write_to_scsi_dma(uint8_t scsi_id, uint8_t scsi_lun)
static int
cdrom_write_to_dma(cdrom_t *dev)
{
int32_t *BufLen = &SCSIDevices[dev->drv->scsi_device_id][dev->drv->scsi_device_lun].BufferLength;
int32_t *BufLen = &SCSIDevices[dev->drv->scsi_device_id].BufferLength;
int ret = 0;
if (dev->drv->bus_type == CDROM_BUS_SCSI) {
cdrom_log("Write to SCSI DMA: (%02X:%02X)\n", dev->drv->scsi_device_id, dev->drv->scsi_device_lun);
ret = cdrom_write_to_scsi_dma(dev->drv->scsi_device_id, dev->drv->scsi_device_lun);
cdrom_log("Write to SCSI DMA: (ID %02X)\n", dev->drv->scsi_device_id);
ret = cdrom_write_to_scsi_dma(dev->drv->scsi_device_id);
} else
ret = cdrom_write_to_ide_dma(dev->drv->ide_channel);
@@ -2980,7 +2965,6 @@ cdrom_write_to_dma(cdrom_t *dev)
}
/* If the result is 1, issue an IRQ, otherwise not. */
void
cdrom_phase_callback(cdrom_t *dev)
{
@@ -2989,13 +2973,13 @@ cdrom_phase_callback(cdrom_t *dev)
switch(dev->packet_status) {
case CDROM_PHASE_IDLE:
cdrom_log("CD-ROM %i: CDROM_PHASE_IDLE\n", dev->id);
dev->pos=0;
dev->pos = 0;
dev->phase = 1;
dev->status = READY_STAT | DRQ_STAT | (dev->status & ERR_STAT);
return;
case CDROM_PHASE_COMMAND:
cdrom_log("CD-ROM %i: CDROM_PHASE_COMMAND\n", dev->id);
dev->status = BUSY_STAT | (dev->status &ERR_STAT);
dev->status = BUSY_STAT | (dev->status & ERR_STAT);
memcpy(dev->atapi_cdb, cdbufferb, dev->cdb_len);
cdrom_command(dev, dev->atapi_cdb);
return;
@@ -3040,14 +3024,14 @@ cdrom_phase_callback(cdrom_t *dev)
ret = cdrom_write_to_dma(dev);
if ((ret == 1) || (dev->drv->bus_type == CDROM_BUS_SCSI)) {
cdrom_log("CD-ROM %i: DMA data in phase done\n");
cdrom_log("CD-ROM %i: DMA data in phase done\n", dev->id);
cdrom_buf_free(dev);
cdrom_command_complete(dev);
} else if (ret == 2) {
cdrom_log("CD-ROM %i: DMA in not enabled, wait\n");
cdrom_log("CD-ROM %i: DMA in not enabled, wait\n", dev->id);
cdrom_command_bus(dev);
} else {
cdrom_log("CD-ROM %i: DMA data in phase failure\n");
cdrom_log("CD-ROM %i: DMA data in phase failure\n", dev->id);
cdrom_buf_free(dev);
}
return;
@@ -3109,17 +3093,17 @@ cdrom_read(uint8_t channel, int length)
}
if (dev->packet_status == CDROM_PHASE_DATA_IN) {
cdrom_log("CD-ROM %i: Returning: %04X (buffer position: %05i, request position: %05i)\n",
id, temp, (dev->pos - 2) & 0xffff, (dev->request_pos - 2) & 0xffff);
if ((dev->request_pos >= dev->max_transfer_len) || (dev->pos >= dev->packet_len)) {
/* Time for a DRQ. */
cdrom_log("CD-ROM %i: Issuing read callback\n", id);
cdrom_pio_request(dev, 0);
}
cdrom_log("CD-ROM %i: Returning: %02X (buffer position: %i, request position: %i)\n", id,
temp, dev->pos, dev->request_pos);
return temp;
} else {
cdrom_log("CD-ROM %i: Returning zero (buffer position: %i, request position: %i)\n", id,
dev->pos, dev->request_pos);
cdrom_log("CD-ROM %i: Returning: 0000 (buffer position: %05i, request position: %05i)\n",
id, (dev->pos - 2) & 0xffff, (dev->request_pos - 2) & 0xffff);
return 0;
}
}
@@ -3169,7 +3153,6 @@ cdrom_write(uint8_t channel, uint32_t val, int length)
return;
}
cdrom_log("CD-ROM %i: Write: %u\n", id, dev->pos);
if (dev->packet_status == CDROM_PHASE_DATA_OUT) {
if ((dev->request_pos >= dev->max_transfer_len) || (dev->pos >= dev->packet_len)) {
/* Time for a DRQ. */
@@ -3178,8 +3161,7 @@ cdrom_write(uint8_t channel, uint32_t val, int length)
return;
} else if (dev->packet_status == CDROM_PHASE_IDLE) {
if (dev->pos >= dev->cdb_len) {
cdrom_log("CD-ROM %i: Write: %u > 12\n", id, dev->pos);
dev->pos=0;
dev->pos = 0;
dev->status = BUSY_STAT;
dev->packet_status = CDROM_PHASE_COMMAND;
timer_process();
@@ -3198,10 +3180,6 @@ cdrom_global_init(void)
/* Clear the global data. */
memset(cdrom, 0x00, sizeof(cdrom));
memset(cdrom_drives, 0x00, sizeof(cdrom_drives));
/* Set all drives to NULL mode. */
/* If this even needed? cdrom_hard_reset() is called before anything
attempts to talk to it, and that intializes everything. */
}
@@ -3213,7 +3191,7 @@ cdrom_hard_reset(void)
for (c = 0; c < CDROM_NUM; c++) {
if (cdrom_drives[c].bus_type) {
cdrom_log("CDROM hard_reset drive=%d host=%02x\n", c, cdrom_drives[c].host_drive);
cdrom_log("CDROM hard_reset drive=%d\n", c);
if (!cdrom[c]) {
cdrom[c] = (cdrom_t *) malloc(sizeof(cdrom_t));

View File

@@ -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.12 2018/04/30
* Version: @(#)cdrom.h 1.0.13 2018/06/18
*
* Author: Miran Grca, <mgrca8@gmail.com>
*
@@ -82,8 +82,7 @@ typedef struct {
bus_mode; /* Bit 0 = PIO suported;
Bit 1 = DMA supportd. */
unsigned int scsi_device_id, scsi_device_lun,
sound_on;
unsigned int scsi_device_id, sound_on;
} cdrom_drive_t;
typedef struct {
@@ -139,7 +138,7 @@ extern cdrom_t *cdrom[CDROM_NUM];
extern cdrom_drive_t cdrom_drives[CDROM_NUM];
extern cdrom_image_t cdrom_image[CDROM_NUM];
extern uint8_t atapi_cdrom_drives[8];
extern uint8_t scsi_cdrom_drives[16][8];
extern uint8_t scsi_cdrom_drives[16];
#define cdrom_sense_error dev->sense[0]
#define cdrom_sense_key dev->sense[2]
@@ -178,7 +177,7 @@ extern void cdrom_request_sense_for_scsi(cdrom_t *dev, uint8_t *buffer, uint8_t
extern void cdrom_update_cdb(uint8_t *cdb, int lba_pos, int number_of_blocks);
extern void cdrom_insert(cdrom_t *dev);
extern int find_cdrom_for_scsi_id(uint8_t scsi_id, uint8_t scsi_lun);
extern int find_cdrom_for_scsi_id(uint8_t scsi_id);
extern int cdrom_read_capacity(cdrom_t *dev, uint8_t *cdb, uint8_t *buffer, uint32_t *len);
extern void cdrom_global_init(void);

View File

@@ -8,7 +8,7 @@
*
* Configuration file handler.
*
* Version: @(#)config.c 1.0.47 2018/04/29
* Version: @(#)config.c 1.0.48 2018/05/25
*
* Authors: Sarah Walker,
* Miran Grca, <mgrca8@gmail.com>
@@ -40,7 +40,6 @@
#include "disk/hdd.h"
#include "disk/hdc.h"
#include "disk/hdc_ide.h"
#include "disk/zip.h"
#include "floppy/fdd.h"
#include "floppy/fdc.h"
#include "game/gameport.h"
@@ -49,6 +48,7 @@
#include "network/network.h"
#include "scsi/scsi.h"
#include "cdrom/cdrom.h"
#include "disk/zip.h"
#include "sound/sound.h"
#include "sound/midi.h"
#include "sound/snd_dbopl.h"
@@ -559,8 +559,6 @@ load_video(void)
gfxcard = video_get_video_from_internal_name(p);
}
video_speed = config_get_int(cat, "video_speed", -1);
voodoo_enabled = !!config_get_int(cat, "voodoo", 0);
}
@@ -679,9 +677,9 @@ load_network(void)
if (p != NULL) {
if ((network_dev_to_id(p) == -1) || (network_ndev == 1)) {
if ((network_ndev == 1) && strcmp(network_host, "none")) {
ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2140);
ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2103);
} else if (network_dev_to_id(p) == -1) {
ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2141);
ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2104);
}
strcpy(network_host, "none");
@@ -786,6 +784,8 @@ load_hard_disks(void)
wchar_t *wp;
uint32_t max_spt, max_hpc, max_tracks;
uint32_t board = 0, dev = 0;
/* FIXME: Remove in a month. */
int lun;
memset(temp, '\0', sizeof(temp));
for (c=0; c<HDD_NUM; c++) {
@@ -879,21 +879,29 @@ load_hard_disks(void)
}
/* SCSI */
sprintf(temp, "hdd_%02i_scsi_location", c+1);
sprintf(temp, "hdd_%02i_scsi_id", c+1);
if (hdd[c].bus == HDD_BUS_SCSI) {
sprintf(tmp2, "%02u:%02u", c, 0);
p = config_get_string(cat, temp, tmp2);
sscanf(p, "%02i:%02i",
(int *)&hdd[c].scsi_id, (int *)&hdd[c].scsi_lun);
hdd[c].scsi_id = config_get_int(cat, temp, c);
if (hdd[c].scsi_id > 15)
hdd[c].scsi_id = 15;
if (hdd[c].scsi_lun > 7)
hdd[c].scsi_lun = 7;
} else {
} else
config_delete_var(cat, temp);
/* FIXME: Remove in a month. */
sprintf(temp, "hdd_%02i_scsi_location", c+1);
if (hdd[c].bus == HDD_BUS_SCSI) {
p = config_get_string(cat, temp, NULL);
if (p) {
sscanf(p, "%02i:%02i",
(int *)&hdd[c].scsi_id, (int *)&lun);
if (hdd[c].scsi_id > 15)
hdd[c].scsi_id = 15;
}
}
config_delete_var(cat, temp);
memset(hdd[c].fn, 0x00, sizeof(hdd[c].fn));
memset(hdd[c].prev_fn, 0x00, sizeof(hdd[c].prev_fn));
@@ -930,6 +938,10 @@ load_hard_disks(void)
sprintf(temp, "hdd_%02i_ide_channels", c+1);
config_delete_var(cat, temp);
sprintf(temp, "hdd_%02i_scsi_id", c+1);
config_delete_var(cat, temp);
/* FIXME: Remove in a month. */
sprintf(temp, "hdd_%02i_scsi_location", c+1);
config_delete_var(cat, temp);
@@ -1028,6 +1040,8 @@ load_other_removable_devices(void)
unsigned int board = 0, dev = 0;
wchar_t *wp;
int c;
/* FIXME: Remove in a month. */
int lun;
memset(temp, 0x00, sizeof(temp));
for (c=0; c<CDROM_NUM; c++) {
@@ -1061,21 +1075,28 @@ load_other_removable_devices(void)
if (cdrom_drives[c].ide_channel > 7)
cdrom_drives[c].ide_channel = 7;
} else {
sprintf(temp, "cdrom_%02i_scsi_location", c+1);
sprintf(temp, "cdrom_%02i_scsi_id", c+1);
if (cdrom_drives[c].bus_type == CDROM_BUS_SCSI) {
sprintf(tmp2, "%02u:%02u", c+2, 0);
p = config_get_string(cat, temp, tmp2);
sscanf(p, "%02u:%02u",
&cdrom_drives[c].scsi_device_id,
&cdrom_drives[c].scsi_device_lun);
cdrom_drives[c].scsi_device_id = config_get_int(cat, temp, c+2);
if (cdrom_drives[c].scsi_device_id > 15)
cdrom_drives[c].scsi_device_id = 15;
if (cdrom_drives[c].scsi_device_lun > 7)
cdrom_drives[c].scsi_device_lun = 7;
} else {
} else
config_delete_var(cat, temp);
/* FIXME: Remove in a month. */
sprintf(temp, "cdrom_%02i_scsi_location", c+1);
if (cdrom_drives[c].bus_type == CDROM_BUS_SCSI) {
p = config_get_string(cat, temp, NULL);
if (p) {
sscanf(p, "%02u:%02u",
&cdrom_drives[c].scsi_device_id, &lun);
if (cdrom_drives[c].scsi_device_id > 15)
cdrom_drives[c].scsi_device_id = 15;
}
}
config_delete_var(cat, temp);
}
sprintf(temp, "cdrom_%02i_image_path", c+1);
@@ -1118,6 +1139,10 @@ load_other_removable_devices(void)
sprintf(temp, "cdrom_%02i_ide_channel", c+1);
config_delete_var(cat, temp);
sprintf(temp, "cdrom_%02i_scsi_id", c+1);
config_delete_var(cat, temp);
/* FIXME: Remove in a month. */
sprintf(temp, "cdrom_%02i_scsi_location", c+1);
config_delete_var(cat, temp);
@@ -1154,21 +1179,28 @@ load_other_removable_devices(void)
if (zip_drives[c].ide_channel > 7)
zip_drives[c].ide_channel = 7;
} else {
sprintf(temp, "zip_%02i_scsi_location", c+1);
sprintf(temp, "zip_%02i_scsi_id", c+1);
if (zip_drives[c].bus_type == CDROM_BUS_SCSI) {
sprintf(tmp2, "%02u:%02u", c+2, 0);
p = config_get_string(cat, temp, tmp2);
sscanf(p, "%02u:%02u",
&zip_drives[c].scsi_device_id,
&zip_drives[c].scsi_device_lun);
zip_drives[c].scsi_device_id = config_get_int(cat, temp, c+2);
if (zip_drives[c].scsi_device_id > 15)
zip_drives[c].scsi_device_id = 15;
if (zip_drives[c].scsi_device_lun > 7)
zip_drives[c].scsi_device_lun = 7;
} else {
} else
config_delete_var(cat, temp);
/* FIXME: Remove in a month. */
sprintf(temp, "zip_%02i_scsi_location", c+1);
if (zip_drives[c].bus_type == CDROM_BUS_SCSI) {
p = config_get_string(cat, temp, NULL);
if (p) {
sscanf(p, "%02u:%02u",
&zip_drives[c].scsi_device_id, &lun);
if (zip_drives[c].scsi_device_id > 15)
zip_drives[c].scsi_device_id = 15;
}
}
config_delete_var(cat, temp);
}
sprintf(temp, "zip_%02i_image_path", c+1);
@@ -1204,6 +1236,10 @@ load_other_removable_devices(void)
sprintf(temp, "zip_%02i_ide_channel", c+1);
config_delete_var(cat, temp);
sprintf(temp, "zip_%02i_scsi_id", c+1);
config_delete_var(cat, temp);
/* FIXME: Remove in a month. */
sprintf(temp, "zip_%02i_scsi_location", c+1);
config_delete_var(cat, temp);
@@ -1242,7 +1278,6 @@ config_load(void)
machine = machine_get_machine_from_internal_name("ibmpc");
gfxcard = GFX_CGA;
vid_api = plat_vidapi("default");
video_speed = -1;
enable_sync = 1;
joystick_type = 7;
if (hdc_name) {
@@ -1438,11 +1473,6 @@ save_video(void)
config_set_string(cat, "gfxcard",
video_get_internal_name(video_old_to_new(gfxcard)));
if (video_speed == 3)
config_delete_var(cat, "video_speed");
else
config_set_int(cat, "video_speed", video_speed);
if (voodoo_enabled == 0)
config_delete_var(cat, "voodoo");
else
@@ -1705,7 +1735,7 @@ save_hard_disks(void)
sprintf(temp, "hdd_%02i_esdi_channel", c+1);
if (hdd_is_valid(c) && (hdd[c].bus == HDD_BUS_ESDI))
config_set_int(cat, temp, hdd[c].esdi_channel);
else
else
config_delete_var(cat, temp);
sprintf(temp, "hdd_%02i_ide_channel", c+1);
@@ -1716,18 +1746,16 @@ save_hard_disks(void)
config_set_string(cat, temp, tmp2);
}
sprintf(temp, "hdd_%02i_scsi_location", c+1);
if (! hdd_is_valid(c) || (hdd[c].bus != HDD_BUS_SCSI)) {
sprintf(temp, "hdd_%02i_scsi_id", c+1);
if (hdd_is_valid(c) && (hdd[c].bus == HDD_BUS_SCSI))
config_set_int(cat, temp, hdd[c].scsi_id);
else
config_delete_var(cat, temp);
} else {
sprintf(tmp2, "%02u:%02u", hdd[c].scsi_id, hdd[c].scsi_lun);
config_set_string(cat, temp, tmp2);
}
sprintf(temp, "hdd_%02i_fn", c+1);
if (hdd_is_valid(c) && (wcslen(hdd[c].fn) != 0))
config_set_wstring(cat, temp, hdd[c].fn);
else
else
config_delete_var(cat, temp);
}
@@ -1828,13 +1856,11 @@ save_other_removable_devices(void)
config_set_string(cat, temp, tmp2);
}
sprintf(temp, "cdrom_%02i_scsi_location", c + 1);
sprintf(temp, "cdrom_%02i_scsi_id", c + 1);
if (cdrom_drives[c].bus_type != CDROM_BUS_SCSI) {
config_delete_var(cat, temp);
} else {
sprintf(tmp2, "%02u:%02u", cdrom_drives[c].scsi_device_id,
cdrom_drives[c].scsi_device_lun);
config_set_string(cat, temp, tmp2);
config_set_int(cat, temp, cdrom_drives[c].scsi_device_id);
}
sprintf(temp, "cdrom_%02i_image_path", c + 1);
@@ -1865,13 +1891,11 @@ save_other_removable_devices(void)
config_set_string(cat, temp, tmp2);
}
sprintf(temp, "zip_%02i_scsi_location", c + 1);
sprintf(temp, "zip_%02i_scsi_id", c + 1);
if (zip_drives[c].bus_type != ZIP_BUS_SCSI) {
config_delete_var(cat, temp);
} else {
sprintf(tmp2, "%02u:%02u", zip_drives[c].scsi_device_id,
zip_drives[c].scsi_device_lun);
config_set_string(cat, temp, tmp2);
config_set_int(cat, temp, zip_drives[c].scsi_device_id);
}
sprintf(temp, "zip_%02i_image_path", c + 1);

View File

@@ -60,6 +60,7 @@ CPU cpus_8088[] = {
{"8088/12", CPU_8088, 3, 12000000, 1, 0, 0, 0, 0, 0, 0,0,0,0, 1},
{"8088/16", CPU_8088, 4, 16000000, 1, 0, 0, 0, 0, 0, 0,0,0,0, 1},
#endif
{"286/6", CPU_286, 0, 6000000, 1, 0, 0, 0, 0, 0, 2,2,2,2, 1},
{"", -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0}
};

View File

@@ -9,7 +9,7 @@
* Implementation of the IDE emulation for hard disks and ATAPI
* CD-ROM devices.
*
* Version: @(#)hdc_ide.c 1.0.46 2018/05/02
* Version: @(#)hdc_ide.c 1.0.47 2018/06/02
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -844,7 +844,7 @@ ide_set_signature(ide_t *ide)
ide->head=0;
if (ide_drive_is_zip(ide)) {
zip_set_signature(zip_id);
zip_set_signature(zip[zip_id]);
ide->secount = zip[zip_id]->phase;
ide->cylinder = zip[zip_id]->request_length;
} else if (ide_drive_is_cdrom(ide)) {
@@ -2058,7 +2058,7 @@ ide_callback(void *priv)
if (ide_drive_is_zip(ide)) {
zip[zip_id]->status = DRDY_STAT | DSC_STAT;
zip[zip_id]->error = 1;
zip_reset(zip_id);
zip_reset(zip[zip_id]);
} else if (ide_drive_is_cdrom(ide)) {
cdrom[cdrom_id]->status = DRDY_STAT | DSC_STAT;
cdrom[cdrom_id]->error = 1;
@@ -2451,7 +2451,7 @@ ide_callback(void *priv)
goto abort_cmd;
if (ide_drive_is_zip(ide))
zip_phase_callback(atapi_zip_drives[ch]);
zip_phase_callback(zip[atapi_zip_drives[ch]]);
else
cdrom_phase_callback(cdrom[atapi_cdrom_drives[ch]]);
return;

View File

@@ -8,7 +8,7 @@
*
* Common code to handle all sorts of hard disk images.
*
* Version: @(#)hdd.c 1.0.8 2018/04/24
* Version: @(#)hdd.c 1.0.9 2018/05/25
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -48,7 +48,7 @@ hdd_string_to_bus(char *str, int cdrom)
if (! strcmp(str, "mfm")) {
if (cdrom) {
no_cdrom:
ui_msgbox(MBX_ERROR, (wchar_t *)IDS_4114);
ui_msgbox(MBX_ERROR, (wchar_t *)IDS_4099);
return(0);
}

View File

@@ -8,7 +8,7 @@
*
* Definitions for the hard disk image handler.
*
* Version: @(#)hdd.h 1.0.5 2018/04/30
* Version: @(#)hdd.h 1.0.6 2018/06/09
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -84,7 +84,6 @@ typedef struct {
uint8_t xta_channel;
uint8_t ide_channel;
uint8_t scsi_id;
uint8_t scsi_lun;
uint32_t base,
spt,
@@ -104,6 +103,31 @@ extern hard_disk_t hdd[HDD_NUM];
extern unsigned int hdd_table[128][3];
typedef struct vhd_footer_t
{
uint8_t cookie[8];
uint32_t features;
uint32_t version;
uint64_t offset;
uint32_t timestamp;
uint8_t creator[4];
uint32_t creator_vers;
uint8_t creator_host_os[4];
uint64_t orig_size;
uint64_t curr_size;
struct {
uint16_t cyl;
uint8_t heads;
uint8_t spt;
} geom;
uint32_t type;
uint32_t checksum;
uint8_t uuid[16];
uint8_t saved_state;
uint8_t reserved[427];
} vhd_footer_t;
extern int hdd_init(void);
extern int hdd_string_to_bus(char *str, int cdrom);
extern char *hdd_bus_to_string(int bus, int cdrom);
@@ -124,9 +148,16 @@ extern uint8_t hdd_image_get_type(uint8_t id);
extern void hdd_image_specify(uint8_t id, uint64_t hpc, uint64_t spt);
extern void hdd_image_unload(uint8_t id, int fn_preserve);
extern void hdd_image_close(uint8_t id);
extern void hdd_image_calc_chs(uint32_t *c, uint32_t *h, uint32_t *s, uint32_t size);
extern void vhd_footer_from_bytes(vhd_footer_t *vhd, uint8_t *bytes);
extern void vhd_footer_to_bytes(uint8_t *bytes, vhd_footer_t *vhd);
extern void new_vhd_footer(vhd_footer_t **vhd);
extern void generate_vhd_checksum(vhd_footer_t *vhd);
extern int image_is_hdi(const wchar_t *s);
extern int image_is_hdx(const wchar_t *s, int check_signature);
extern int image_is_vhd(const wchar_t *s, int check_signature);
#endif /*EMU_HDD_H*/

View File

@@ -8,7 +8,7 @@
*
* Handling of hard disk image files.
*
* Version: @(#)hdd_image.c 1.0.15 2018/04/29
* Version: @(#)hdd_image.c 1.0.16 2018/06/09
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -24,11 +24,13 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/time.h>
#include <wchar.h>
#include <errno.h>
#define HAVE_STDARG_H
#include "../86box.h"
#include "../plat.h"
#include "../random.h"
#include "hdd.h"
@@ -48,6 +50,26 @@ static char empty_sector[512];
static char *empty_sector_1mb;
#define VHD_OFFSET_COOKIE 0
#define VHD_OFFSET_FEATURES 8
#define VHD_OFFSET_VERSION 12
#define VHD_OFFSET_DATA_OFFSET 16
#define VHD_OFFSET_TIMESTAMP 24
#define VHD_OFFSET_CREATOR 28
#define VHD_OFFSET_CREATOR_VERS 32
#define VHD_OFFSET_CREATOR_HOST 36
#define VHD_OFFSET_ORIG_SIZE 40
#define VHD_OFFSET_CURR_SIZE 48
#define VHD_OFFSET_GEOM_CYL 56
#define VHD_OFFSET_GEOM_HEAD 58
#define VHD_OFFSET_GEOM_SPT 59
#define VHD_OFFSET_TYPE 60
#define VHD_OFFSET_CHECKSUM 64
#define VHD_OFFSET_UUID 68
#define VHD_OFFSET_SAVED_STATE 84
#define VHD_OFFSET_RESERVED 85
#ifdef ENABLE_HDD_IMAGE_LOG
int hdd_image_do_log = ENABLE_HDD_IMAGE_LOG;
#endif
@@ -121,6 +143,303 @@ image_is_hdx(const wchar_t *s, int check_signature)
}
int
image_is_vhd(const wchar_t *s, int check_signature)
{
int len;
FILE *f;
uint64_t filelen;
uint64_t signature;
char *ws = (char *) s;
wchar_t ext[5] = { 0, 0, 0, 0, 0 };
len = wcslen(s);
if ((len < 4) || (s[0] == L'.'))
return 0;
memcpy(ext, ws + ((len - 4) << 1), 8);
if (wcscasecmp(ext, L".VHD") == 0) {
if (check_signature) {
f = plat_fopen((wchar_t *)s, L"rb");
if (!f)
return 0;
fseeko64(f, 0, SEEK_END);
filelen = ftello64(f);
fseeko64(f, -512, SEEK_END);
if (filelen < 512)
return 0;
fread(&signature, 1, 8, f);
fclose(f);
if (signature == 0x78697463656E6F63ll)
return 1;
else
return 0;
} else
return 1;
} else
return 0;
}
static uint64_t
be_to_u64(uint8_t *bytes, int start)
{
uint64_t n = ((uint64_t)bytes[start+7] << 0) |
((uint64_t)bytes[start+6] << 8) |
((uint64_t)bytes[start+5] << 16) |
((uint64_t)bytes[start+4] << 24) |
((uint64_t)bytes[start+3] << 32) |
((uint64_t)bytes[start+2] << 40) |
((uint64_t)bytes[start+1] << 48) |
((uint64_t)bytes[start] << 56);
return n;
}
static uint32_t
be_to_u32(uint8_t *bytes, int start)
{
uint32_t n = ((uint32_t)bytes[start+3] << 0) |
((uint32_t)bytes[start+2] << 8) |
((uint32_t)bytes[start+1] << 16) |
((uint32_t)bytes[start] << 24);
return n;
}
static uint16_t
be_to_u16(uint8_t *bytes, int start)
{
uint16_t n = ((uint16_t)bytes[start+1] << 0) |
((uint16_t)bytes[start] <<8);
return n;
}
static uint64_t
u64_to_be(uint64_t value, int is_be)
{
uint64_t res = 0;
if (is_be)
res = value;
else {
uint64_t mask = 0xff00000000000000;
res = ((value & (mask >> 0)) >> 56) |
((value & (mask >> 8)) >> 40) |
((value & (mask >> 16)) >> 24) |
((value & (mask >> 24)) >> 8) |
((value & (mask >> 32)) << 8) |
((value & (mask >> 40)) << 24) |
((value & (mask >> 48)) << 40) |
((value & (mask >> 56)) << 56);
}
return res;
}
static uint32_t
u32_to_be(uint32_t value, int is_be)
{
uint32_t res = 0;
if (is_be)
res = value;
else {
uint32_t mask = 0xff000000;
res = ((value & (mask >> 0)) >> 24) |
((value & (mask >> 8)) >> 8) |
((value & (mask >> 16)) << 8) |
((value & (mask >> 24)) << 24);
}
return res;
}
static uint16_t
u16_to_be(uint16_t value, int is_be)
{
uint16_t res = 0;
if (is_be)
res = value;
else
res = (value >> 8) | (value << 8);
return res;
}
static void
mk_guid(uint8_t *guid)
{
int n;
for (n = 0; n < 16; n++)
guid[n] = random_generate();
guid[6] &= 0x0F;
guid[6] |= 0x40; /* Type 4 */
guid[8] &= 0x3F;
guid[8] |= 0x80; /* Variant 1 */
}
static uint32_t
calc_vhd_timestamp()
{
time_t start_time;
time_t curr_time;
double vhd_time;
start_time = 946684800; /* 1 Jan 2000 00:00 */
curr_time = time(NULL);
vhd_time = difftime(curr_time, start_time);
return (uint32_t)vhd_time;
}
void
vhd_footer_from_bytes(vhd_footer_t *vhd, uint8_t *bytes)
{
memcpy(vhd->cookie, bytes + VHD_OFFSET_COOKIE, sizeof(vhd->cookie));
vhd->features = be_to_u32(bytes, VHD_OFFSET_FEATURES);
vhd->version = be_to_u32(bytes, VHD_OFFSET_VERSION);
vhd->offset = be_to_u64(bytes, VHD_OFFSET_DATA_OFFSET);
vhd->timestamp = be_to_u32(bytes, VHD_OFFSET_TIMESTAMP);
memcpy(vhd->creator, bytes + VHD_OFFSET_CREATOR, sizeof(vhd->creator));
vhd->creator_vers = be_to_u32(bytes, VHD_OFFSET_CREATOR_VERS);
memcpy(vhd->creator_host_os, bytes + VHD_OFFSET_CREATOR_HOST, sizeof(vhd->creator_host_os));
vhd->orig_size = be_to_u64(bytes, VHD_OFFSET_ORIG_SIZE);
vhd->curr_size = be_to_u64(bytes, VHD_OFFSET_CURR_SIZE);
vhd->geom.cyl = be_to_u16(bytes, VHD_OFFSET_GEOM_CYL);
vhd->geom.heads = bytes[VHD_OFFSET_GEOM_HEAD];
vhd->geom.spt = bytes[VHD_OFFSET_GEOM_SPT];
vhd->type = be_to_u32(bytes, VHD_OFFSET_TYPE);
vhd->checksum = be_to_u32(bytes, VHD_OFFSET_CHECKSUM);
memcpy(vhd->uuid, bytes + VHD_OFFSET_UUID, sizeof(vhd->uuid)); /* TODO: handle UUID's properly */
vhd->saved_state = bytes[VHD_OFFSET_SAVED_STATE];
memcpy(vhd->reserved, bytes + VHD_OFFSET_RESERVED, sizeof(vhd->reserved));
}
void
vhd_footer_to_bytes(uint8_t *bytes, vhd_footer_t *vhd)
{
/* Quick endian check */
int is_be = 0;
uint8_t e = 1;
uint8_t *ep = &e;
uint16_t u16;
uint32_t u32;
uint64_t u64;
if (ep[0] == 0)
is_be = 1;
memcpy(bytes + VHD_OFFSET_COOKIE, vhd->cookie, sizeof(vhd->cookie));
u32 = u32_to_be(vhd->features, is_be);
memcpy(bytes + VHD_OFFSET_FEATURES, &u32, sizeof(vhd->features));
u32 = u32_to_be(vhd->version, is_be);
memcpy(bytes + VHD_OFFSET_VERSION, &u32, sizeof(vhd->version));
u64 = u64_to_be(vhd->offset, is_be);
memcpy(bytes + VHD_OFFSET_DATA_OFFSET, &u64, sizeof(vhd->offset));
u32 = u32_to_be(vhd->timestamp, is_be);
memcpy(bytes + VHD_OFFSET_TIMESTAMP, &u32, sizeof(vhd->timestamp));
memcpy(bytes + VHD_OFFSET_CREATOR, vhd->creator, sizeof(vhd->creator));
u32 = u32_to_be(vhd->creator_vers, is_be);
memcpy(bytes + VHD_OFFSET_CREATOR_VERS, &u32, sizeof(vhd->creator_vers));
memcpy(bytes + VHD_OFFSET_CREATOR_HOST, vhd->creator_host_os, sizeof(vhd->creator_host_os));
u64 = u64_to_be(vhd->orig_size, is_be);
memcpy(bytes + VHD_OFFSET_ORIG_SIZE, &u64, sizeof(vhd->orig_size));
u64 = u64_to_be(vhd->curr_size, is_be);
memcpy(bytes + VHD_OFFSET_CURR_SIZE, &u64, sizeof(vhd->curr_size));
u16 = u16_to_be(vhd->geom.cyl, is_be);
memcpy(bytes + VHD_OFFSET_GEOM_CYL, &u16, sizeof(vhd->geom.cyl));
memcpy(bytes + VHD_OFFSET_GEOM_HEAD, &(vhd->geom.heads), sizeof(vhd->geom.heads));
memcpy(bytes + VHD_OFFSET_GEOM_SPT, &(vhd->geom.spt), sizeof(vhd->geom.spt));
u32 = u32_to_be(vhd->type, is_be);
memcpy(bytes + VHD_OFFSET_TYPE, &u32, sizeof(vhd->type));
u32 = u32_to_be(vhd->checksum, is_be);
memcpy(bytes + VHD_OFFSET_CHECKSUM, &u32, sizeof(vhd->checksum));
memcpy(bytes + VHD_OFFSET_UUID, vhd->uuid, sizeof(vhd->uuid));
memcpy(bytes + VHD_OFFSET_SAVED_STATE, &(vhd->saved_state), sizeof(vhd->saved_state));
memcpy(bytes + VHD_OFFSET_RESERVED, vhd->reserved, sizeof(vhd->reserved));
}
void
new_vhd_footer(vhd_footer_t **vhd)
{
uint8_t cookie[8] = {'c', 'o', 'n', 'e', 'c', 't', 'i', 'x'};
uint8_t creator[4] = {'8', '6', 'b', 'x'};
uint8_t cr_host_os[4] = {'W', 'i', '2', 'k'};
if (*vhd == NULL)
*vhd = (vhd_footer_t *) malloc(sizeof(vhd_footer_t));
memcpy((*vhd)->cookie, cookie, 8);
(*vhd)->features = 0x00000002;
(*vhd)->version = 0x00010000;
(*vhd)->offset = 0xffffffffffffffff; /* fixed disk */
(*vhd)->timestamp = calc_vhd_timestamp();
memcpy((*vhd)->creator, creator, 4);
(*vhd)->creator_vers = 0x00010000;
memcpy((*vhd)->creator_host_os, cr_host_os, 4);
(*vhd)->type = 2; /* fixed disk */
mk_guid((*vhd)->uuid);
(*vhd)->saved_state = 0;
memset((*vhd)->reserved, 0, 427);
}
void
generate_vhd_checksum(vhd_footer_t *vhd)
{
uint32_t chk = 0;
int i;
for (i = 0; i < sizeof(vhd_footer_t); i++) {
/* We don't include the checksum field in the checksum */
if ((i < VHD_OFFSET_CHECKSUM) || (i >= VHD_OFFSET_UUID))
chk += ((uint8_t*)vhd)[i];
}
vhd->checksum = ~chk;
}
void
hdd_image_calc_chs(uint32_t *c, uint32_t *h, uint32_t *s, uint32_t size)
{
/* Calculate the geometry from size (in MB), using the algorithm provided in
"Virtual Hard Disk Image Format Specification, Appendix: CHS Calculation" */
uint64_t ts = ((uint64_t) size) << 11LL;
uint32_t spt, heads, cyl, cth;
if (ts > 65535 * 16 * 255)
ts = 65535 * 16 * 255;
if (ts >= 65535 * 16 * 63) {
spt = 255;
heads = 16;
cth = ts / spt;
} else {
spt = 17;
cth = ts / spt;
heads = (cth +1023) / 1024;
if (heads < 4)
heads = 4;
if ((cth >= (heads * 1024)) || (heads > 16)) {
spt = 31;
heads = 16;
cth = ts / spt;
}
if (cth >= (heads * 1024)) {
spt = 63;
heads = 16;
cth = ts / spt;
}
}
cyl = cth / heads;
*c = cyl;
*h = heads;
*s = spt;
}
static int
prepare_new_hard_disk(uint8_t id, uint64_t full_size)
{
@@ -182,10 +501,12 @@ hdd_image_load(int id)
uint64_t signature = 0xD778A82044445459ll;
uint64_t full_size = 0;
uint64_t spt = 0, hpc = 0, tracks = 0;
int c;
int c, ret;
uint64_t s = 0;
wchar_t *fn = hdd[id].fn;
int is_hdx[2] = { 0, 0 };
int is_vhd[2] = { 0, 0 };
vhd_footer_t *vft = NULL;
memset(empty_sector, 0, sizeof(empty_sector));
@@ -202,6 +523,9 @@ hdd_image_load(int id)
is_hdx[0] = image_is_hdx(fn, 0);
is_hdx[1] = image_is_hdx(fn, 1);
is_vhd[0] = image_is_vhd(fn, 0);
is_vhd[1] = image_is_vhd(fn, 1);
hdd_images[id].pos = 0;
/* Try to open existing hard disk image */
@@ -268,7 +592,29 @@ hdd_image_load(int id)
((uint64_t) hdd[id].hpc) *
((uint64_t) hdd[id].tracks) << 9LL;
return prepare_new_hard_disk(id, full_size);
ret = prepare_new_hard_disk(id, full_size);
if (is_vhd[0]) {
/* VHD image. */
/* Generate new footer. */
empty_sector_1mb = (char *) malloc(512);
new_vhd_footer(&vft);
vft->orig_size = vft->curr_size = full_size;
vft->geom.cyl = tracks;
vft->geom.heads = hpc;
vft->geom.spt = spt;
generate_vhd_checksum(vft);
memset(empty_sector_1mb, 0, 512);
vhd_footer_to_bytes((uint8_t *) empty_sector_1mb, vft);
fwrite(empty_sector_1mb, 1, 512, hdd_images[id].file);
free(vft);
vft = NULL;
free(empty_sector_1mb);
empty_sector_1mb = NULL;
hdd_images[id].type = 3;
}
return ret;
} else {
/* Failed for another reason */
hdd_image_log("Failed for another reason\n");
@@ -322,6 +668,40 @@ hdd_image_load(int id)
fread(&(hdd[id].at_spt), 1, 4, hdd_images[id].file);
fread(&(hdd[id].at_hpc), 1, 4, hdd_images[id].file);
hdd_images[id].type = 2;
} else if (is_vhd[1]) {
empty_sector_1mb = (char *) malloc(512);
memset(empty_sector_1mb, 0, 512);
fseeko64(hdd_images[id].file, -512, SEEK_END);
fread(empty_sector_1mb, 1, 512, hdd_images[id].file);
new_vhd_footer(&vft);
vhd_footer_from_bytes(vft, (uint8_t *) empty_sector_1mb);
if (vft->type != 2) {
/* VHD is not fixed size */
hdd_image_log("VHD: Image is not fixed size\n");
free(vft);
vft = NULL;
free(empty_sector_1mb);
empty_sector_1mb = NULL;
fclose(hdd_images[id].file);
hdd_images[id].file = NULL;
memset(hdd[id].fn, 0, sizeof(hdd[id].fn));
return 0;
}
full_size = vft->orig_size;
hdd[id].tracks = vft->geom.cyl;
hdd[id].hpc = vft->geom.heads;
hdd[id].spt = vft->geom.spt;
free(vft);
vft = NULL;
free(empty_sector_1mb);
empty_sector_1mb = NULL;
hdd_images[id].type = 3;
/* If we're here, this means there is a valid VHD footer in the
image, which means that by definition, all valid sectors
are there. */
hdd_images[id].last_sector = (uint32_t) (full_size >> 9) - 1;
hdd_images[id].loaded = 1;
return 1;
} else {
full_size = ((uint64_t) hdd[id].spt) *
((uint64_t) hdd[id].hpc) *

File diff suppressed because it is too large Load Diff

View File

@@ -48,9 +48,32 @@ enum {
typedef struct {
uint8_t previous_command, error,
features, status,
phase, *buffer,
unsigned int bus_type; /* 0 = ATAPI, 1 = SCSI */
uint8_t ide_channel,
bus_mode; /* Bit 0 = PIO suported;
Bit 1 = DMA supportd. */
unsigned int scsi_device_id, is_250;
wchar_t image_path[1024],
prev_image_path[1024];
int read_only, ui_writeprot;
uint32_t medium_size, base;
FILE *f;
} zip_drive_t;
typedef struct {
mode_sense_pages_t ms_pages_saved;
zip_drive_t *drv;
uint8_t previous_command,
error, features,
status, phase,
id, *buffer,
atapi_cdb[16],
current_cdb[16],
sense[256];
@@ -77,35 +100,16 @@ typedef struct {
uint64_t current_page_code;
} zip_t;
typedef struct {
unsigned int bus_type; /* 0 = ATAPI, 1 = SCSI */
uint8_t ide_channel,
bus_mode; /* Bit 0 = PIO suported;
Bit 1 = DMA supportd. */
unsigned int scsi_device_id, scsi_device_lun,
is_250;
wchar_t image_path[1024],
prev_image_path[1024];
int read_only, ui_writeprot;
uint32_t medium_size, base;
FILE *f;
} zip_drive_t;
extern zip_t *zip[ZIP_NUM];
extern zip_drive_t zip_drives[ZIP_NUM];
extern uint8_t atapi_zip_drives[8];
extern uint8_t scsi_zip_drives[16][8];
extern uint8_t scsi_zip_drives[16];
#define zip_sense_error zip[id]->sense[0]
#define zip_sense_key zip[id]->sense[2]
#define zip_asc zip[id]->sense[12]
#define zip_ascq zip[id]->sense[13]
#define zip_sense_error dev->sense[0]
#define zip_sense_key dev->sense[2]
#define zip_asc dev->sense[12]
#define zip_ascq dev->sense[13]
#ifdef __cplusplus
@@ -116,37 +120,32 @@ extern int (*ide_bus_master_read)(int channel, uint8_t *data, int transfer_lengt
extern int (*ide_bus_master_write)(int channel, uint8_t *data, int transfer_length, void *priv);
extern void (*ide_bus_master_set_irq)(int channel, void *priv);
extern void *ide_bus_master_priv[2];
extern void ioctl_close(uint8_t id);
extern uint32_t zip_mode_sense_get_channel(uint8_t id, int channel);
extern uint32_t zip_mode_sense_get_volume(uint8_t id, int channel);
extern void build_atapi_zip_map(void);
extern void build_scsi_zip_map(void);
extern int zip_ZIP_PHASE_to_scsi(uint8_t id);
extern int zip_atapi_phase_to_scsi(uint8_t id);
extern void zip_command(uint8_t id, uint8_t *cdb);
extern void zip_phase_callback(uint8_t id);
extern int zip_ZIP_PHASE_to_scsi(zip_t *dev);
extern int zip_atapi_phase_to_scsi(zip_t *dev);
extern void zip_command(zip_t *dev, uint8_t *cdb);
extern void zip_phase_callback(zip_t *dev);
extern uint32_t zip_read(uint8_t channel, int length);
extern void zip_write(uint8_t channel, uint32_t val, int length);
extern void zip_close(uint8_t id);
extern void zip_disk_reload(uint8_t id);
extern void zip_reset(uint8_t id);
extern void zip_set_signature(int id);
extern void zip_request_sense_for_scsi(uint8_t id, uint8_t *buffer, uint8_t alloc_length);
extern void zip_disk_close(zip_t *dev);
extern void zip_disk_reload(zip_t *dev);
extern void zip_reset(zip_t *dev);
extern void zip_set_signature(zip_t *dev);
extern void zip_request_sense_for_scsi(zip_t *dev, uint8_t *buffer, uint8_t alloc_length);
extern void zip_update_cdb(uint8_t *cdb, int lba_pos, int number_of_blocks);
extern void zip_insert(uint8_t id);
extern void zip_insert(zip_t *dev);
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 int find_zip_for_scsi_id(uint8_t scsi_id);
extern int zip_read_capacity(zip_t *dev, uint8_t *cdb, uint8_t *buffer, uint32_t *len);
extern void zip_global_init(void);
extern void zip_hard_reset(void);
extern int zip_load(uint8_t id, wchar_t *fn);
extern void zip_destroy_drives(void);
extern void zip_close(uint8_t id);
extern int zip_load(zip_t *dev, wchar_t *fn);
extern void zip_close();
#ifdef __cplusplus
}

View File

@@ -9,7 +9,7 @@
* Implementation of the NEC uPD-765 and compatible floppy disk
* controller.
*
* Version: @(#)fdc.c 1.0.8 2018/05/09
* Version: @(#)fdc.c 1.0.9 2018/06/12
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Sarah Walker, <tommowalker@tommowalker.co.uk>
@@ -1710,10 +1710,8 @@ fdc_error(fdc_t *fdc, int st5, int st6)
fdc->fintr = 0;
fdc->stat = 0xD0;
fdc->st0 = fdc->res[4] = 0x40 | (fdd_get_head(real_drive(fdc, fdc->drive)) ? 4 : 0) | fdc->rw_drive;
if (fdc->head && !fdd_is_double_sided(real_drive(fdc, fdc->drive))) {
pclog("Head 1 on 1-sided drive\n");
if (fdc->head && !fdd_is_double_sided(real_drive(fdc, fdc->drive)))
fdc->st0 |= 0x08;
}
fdc->res[5] = st5;
fdc->res[6] = st6;
fdc_log("FDC Error: %02X %02X %02X\n", fdc->res[4], fdc->res[5], fdc->res[6]);

View File

@@ -10,7 +10,7 @@
* data in the form of FM/MFM-encoded transitions) which also
* forms the core of the emulator's floppy disk emulation.
*
* Version: @(#)fdd_86f.c 1.0.9 2018/05/06
* Version: @(#)fdd_86f.c 1.0.10 2018/06/12
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -1435,9 +1435,9 @@ d86f_read_sector_id(int drive, int side, int match)
dev->state = STATE_IDLE;
fdc_finishread(d86f_fdc);
fdc_headercrcerror(d86f_fdc);
} else if (dev->state == STATE_0A_READ_ID) {
} else if (dev->state == STATE_0A_READ_ID)
dev->state--;
} else {
else {
dev->error_condition |= 1; /* Mark that there was an ID CRC error. */
dev->state++;
}
@@ -1549,6 +1549,7 @@ d86f_read_sector_data(int drive, int side)
if (dev->data_find.bits_obtained) {
if (!(dev->data_find.bits_obtained & 15)) {
/* We've got a byte. */
d86f_log("86F: We've got a byte.\n");
if (dev->data_find.bytes_obtained < sector_len) {
data = decodefm(drive, dev->last_word[side]);
if (dev->state == STATE_11_SCAN_DATA) {
@@ -1559,33 +1560,18 @@ d86f_read_sector_data(int drive, int side)
if (dev->data_find.bytes_obtained < d86f_get_data_len(drive)) {
if (dev->state != STATE_16_VERIFY_DATA) {
read_status = fdc_data(d86f_fdc, data);
if (read_status == -1) {
if (read_status == -1)
dev->dma_over++;
}
}
}
}
fdd_calccrc(data, &(dev->calc_crc));
} else if (dev->data_find.bytes_obtained < crc_pos) {
} else if (dev->data_find.bytes_obtained < crc_pos)
dev->track_crc.bytes[(dev->data_find.bytes_obtained - sector_len) ^ 1] = decodefm(drive, dev->last_word[side]);
}
dev->data_find.bytes_obtained++;
if (dev->data_find.bytes_obtained == (crc_pos + fdc_get_gap(d86f_fdc))) {
/* We've got the data. */
if (dev->dma_over > 1) {
dev->data_find.sync_marks = dev->data_find.bits_obtained = dev->data_find.bytes_obtained = 0;
dev->error_condition = 0;
dev->state = STATE_IDLE;
fdc_finishread(d86f_fdc);
fdc_overrun(d86f_fdc);
d86f_get_bit(drive, side);
dev->data_find.bits_obtained++;
return;
}
if ((dev->calc_crc.word != dev->track_crc.word) && (dev->state != STATE_02_READ_DATA)) {
d86f_log("86F: Data CRC error: %04X != %04X (%08X)\n", dev->track_crc.word, dev->calc_crc.word, dev->last_sector.dword);
dev->data_find.sync_marks = dev->data_find.bits_obtained = dev->data_find.bytes_obtained = 0;
@@ -1600,15 +1586,14 @@ d86f_read_sector_data(int drive, int side)
fdc_track_finishread(d86f_fdc, dev->error_condition);
} else {
/* CRC is valid. */
d86f_log("86F: Data CRC OK: %04X != %04X (%08X)\n", dev->track_crc.word, dev->calc_crc.word, dev->last_sector.dword);
dev->data_find.sync_marks = dev->data_find.bits_obtained = dev->data_find.bytes_obtained = 0;
dev->error_condition = 0;
if (dev->state == STATE_11_SCAN_DATA) {
dev->state = STATE_IDLE;
dev->state = STATE_IDLE;
if (dev->state == STATE_11_SCAN_DATA)
fdc_sector_finishcompare(d86f_fdc, (dev->satisfying_bytes == ((128 << ((uint32_t) dev->last_sector.id.n)) - 1)) ? 1 : 0);
} else {
dev->state = STATE_IDLE;
else
fdc_sector_finishread(d86f_fdc);
}
}
}
}
@@ -1704,17 +1689,6 @@ d86f_write_sector_data(int drive, int side, int mfm, uint16_t am)
dev->data_find.bytes_obtained++;
if (dev->data_find.bytes_obtained == (crc_pos + fdc_get_gap(d86f_fdc))) {
if (dev->dma_over > 1) {
dev->data_find.sync_marks = dev->data_find.bits_obtained = dev->data_find.bytes_obtained = 0;
dev->error_condition = 0;
dev->state = STATE_IDLE;
fdc_finishread(d86f_fdc);
fdc_overrun(d86f_fdc);
dev->data_find.bits_obtained++;
return;
}
/* We've written the data. */
dev->data_find.sync_marks = dev->data_find.bits_obtained = dev->data_find.bytes_obtained = 0;
dev->error_condition = 0;
@@ -2143,15 +2117,6 @@ d86f_turbo_read(int drive, int side)
}
}
if (dev->dma_over > 1) {
dev->data_find.sync_marks = dev->data_find.bits_obtained = dev->data_find.bytes_obtained = 0;
dev->error_condition = 0;
dev->state = STATE_IDLE;
fdc_finishread(d86f_fdc);
fdc_overrun(d86f_fdc);
return;
}
if (dev->turbo_pos >= (128 << dev->last_sector.id.n)) {
/* CRC is valid. */
dev->data_find.sync_marks = dev->data_find.bits_obtained = dev->data_find.bytes_obtained = 0;
@@ -2573,7 +2538,8 @@ d86f_poll(int drive)
fdc_wrongcylinder(d86f_fdc);
else
fdc_nosector(d86f_fdc);
}
} else
fdc_nosector(d86f_fdc);
} else {
fdc_noidam(d86f_fdc);
}
@@ -3191,7 +3157,8 @@ d86f_readsector(int drive, int sector, int track, int side, int rate, int sector
int ret = 0;
ret = d86f_common_command(drive, sector, track, side, rate, sector_size);
if (! ret) return;
if (! ret)
return;
if (sector == SECTOR_FIRST)
dev->state = STATE_02_SPIN_TO_INDEX;

View File

@@ -10,7 +10,7 @@
* word 0 - base address
* word 1 - bits 1-15 = byte count, bit 31 = end of transfer
*
* Version: @(#)intel_piix.c 1.0.16 2018/05/11
* Version: @(#)intel_piix.c 1.0.17 2018/06/02
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -829,7 +829,7 @@ piix_reset(void *p)
}
for (i = 0; i < ZIP_NUM; i++) {
if (zip_drives[i].bus_type == ZIP_BUS_ATAPI)
zip_reset(i);
zip_reset(zip[i]);
}
}

View File

@@ -8,7 +8,7 @@
*
* Intel 8042 (AT keyboard controller) emulation.
*
* Version: @(#)keyboard_at.c 1.0.36 2018/05/12
* Version: @(#)keyboard_at.c 1.0.37 2018/05/25
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -44,6 +44,7 @@
#include "sound/snd_speaker.h"
#include "video/video.h"
#include "keyboard.h"
#include "mouse.h"
#define STAT_PARITY 0x80
@@ -121,6 +122,8 @@ typedef struct {
uint8_t (*write60_ven)(void *p, uint8_t val);
uint8_t (*write64_ven)(void *p, uint8_t val);
int64_t timeout;
} atkbd_t;
@@ -1001,6 +1004,20 @@ kbd_pulse_poll(void *p)
}
static void
kbd_timeout_poll(void *p)
{
atkbd_t *kbd = (atkbd_t *) p;
kbd->key_wantdata = 0;
kbd->want60 = 0;
if (mouse_p)
mouse_clear_data(mouse_p);
kbd->timeout = 0LL;
}
static void
kbd_keyboard_set(atkbd_t *kbd, uint8_t enable)
{
@@ -1074,6 +1091,7 @@ kbd_write64_generic(void *p, uint8_t val)
if ((kbd->flags & KBC_TYPE_MASK) >= KBC_TYPE_PS2_1) {
kbdlog("ATkbd: write mouse output buffer\n");
kbd->want60 = 1;
kbd->timeout = 25000LL * TIMER_USEC;
return 0;
}
break;
@@ -1081,6 +1099,7 @@ kbd_write64_generic(void *p, uint8_t val)
if ((kbd->flags & KBC_TYPE_MASK) >= KBC_TYPE_PS2_1) {
kbdlog("ATkbd: write to mouse\n");
kbd->want60 = 1;
kbd->timeout = 25000LL * TIMER_USEC;
return 0;
}
break;
@@ -1122,6 +1141,7 @@ kbd_write60_ami(void *p, uint8_t val)
if (kbd->secr_phase == 1) {
kbd->mem_addr = val;
kbd->want60 = 1;
kbd->timeout = 25000LL * TIMER_USEC;
kbd->secr_phase = 2;
} else if (kbd->secr_phase == 2) {
kbd->mem[kbd->mem_addr] = val;
@@ -1164,6 +1184,7 @@ kbd_write64_ami(void *p, uint8_t val)
case 0x5c: case 0x5d: case 0x5e: case 0x5f:
kbdlog("AMI - alias write to register %08X\n", kbd->command);
kbd->want60 = 1;
kbd->timeout = 25000LL * TIMER_USEC;
return 0;
case 0xa1: /*AMI - get controller version*/
kbdlog("AMI - get controller version\n");
@@ -1229,6 +1250,7 @@ kbd_write64_ami(void *p, uint8_t val)
case 0xaf: /*Set extended controller RAM*/
kbdlog("ATkbd: set extended controller RAM\n");
kbd->want60 = 1;
kbd->timeout = 25000LL * TIMER_USEC;
kbd->secr_phase = 1;
return 0;
case 0xb0: case 0xb1: case 0xb2: case 0xb3:
@@ -1245,9 +1267,10 @@ kbd_write64_ami(void *p, uint8_t val)
return 0;
case 0xb8: case 0xb9: case 0xba: case 0xbb:
/*Set keyboard controller line P10-P13 (input port bits 0-3) high*/
if (!PCI || (val > 0xb9))
if (!PCI || (val > 0xb9)) {
kbd->input_port |= (1 << (val & 0x03));
kbd_adddata(0x00);
kbd_adddata(0x00);
}
return 0;
case 0xbc: case 0xbd:
/*Set keyboard controller line P22-P23 (output port bits 2-3) high*/
@@ -1274,6 +1297,7 @@ kbd_write64_ami(void *p, uint8_t val)
case 0xcb: /*AMI - set keyboard mode*/
kbdlog("AMI - set keyboard mode\n");
kbd->want60 = 1;
kbd->timeout = 25000LL * TIMER_USEC;
return 0;
case 0xef: /*??? - sent by AMI486*/
kbdlog("??? - sent by AMI486\n");
@@ -1343,6 +1367,7 @@ kbd_write64_quadtel(void *p, uint8_t val)
case 0xcf: /*??? - sent by MegaPC BIOS*/
kbdlog("??? - sent by MegaPC BIOS\n");
kbd->want60 = 1;
kbd->timeout = 25000LL * TIMER_USEC;
return 0;
}
@@ -1394,6 +1419,7 @@ kbd_write64_toshiba(void *p, uint8_t val)
return 0;
case 0xb6: /* T3100e: Set colour / mono byte */
kbd->want60 = 1;
kbd->timeout = 25000LL * TIMER_USEC;
return 0;
case 0xb7: /* T3100e: Emulate PS/2 keyboard - not implemented */
case 0xb8: /* T3100e: Emulate AT keyboard - not implemented */
@@ -1547,6 +1573,7 @@ kbd_write(uint16_t port, uint8_t val, void *priv)
case 0xed: /*Set/reset LEDs*/
kbdlog("ATkbd: set/reset leds\n");
kbd->key_wantdata = 1;
kbd->timeout = 25000LL * TIMER_USEC;
kbd_adddata_keyboard(0xfa);
break;
@@ -1562,6 +1589,7 @@ kbd_write(uint16_t port, uint8_t val, void *priv)
case 0xf0: /*Get/set scan code set*/
kbdlog("ATkbd: scan code set\n");
kbd->key_wantdata = 1;
kbd->timeout = 25000LL * TIMER_USEC;
kbd_adddata_keyboard(0xfa);
break;
@@ -1576,6 +1604,7 @@ kbd_write(uint16_t port, uint8_t val, void *priv)
case 0xf3: /*Set typematic rate/delay*/
kbdlog("ATkbd: set typematic rate/delay\n");
kbd->key_wantdata = 1;
kbd->timeout = 25000LL * TIMER_USEC;
kbd_adddata_keyboard(0xfa);
break;
@@ -1696,6 +1725,7 @@ kbd_write(uint16_t port, uint8_t val, void *priv)
case 0x78: case 0x79: case 0x7a: case 0x7b:
case 0x7c: case 0x7d: case 0x7e: case 0x7f:
kbd->want60 = 1;
kbd->timeout = 25000LL * TIMER_USEC;
break;
case 0xaa: /*Self-test*/
@@ -1753,11 +1783,13 @@ kbd_write(uint16_t port, uint8_t val, void *priv)
case 0xd1: /*Write output port*/
// kbdlog("ATkbd: write output port\n");
kbd->want60 = 1;
kbd->timeout = 25000LL * TIMER_USEC;
break;
case 0xd2: /*Write keyboard output buffer*/
kbdlog("ATkbd: write keyboard output buffer\n");
kbd->want60 = 1;
kbd->timeout = 25000LL * TIMER_USEC;
break;
case 0xdd: /* Disable A20 Address Line */
@@ -1864,6 +1896,7 @@ kbd_reset(void *priv)
kbd->last_irq = 0;
kbd->secr_phase = 0;
kbd->key_wantdata = 0;
kbd->timeout = 0LL;
keyboard_mode = 0x02 | kbd->dtrans;
@@ -1909,6 +1942,9 @@ kbd_init(const device_t *info)
timer_add(kbd_pulse_poll,
&kbd->pulse_cb, &kbd->pulse_cb, kbd);
timer_add(kbd_timeout_poll,
&kbd->timeout, &kbd->timeout, kbd);
kbd->write60_ven = NULL;
kbd->write64_ven = NULL;

View File

@@ -10,7 +10,7 @@
*
* NOTE: FIXME: Strings 2176 and 2193 are same.
*
* Version: @(#)language.h 1.0.7 2018/03/07
* Version: @(#)language.h 1.0.8 2018/05/25
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*
@@ -25,17 +25,17 @@
#define IDS_2049 2049 // "86Box Error"
#define IDS_2050 2050 // "86Box Fatal Error"
#define IDS_2051 2051 // "This will reset 86Box.."
#define IDS_2052 2052 // "DirectDraw Screenshot Error"
#define IDS_2053 2053 // "Invalid number of sectors.."
#define IDS_2054 2054 // "Invalid number of heads.."
#define IDS_2055 2055 // "Invalid number of cylinders.."
#define IDS_2052 2052 // "Use CTRL+ALT+PAGE DOWN.."
#define IDS_2053 2053 // "Speed"
#define IDS_2054 2054 // "ZIP %i (%03i): %ls"
#define IDS_2055 2055 // "ZIP images (*.IM?)\0*.IM..."
#define IDS_2056 2056 // "No usable ROM images found!"
#define IDS_2057 2057 // "(empty)"
#define IDS_2058 2058 // "(host drive %c:)"
#define IDS_2058 2058 // "ZIP images (*.IM?)\0*.IM..."
#define IDS_2059 2059 // "(Turbo)"
#define IDS_2060 2060 // "On"
#define IDS_2061 2061 // "Off"
#define IDS_2062 2062 // "86Box was unable to find any.."
#define IDS_2062 2062 // "All floppy images (*.DSK..."
#define IDS_2063 2063 // "Configured ROM set not avai.."
#define IDS_2064 2064 // "Configured video BIOS not.."
#define IDS_2065 2065 // "Machine"
@@ -49,114 +49,54 @@
#define IDS_2073 2073 // "Floppy drives"
#define IDS_2074 2074 // "Other removable devices"
#define IDS_2075 2075 // "CD-ROM images (*.ISO;*.CU.."
#define IDS_2076 2076 // "Host CD/DVD Drive (%c:)"
#define IDS_2076 2076 // "Surface-based images (*.8.."
#define IDS_2077 2077 // "Click to capture mouse"
#define IDS_2078 2078 // "Press F12-F8 to release mouse"
#define IDS_2079 2079 // "Press F12-F8 or middle button.."
#define IDS_2080 2080 // "Drive"
#define IDS_2081 2081 // "Location"
#define IDS_2080 2080 // "E&xport to 86F..."
#define IDS_2081 2081 // "Unable to initialize Flui.."
#define IDS_2082 2082 // "Bus"
#define IDS_2083 2083 // "File"
#define IDS_2084 2084 // "C"
#define IDS_2085 2085 // "H"
#define IDS_2086 2086 // "S"
#define IDS_2087 2087 // "MB"
#define IDS_2088 2088 // "Unable to create bitmap file: %s"
#define IDS_2089 2089 // "Enabled"
#define IDS_2090 2090 // "Mute"
#define IDS_2091 2091 // "Type"
#define IDS_2092 2092 // "Bus"
#define IDS_2093 2093 // "DMA"
#define IDS_2088 2088 // "Check BPB"
#define IDS_2089 2089 // "&Image..."
#define IDS_2090 2090 // "&Reload previous image"
#define IDS_2091 2091 // "E&mpty"
#define IDS_2092 2092 // "&Mute"
#define IDS_2093 2093 // "E&ject"
#define IDS_2094 2094 // "KB"
#define IDS_2095 2095 // "Neither DirectDraw nor Dire.."
#define IDS_2096 2096 // "Slave"
#define IDS_2097 2097 // "SCSI (ID %s, LUN %s)"
#define IDS_2098 2098 // "Adapter Type"
#define IDS_2099 2099 // "Base Address"
#define IDS_2100 2100 // "IRQ"
#define IDS_2101 2101 // "8-bit DMA"
#define IDS_2102 2102 // "16-bit DMA"
#define IDS_2103 2103 // "BIOS"
#define IDS_2104 2104 // "Network Type"
#define IDS_2105 2105 // "Surround Module"
#define IDS_2106 2106 // "MPU-401 Base Address"
#define IDS_2107 2107 // "Use CTRL+ALT+PAGE DOWN.."
#define IDS_2108 2108 // "On-board RAM"
#define IDS_2109 2109 // "Memory Size"
#define IDS_2110 2110 // "Display Type"
#define IDS_2111 2111 // "RGB"
#define IDS_2112 2112 // "Composite"
#define IDS_2113 2113 // "Composite Type"
#define IDS_2114 2114 // "Old"
#define IDS_2115 2115 // "New"
#define IDS_2116 2116 // "RGB Type"
#define IDS_2117 2117 // "Color"
#define IDS_2118 2118 // "Monochrome (Green)"
#define IDS_2119 2119 // "Monochrome (Amber)"
#define IDS_2120 2120 // "Monochrome (Gray)"
#define IDS_2121 2121 // "Color (no brown)"
#define IDS_2122 2122 // "Monochrome (Default)"
#define IDS_2123 2123 // "Snow Emulation"
#define IDS_2124 2124 // "Bilinear Filtering"
#define IDS_2125 2125 // "Dithering"
#define IDS_2126 2126 // "Framebuffer Memory Size"
#define IDS_2127 2127 // "Texture Memory Size"
#define IDS_2128 2128 // "Screen Filter"
#define IDS_2129 2129 // "Render Threads"
#define IDS_2130 2130 // "Recompiler"
#define IDS_2131 2131 // "System Default"
#define IDS_2132 2132 // "%i Wait state(s)"
#define IDS_2133 2133 // "8-bit"
#define IDS_2134 2134 // "Slow 16-bit"
#define IDS_2135 2135 // "Fast 16-bit"
#define IDS_2136 2136 // "Slow VLB/PCI"
#define IDS_2137 2137 // "Mid VLB/PCI"
#define IDS_2138 2138 // "Fast VLB/PCI"
#define IDS_2139 2139 // "PCap failed to set up.."
#define IDS_2140 2140 // "No PCap devices found"
#define IDS_2141 2141 // "Invalid PCap device"
#define IDS_2142 2142 // "&Notify disk change"
#define IDS_2143 2143 // "Type"
#define IDS_2144 2144 // "Standard 2-button joystick(s)"
#define IDS_2145 2145 // "Standard 4-button joystick"
#define IDS_2146 2146 // "Standard 6-button joystick"
#define IDS_2147 2147 // "Standard 8-button joystick"
#define IDS_2148 2148 // "CH Flightstick Pro"
#define IDS_2149 2149 // "Microsoft SideWinder Pad"
#define IDS_2150 2150 // "Thrustmaster Flight Cont.."
#define IDS_2151 2151 // "Disabled"
#define IDS_2152 2152 // "None"
#define IDS_2153 2153 // "Unable to load Accelerators"
#define IDS_2154 2154 // "Unable to register Raw Input"
#define IDS_2155 2155 // "IRQ %i"
#define IDS_2156 2156 // "%" PRIu64
#define IDS_2157 2157 // "%" PRIu64 " MB (CHS: %".."
#define IDS_2158 2158 // "Floppy %i (%s): %ls"
#define IDS_2159 2159 // "All floppy images (*.0??;*.."
#define IDS_2160 2160 // "Configuration files (*.CF.."
#define IDS_2161 2161 // "&New image..."
#define IDS_2162 2162 // "&Existing image..."
#define IDS_2163 2163 // "Existing image (&Write-pr..."
#define IDS_2164 2164 // "E&ject"
#define IDS_2165 2165 // "&Mute"
#define IDS_2166 2166 // "E&mpty"
#define IDS_2167 2167 // "&Reload previous image"
#define IDS_2168 2168 // "&Image..."
#define IDS_2169 2169 // "Image (&Write-protected)..."
#define IDS_2170 2170 // "Check BPB"
#define IDS_2171 2171 // "Unable to initialize Flui.."
#define IDS_2172 2172 // "E&xport to 86F..."
#define IDS_2173 2173 // "Surface-based images (*.8.."
#define IDS_2174 2174 // "All floppy images (*.DSK..."
#define IDS_2175 2175 // "ZIP images (*.IM?)\0*.IM..."
#define IDS_2176 2176 // "ZIP images (*.IM?)\0*.IM..."
#define IDS_2177 2177 // "ZIP %i (%03i): %ls"
#define IDS_2178 2178 // "Speed"
#define IDS_2096 2096 // "&New image..."
#define IDS_2097 2097 // "&Existing image..."
#define IDS_2098 2098 // "Existing image (&Write-pr..."
#define IDS_2099 2099 // "Default"
#define IDS_2100 2100 // "%i Wait state(s)"
#define IDS_2101 2101 // "Type"
#define IDS_2102 2102 // "PCap failed to set up.."
#define IDS_2103 2103 // "No PCap devices found"
#define IDS_2104 2104 // "Invalid PCap device"
#define IDS_2105 2105 // "Standard 2-button joystick(s)"
#define IDS_2106 2106 // "Standard 4-button joystick"
#define IDS_2107 2107 // "Standard 6-button joystick"
#define IDS_2108 2108 // "Standard 8-button joystick"
#define IDS_2109 2109 // "CH Flightstick Pro"
#define IDS_2110 2110 // "Microsoft SideWinder Pad"
#define IDS_2111 2111 // "Thrustmaster Flight Cont.."
#define IDS_2112 2112 // "None"
#define IDS_2113 2113 // "Unable to load Accelerators"
#define IDS_2114 2114 // "Unable to register Raw Input"
#define IDS_2115 2115 // "%u"
#define IDS_2116 2116 // "%u MB (CHS: %i, %i, %i)"
#define IDS_2117 2117 // "Floppy %i (%s): %ls"
#define IDS_2118 2118 // "All floppy images (*.0??;*.."
#define IDS_4096 4096 // "Hard disk (%s)"
#define IDS_4097 4097 // "%01i:%01i"
#define IDS_4098 4098 // "%i"
#define IDS_4099 4099 // "Disabled"
#define IDS_4099 4099 // "MFM/RLL or ESDI CD-ROM driv.."
#define IDS_4100 4100 // "Custom..."
#define IDS_4101 4101 // "Custom (large)..."
#define IDS_4102 4102 // "Add New Hard Disk"
@@ -171,8 +111,6 @@
#define IDS_4111 4111 // "This image exists and will be.."
#define IDS_4112 4112 // "Please enter a valid file name"
#define IDS_4113 4113 // "Remember to partition and fo.."
#define IDS_4114 4114 // "MFM/RLL or ESDI CD-ROM driv.."
#define IDS_4115 4115 // "Removable disk %i (SCSI): %ls"
#define IDS_4352 4352 // "MFM/RLL"
#define IDS_4353 4353 // "XT IDE"
@@ -193,17 +131,17 @@
#define IDS_5120 5120 // "CD-ROM %i (%s): %s"
#define IDS_5376 5376 // "Disabled"
#define IDS_5377 5377 // "<Reserved>"
#define IDS_5378 5378 // "<Reserved>"
#define IDS_5379 5379 // "<Reserved>"
#define IDS_5377 5377 // <Reserved>
#define IDS_5378 5378 // <Reserved>
#define IDS_5379 5379 // <Reserved>
#define IDS_5380 5380 // "ATAPI (PIO-only)"
#define IDS_5381 5381 // "ATAPI (PIO and DMA)"
#define IDS_5382 5382 // "SCSI"
#define IDS_5632 5632 // "Disabled"
#define IDS_5633 5633 // "<Reserved>"
#define IDS_5634 5634 // "<Reserved>"
#define IDS_5635 5635 // "<Reserved>"
#define IDS_5633 5633 // <Reserved>
#define IDS_5634 5634 // <Reserved>
#define IDS_5635 5635 // <Reserved>
#define IDS_5636 5636 // "ATAPI (PIO-only) (%01i:%01i)"
#define IDS_5637 5637 // "ATAPI (PIO and DMA) (%01i:%01i)"
#define IDS_5638 5638 // "SCSI (%02i:%02i)"
@@ -232,9 +170,9 @@
#define IDS_LANG_ENUS IDS_7168
#define STR_NUM_2048 131
#define STR_NUM_2048 71
#define STR_NUM_3072 11
#define STR_NUM_4096 20
#define STR_NUM_4096 18
#define STR_NUM_4352 7
#define STR_NUM_4608 7
#define STR_NUM_5120 1

View File

@@ -1,358 +0,0 @@
/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
*
* This file is part of the 86Box distribution.
*
* Implementation of the Intel 430FX PCISet chip.
*
* Version: @(#)m_at_430fx.c 1.0.17 2018/04/26
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
*
* Copyright 2008-2018 Sarah Walker.
* Copyright 2016-2018 Miran Grca.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include "../86box.h"
#include "../mem.h"
#include "../memregs.h"
#include "../rom.h"
#include "../pci.h"
#include "../device.h"
#include "../keyboard.h"
#include "../piix.h"
#include "../intel_flash.h"
#include "../sio.h"
#include "../video/video.h"
#include "../video/vid_cl54xx.h"
#include "../video/vid_s3.h"
#include "machine.h"
typedef struct
{
uint8_t regs[256];
} i430fx_t;
static void
i430fx_map(uint32_t addr, uint32_t size, int state)
{
switch (state & 3) {
case 0:
mem_set_mem_state(addr, size, MEM_READ_EXTERNAL | MEM_WRITE_EXTERNAL);
break;
case 1:
mem_set_mem_state(addr, size, MEM_READ_INTERNAL | MEM_WRITE_EXTERNAL);
break;
case 2:
mem_set_mem_state(addr, size, MEM_READ_EXTERNAL | MEM_WRITE_INTERNAL);
break;
case 3:
mem_set_mem_state(addr, size, MEM_READ_INTERNAL | MEM_WRITE_INTERNAL);
break;
}
flushmmucache_nopc();
}
static void
i430fx_write(int func, int addr, uint8_t val, void *priv)
{
i430fx_t *dev = (i430fx_t *) priv;
if (func)
return;
if ((addr >= 0x10) && (addr < 0x4f))
return;
switch (addr) {
case 0x00: case 0x01: case 0x02: case 0x03:
case 0x08: case 0x09: case 0x0a: case 0x0b:
case 0x0c: case 0x0e:
return;
case 0x04: /*Command register*/
val &= 0x02;
val |= 0x04;
break;
case 0x05:
val = 0;
break;
case 0x06: /*Status*/
val = 0;
break;
case 0x07:
val = 0x02;
break;
case 0x59: /*PAM0*/
if ((dev->regs[0x59] ^ val) & 0xf0) {
i430fx_map(0xf0000, 0x10000, val >> 4);
shadowbios = (val & 0x10);
}
break;
case 0x5a: /*PAM1*/
if ((dev->regs[0x5a] ^ val) & 0x0f)
i430fx_map(0xc0000, 0x04000, val & 0xf);
if ((dev->regs[0x5a] ^ val) & 0xf0)
i430fx_map(0xc4000, 0x04000, val >> 4);
break;
case 0x5b: /*PAM2*/
if ((dev->regs[0x5b] ^ val) & 0x0f)
i430fx_map(0xc8000, 0x04000, val & 0xf);
if ((dev->regs[0x5b] ^ val) & 0xf0)
i430fx_map(0xcc000, 0x04000, val >> 4);
break;
case 0x5c: /*PAM3*/
if ((dev->regs[0x5c] ^ val) & 0x0f)
i430fx_map(0xd0000, 0x04000, val & 0xf);
if ((dev->regs[0x5c] ^ val) & 0xf0)
i430fx_map(0xd4000, 0x04000, val >> 4);
break;
case 0x5d: /*PAM4*/
if ((dev->regs[0x5d] ^ val) & 0x0f)
i430fx_map(0xd8000, 0x04000, val & 0xf);
if ((dev->regs[0x5d] ^ val) & 0xf0)
i430fx_map(0xdc000, 0x04000, val >> 4);
break;
case 0x5e: /*PAM5*/
if ((dev->regs[0x5e] ^ val) & 0x0f)
i430fx_map(0xe0000, 0x04000, val & 0xf);
if ((dev->regs[0x5e] ^ val) & 0xf0)
i430fx_map(0xe4000, 0x04000, val >> 4);
break;
case 0x5f: /*PAM6*/
if ((dev->regs[0x5f] ^ val) & 0x0f)
i430fx_map(0xe8000, 0x04000, val & 0xf);
if ((dev->regs[0x5f] ^ val) & 0xf0)
i430fx_map(0xec000, 0x04000, val >> 4);
break;
case 0x72: /*SMRAM*/
if ((dev->regs[0x72] ^ val) & 0x48)
i430fx_map(0xa0000, 0x20000, ((val & 0x48) == 0x48) ? 3 : 0);
break;
}
dev->regs[addr] = val;
}
static uint8_t
i430fx_read(int func, int addr, void *priv)
{
i430fx_t *dev = (i430fx_t *) priv;
if (func)
return 0xff;
return dev->regs[addr];
}
static void
i430fx_reset(void *priv)
{
i430fx_write(0, 0x59, 0x00, priv);
i430fx_write(0, 0x72, 0x02, priv);
}
static void
i430fx_close(void *p)
{
i430fx_t *i430fx = (i430fx_t *)p;
free(i430fx);
}
static void
*i430fx_init(const device_t *info)
{
i430fx_t *i430fx = (i430fx_t *) malloc(sizeof(i430fx_t));
memset(i430fx, 0, sizeof(i430fx_t));
i430fx->regs[0x00] = 0x86; i430fx->regs[0x01] = 0x80; /*Intel*/
i430fx->regs[0x02] = 0x2d; i430fx->regs[0x03] = 0x12; /*SB82437FX-66*/
i430fx->regs[0x04] = 0x06; i430fx->regs[0x05] = 0x00;
i430fx->regs[0x06] = 0x00; i430fx->regs[0x07] = 0x82;
i430fx->regs[0x08] = 0x00; /*A0 stepping*/
i430fx->regs[0x09] = 0x00; i430fx->regs[0x0a] = 0x00; i430fx->regs[0x0b] = 0x06;
i430fx->regs[0x52] = 0x40; /*256kb PLB cache*/
i430fx->regs[0x57] = 0x01;
i430fx->regs[0x60] = i430fx->regs[0x61] = i430fx->regs[0x62] = i430fx->regs[0x63] = 0x02;
i430fx->regs[0x64] = 0x02;
i430fx->regs[0x72] = 0x02;
pci_add_card(0, i430fx_read, i430fx_write, i430fx);
return i430fx;
}
const device_t i430fx_device =
{
"Intel SB82437FX-66",
DEVICE_PCI,
0,
i430fx_init,
i430fx_close,
i430fx_reset,
NULL,
NULL,
NULL,
NULL
};
void
machine_at_p54tp4xe_init(const machine_t *model)
{
machine_at_common_init(model);
device_add(&keyboard_ps2_pci_device);
memregs_init();
pci_init(PCI_CONFIG_TYPE_1);
pci_register_slot(0x00, PCI_CARD_SPECIAL, 0, 0, 0, 0);
pci_register_slot(0x0C, PCI_CARD_NORMAL, 1, 2, 3, 4);
pci_register_slot(0x0B, PCI_CARD_NORMAL, 2, 3, 4, 1);
pci_register_slot(0x0A, PCI_CARD_NORMAL, 3, 4, 1, 2);
pci_register_slot(0x09, PCI_CARD_NORMAL, 4, 1, 2, 3);
pci_register_slot(0x07, PCI_CARD_SPECIAL, 0, 0, 0, 0);
device_add(&i430fx_device);
device_add(&piix_device);
fdc37c665_init();
device_add(&intel_flash_bxt_device);
}
void
machine_at_endeavor_init(const machine_t *model)
{
machine_at_common_init(model);
device_add(&keyboard_ps2_ami_pci_device);
memregs_init();
pci_init(PCI_CONFIG_TYPE_1);
pci_register_slot(0x00, PCI_CARD_SPECIAL, 0, 0, 0, 0);
pci_register_slot(0x08, PCI_CARD_ONBOARD, 4, 0, 0, 0);
pci_register_slot(0x0D, PCI_CARD_NORMAL, 1, 2, 3, 4);
pci_register_slot(0x0E, PCI_CARD_NORMAL, 2, 3, 4, 1);
pci_register_slot(0x0F, PCI_CARD_NORMAL, 3, 4, 1, 2);
pci_register_slot(0x10, PCI_CARD_NORMAL, 4, 1, 2, 3);
pci_register_slot(0x07, PCI_CARD_SPECIAL, 0, 0, 0, 0);
device_add(&i430fx_device);
device_add(&piix_device);
pc87306_init();
device_add(&intel_flash_bxt_ami_device);
if (gfxcard == GFX_INTERNAL)
device_add(&s3_phoenix_trio64_onboard_pci_device);
}
const device_t *
at_endeavor_get_device(void)
{
return &s3_phoenix_trio64_onboard_pci_device;
}
void
machine_at_zappa_init(const machine_t *model)
{
machine_at_common_init(model);
device_add(&keyboard_ps2_ami_pci_device);
memregs_init();
pci_init(PCI_CONFIG_TYPE_1);
pci_register_slot(0x00, PCI_CARD_SPECIAL, 0, 0, 0, 0);
pci_register_slot(0x0D, PCI_CARD_NORMAL, 1, 2, 3, 4);
pci_register_slot(0x0E, PCI_CARD_NORMAL, 3, 4, 1, 2);
pci_register_slot(0x0F, PCI_CARD_NORMAL, 2, 3, 4, 1);
pci_register_slot(0x07, PCI_CARD_SPECIAL, 0, 0, 0, 0);
device_add(&i430fx_device);
device_add(&piix_device);
pc87306_init();
device_add(&intel_flash_bxt_ami_device);
}
void
machine_at_mb500n_init(const machine_t *model)
{
machine_at_common_init(model);
device_add(&keyboard_ps2_pci_device);
pci_init(PCI_CONFIG_TYPE_1);
pci_register_slot(0x00, PCI_CARD_SPECIAL, 0, 0, 0, 0);
pci_register_slot(0x14, PCI_CARD_NORMAL, 1, 2, 3, 4);
pci_register_slot(0x13, PCI_CARD_NORMAL, 2, 3, 4, 1);
pci_register_slot(0x12, PCI_CARD_NORMAL, 3, 4, 1, 2);
pci_register_slot(0x11, PCI_CARD_NORMAL, 4, 1, 2, 3);
pci_register_slot(0x07, PCI_CARD_SPECIAL, 0, 0, 0, 0);
device_add(&i430fx_device);
device_add(&piix_device);
fdc37c665_init();
device_add(&intel_flash_bxt_device);
}
void
machine_at_president_init(const machine_t *model)
{
machine_at_common_init(model);
device_add(&keyboard_ps2_pci_device);
memregs_init();
pci_init(PCI_CONFIG_TYPE_1);
pci_register_slot(0x00, PCI_CARD_SPECIAL, 0, 0, 0, 0);
pci_register_slot(0x08, PCI_CARD_NORMAL, 1, 2, 3, 4);
pci_register_slot(0x09, PCI_CARD_NORMAL, 2, 3, 4, 1);
pci_register_slot(0x0A, PCI_CARD_NORMAL, 3, 4, 1, 2);
pci_register_slot(0x0B, PCI_CARD_NORMAL, 4, 1, 2, 3);
pci_register_slot(0x07, PCI_CARD_SPECIAL, 0, 0, 0, 0);
device_add(&i430fx_device);
device_add(&piix_device);
w83877f_init();
device_add(&intel_flash_bxt_device);
}
void
machine_at_thor_init(const machine_t *model)
{
machine_at_common_init(model);
device_add(&keyboard_ps2_ami_pci_device);
memregs_init();
pci_init(PCI_CONFIG_TYPE_1);
pci_register_slot(0x00, PCI_CARD_SPECIAL, 0, 0, 0, 0);
pci_register_slot(0x08, PCI_CARD_ONBOARD, 4, 0, 0, 0);
pci_register_slot(0x0D, PCI_CARD_NORMAL, 1, 2, 3, 4);
pci_register_slot(0x0E, PCI_CARD_NORMAL, 2, 3, 4, 1);
pci_register_slot(0x0F, PCI_CARD_NORMAL, 3, 4, 2, 1);
pci_register_slot(0x10, PCI_CARD_NORMAL, 4, 3, 2, 1);
pci_register_slot(0x07, PCI_CARD_SPECIAL, 0, 0, 0, 0);
device_add(&i430fx_device);
device_add(&piix_device);
pc87306_init();
device_add(&intel_flash_bxt_ami_device);
}

View File

@@ -1,403 +0,0 @@
/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
*
* This file is part of the 86Box distribution.
*
* Implementation of the Intel 430HX PCISet chip.
*
* Version: @(#)m_at_430hx.c 1.0.13 2018/04/26
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
*
* Copyright 2008-2018 Sarah Walker.
* Copyright 2016-2018 Miran Grca.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include "../86box.h"
#include "../io.h"
#include "../mem.h"
#include "../memregs.h"
#include "../pci.h"
#include "../device.h"
#include "../keyboard.h"
#include "../piix.h"
#include "../intel_flash.h"
#include "../sio.h"
#include "machine.h"
typedef struct
{
uint8_t regs[256];
} i430hx_t;
typedef struct
{
int index;
} acerm3a_t;
static void i430hx_map(uint32_t addr, uint32_t size, int state)
{
switch (state & 3) {
case 0:
mem_set_mem_state(addr, size, MEM_READ_EXTERNAL | MEM_WRITE_EXTERNAL);
break;
case 1:
mem_set_mem_state(addr, size, MEM_READ_INTERNAL | MEM_WRITE_EXTERNAL);
break;
case 2:
mem_set_mem_state(addr, size, MEM_READ_EXTERNAL | MEM_WRITE_INTERNAL);
break;
case 3:
mem_set_mem_state(addr, size, MEM_READ_INTERNAL | MEM_WRITE_INTERNAL);
break;
}
flushmmucache_nopc();
}
static void
i430hx_write(int func, int addr, uint8_t val, void *priv)
{
i430hx_t *dev = (i430hx_t *) priv;
if (func)
return;
if ((addr >= 0x10) && (addr < 0x4f))
return;
switch (addr) {
case 0x00: case 0x01: case 0x02: case 0x03:
case 0x08: case 0x09: case 0x0a: case 0x0b:
case 0x0c: case 0x0e:
return;
case 0x04: /*Command register*/
val &= 0x02;
val |= 0x04;
break;
case 0x05:
val = 0;
break;
case 0x06: /*Status*/
val = 0;
break;
case 0x07:
val &= 0x80;
val |= 0x02;
break;
case 0x59: /*PAM0*/
if ((dev->regs[0x59] ^ val) & 0xf0) {
i430hx_map(0xf0000, 0x10000, val >> 4);
shadowbios = (val & 0x10);
}
break;
case 0x5a: /*PAM1*/
if ((dev->regs[0x5a] ^ val) & 0x0f)
i430hx_map(0xc0000, 0x04000, val & 0xf);
if ((dev->regs[0x5a] ^ val) & 0xf0)
i430hx_map(0xc4000, 0x04000, val >> 4);
break;
case 0x5b: /*PAM2*/
if ((dev->regs[0x5b] ^ val) & 0x0f)
i430hx_map(0xc8000, 0x04000, val & 0xf);
if ((dev->regs[0x5b] ^ val) & 0xf0)
i430hx_map(0xcc000, 0x04000, val >> 4);
break;
case 0x5c: /*PAM3*/
if ((dev->regs[0x5c] ^ val) & 0x0f)
i430hx_map(0xd0000, 0x04000, val & 0xf);
if ((dev->regs[0x5c] ^ val) & 0xf0)
i430hx_map(0xd4000, 0x04000, val >> 4);
break;
case 0x5d: /*PAM4*/
if ((dev->regs[0x5d] ^ val) & 0x0f)
i430hx_map(0xd8000, 0x04000, val & 0xf);
if ((dev->regs[0x5d] ^ val) & 0xf0)
i430hx_map(0xdc000, 0x04000, val >> 4);
break;
case 0x5e: /*PAM5*/
if ((dev->regs[0x5e] ^ val) & 0x0f)
i430hx_map(0xe0000, 0x04000, val & 0xf);
if ((dev->regs[0x5e] ^ val) & 0xf0)
i430hx_map(0xe4000, 0x04000, val >> 4);
break;
case 0x5f: /*PAM6*/
if ((dev->regs[0x5f] ^ val) & 0x0f)
i430hx_map(0xe8000, 0x04000, val & 0xf);
if ((dev->regs[0x5f] ^ val) & 0xf0)
i430hx_map(0xec000, 0x04000, val >> 4);
break;
case 0x72: /*SMRAM*/
if ((dev->regs[0x72] ^ val) & 0x48)
i430hx_map(0xa0000, 0x20000, ((val & 0x48) == 0x48) ? 3 : 0);
break;
}
dev->regs[addr] = val;
}
static uint8_t
i430hx_read(int func, int addr, void *priv)
{
i430hx_t *dev = (i430hx_t *) priv;
if (func)
return 0xff;
return dev->regs[addr];
}
static void
i430hx_reset(void *priv)
{
i430hx_write(0, 0x59, 0x00, priv);
i430hx_write(0, 0x72, 0x02, priv);
}
static void
i430hx_close(void *p)
{
i430hx_t *i430hx = (i430hx_t *)p;
free(i430hx);
}
static void
*i430hx_init(const device_t *info)
{
i430hx_t *i430hx = (i430hx_t *) malloc(sizeof(i430hx_t));
memset(i430hx, 0, sizeof(i430hx_t));
i430hx->regs[0x00] = 0x86; i430hx->regs[0x01] = 0x80; /*Intel*/
i430hx->regs[0x02] = 0x50; i430hx->regs[0x03] = 0x12; /*82439HX*/
i430hx->regs[0x04] = 0x06; i430hx->regs[0x05] = 0x00;
i430hx->regs[0x06] = 0x00; i430hx->regs[0x07] = 0x02;
i430hx->regs[0x08] = 0x00; /*A0 stepping*/
i430hx->regs[0x09] = 0x00; i430hx->regs[0x0a] = 0x00; i430hx->regs[0x0b] = 0x06;
i430hx->regs[0x51] = 0x20;
i430hx->regs[0x52] = 0xB5; /*512kb cache*/
i430hx->regs[0x59] = 0x40;
i430hx->regs[0x5A] = i430hx->regs[0x5B] = i430hx->regs[0x5C] = i430hx->regs[0x5D] = 0x44;
i430hx->regs[0x5E] = i430hx->regs[0x5F] = 0x44;
i430hx->regs[0x56] = 0x52; /*DRAM control*/
i430hx->regs[0x57] = 0x01;
i430hx->regs[0x60] = i430hx->regs[0x61] = i430hx->regs[0x62] = i430hx->regs[0x63] = 0x02;
i430hx->regs[0x64] = i430hx->regs[0x65] = i430hx->regs[0x66] = i430hx->regs[0x67] = 0x02;
i430hx->regs[0x68] = 0x11;
i430hx->regs[0x72] = 0x02;
pci_add_card(0, i430hx_read, i430hx_write, i430hx);
return i430hx;
}
const device_t i430hx_device =
{
"Intel 82439HX",
DEVICE_PCI,
0,
i430hx_init,
i430hx_close,
i430hx_reset,
NULL,
NULL,
NULL,
NULL
};
static void
acerm3a_out(uint16_t port, uint8_t val, void *p)
{
acerm3a_t *dev = (acerm3a_t *) p;
if (port == 0xea)
dev->index = val;
}
static uint8_t
acerm3a_in(uint16_t port, void *p)
{
acerm3a_t *dev = (acerm3a_t *) p;
if (port == 0xeb) {
switch (dev->index) {
case 2:
return 0xfd;
}
}
return 0xff;
}
static void
acerm3a_close(void *p)
{
acerm3a_t *dev = (acerm3a_t *)p;
free(dev);
}
static void
*acerm3a_init(const device_t *info)
{
acerm3a_t *acerm3a = (acerm3a_t *) malloc(sizeof(acerm3a_t));
memset(acerm3a, 0, sizeof(acerm3a_t));
io_sethandler(0x00ea, 0x0002, acerm3a_in, NULL, NULL, acerm3a_out, NULL, NULL, acerm3a);
return acerm3a;
}
const device_t acerm3a_device =
{
"Acer M3A Register",
0,
0,
acerm3a_init,
acerm3a_close,
NULL,
NULL,
NULL,
NULL,
NULL
};
void
machine_at_acerm3a_init(const machine_t *model)
{
machine_at_common_init(model);
device_add(&keyboard_ps2_pci_device);
powermate_memregs_init();
pci_init(PCI_CONFIG_TYPE_1);
pci_register_slot(0x00, PCI_CARD_SPECIAL, 0, 0, 0, 0);
pci_register_slot(0x07, PCI_CARD_SPECIAL, 0, 0, 0, 0);
pci_register_slot(0x0C, PCI_CARD_NORMAL, 1, 2, 3, 4);
pci_register_slot(0x0D, PCI_CARD_NORMAL, 2, 3, 4, 1);
pci_register_slot(0x0E, PCI_CARD_NORMAL, 3, 4, 1, 2);
pci_register_slot(0x1F, PCI_CARD_NORMAL, 4, 1, 2, 3);
pci_register_slot(0x10, PCI_CARD_ONBOARD, 4, 0, 0, 0);
device_add(&i430hx_device);
device_add(&piix3_device);
fdc37c932fr_init();
device_add(&acerm3a_device);
device_add(&intel_flash_bxb_device);
}
void
machine_at_acerv35n_init(const machine_t *model)
{
machine_at_common_init(model);
device_add(&keyboard_ps2_pci_device);
powermate_memregs_init();
pci_init(PCI_CONFIG_TYPE_1);
pci_register_slot(0x00, PCI_CARD_SPECIAL, 0, 0, 0, 0);
pci_register_slot(0x07, PCI_CARD_SPECIAL, 0, 0, 0, 0);
pci_register_slot(0x11, PCI_CARD_NORMAL, 1, 2, 3, 4);
pci_register_slot(0x12, PCI_CARD_NORMAL, 2, 3, 4, 1);
pci_register_slot(0x13, PCI_CARD_NORMAL, 3, 4, 1, 2);
pci_register_slot(0x14, PCI_CARD_NORMAL, 4, 1, 2, 3);
pci_register_slot(0x0D, PCI_CARD_NORMAL, 1, 2, 3, 4);
device_add(&i430hx_device);
device_add(&piix3_device);
fdc37c932fr_init();
device_add(&acerm3a_device);
device_add(&intel_flash_bxb_device);
}
void
machine_at_ap53_init(const machine_t *model)
{
machine_at_common_init(model);
device_add(&keyboard_ps2_ami_pci_device);
memregs_init();
powermate_memregs_init();
pci_init(PCI_CONFIG_TYPE_1);
pci_register_slot(0x00, PCI_CARD_SPECIAL, 0, 0, 0, 0);
pci_register_slot(0x11, PCI_CARD_NORMAL, 1, 2, 3, 4);
pci_register_slot(0x12, PCI_CARD_NORMAL, 2, 3, 4, 1);
pci_register_slot(0x13, PCI_CARD_NORMAL, 3, 4, 1, 2);
pci_register_slot(0x14, PCI_CARD_NORMAL, 4, 1, 2, 3);
pci_register_slot(0x07, PCI_CARD_SPECIAL, 0, 0, 0, 0);
pci_register_slot(0x06, PCI_CARD_ONBOARD, 1, 2, 3, 4);
device_add(&i430hx_device);
device_add(&piix3_device);
fdc37c669_init();
device_add(&intel_flash_bxt_device);
}
void
machine_at_p55t2p4_init(const machine_t *model)
{
machine_at_common_init(model);
device_add(&keyboard_ps2_pci_device);
memregs_init();
pci_init(PCI_CONFIG_TYPE_1);
pci_register_slot(0x00, PCI_CARD_SPECIAL, 0, 0, 0, 0);
pci_register_slot(0x0C, PCI_CARD_NORMAL, 1, 2, 3, 4);
pci_register_slot(0x0B, PCI_CARD_NORMAL, 2, 3, 4, 1);
pci_register_slot(0x0A, PCI_CARD_NORMAL, 3, 4, 1, 2);
pci_register_slot(0x09, PCI_CARD_NORMAL, 4, 1, 2, 3);
pci_register_slot(0x07, PCI_CARD_SPECIAL, 0, 0, 0, 0);
device_add(&i430hx_device);
device_add(&piix3_device);
w83877f_init();
device_add(&intel_flash_bxt_device);
}
void
machine_at_p55t2s_init(const machine_t *model)
{
machine_at_common_init(model);
device_add(&keyboard_ps2_ami_pci_device);
memregs_init();
powermate_memregs_init();
pci_init(PCI_CONFIG_TYPE_1);
pci_register_slot(0x00, PCI_CARD_SPECIAL, 0, 0, 0, 0);
pci_register_slot(0x12, PCI_CARD_NORMAL, 1, 2, 3, 4);
pci_register_slot(0x13, PCI_CARD_NORMAL, 4, 1, 2, 3);
pci_register_slot(0x14, PCI_CARD_NORMAL, 3, 4, 1, 2);
pci_register_slot(0x11, PCI_CARD_NORMAL, 2, 3, 4, 1);
pci_register_slot(0x07, PCI_CARD_SPECIAL, 0, 0, 0, 0);
device_add(&i430hx_device);
device_add(&piix3_device);
pc87306_init();
device_add(&intel_flash_bxt_device);
}

View File

@@ -1,272 +0,0 @@
/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
*
* This file is part of the 86Box distribution.
*
* Implementation of the Intel 430LX and 430NX PCISet chips.
*
* Version: @(#)m_at_430lx_nx.c 1.0.12 2018/04/26
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
*
* Copyright 2008-2018 Sarah Walker.
* Copyright 2016-2018 Miran Grca.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include "../86box.h"
#include "../mem.h"
#include "../memregs.h"
#include "../rom.h"
#include "../pci.h"
#include "../device.h"
#include "../keyboard.h"
#include "../intel.h"
#include "../intel_flash.h"
#include "../intel_sio.h"
#include "../sio.h"
#include "machine.h"
typedef struct
{
uint8_t regs[256];
} i430lx_nx_t;
static void
i430lx_nx_map(uint32_t addr, uint32_t size, int state)
{
switch (state & 3) {
case 0:
mem_set_mem_state(addr, size, MEM_READ_EXTERNAL | MEM_WRITE_EXTERNAL);
break;
case 1:
mem_set_mem_state(addr, size, MEM_READ_INTERNAL | MEM_WRITE_EXTERNAL);
break;
case 2:
mem_set_mem_state(addr, size, MEM_READ_EXTERNAL | MEM_WRITE_INTERNAL);
break;
case 3:
mem_set_mem_state(addr, size, MEM_READ_INTERNAL | MEM_WRITE_INTERNAL);
break;
}
flushmmucache_nopc();
}
static void
i430lx_nx_write(int func, int addr, uint8_t val, void *priv)
{
i430lx_nx_t *dev = (i430lx_nx_t *) priv;
if (func)
return;
if ((addr >= 0x10) && (addr < 0x4f))
return;
switch (addr) {
case 0x00: case 0x01: case 0x02: case 0x03:
case 0x08: case 0x09: case 0x0a: case 0x0b:
case 0x0c: case 0x0e:
return;
case 0x04: /*Command register*/
val &= 0x42;
val |= 0x04;
break;
case 0x05:
val &= 0x01;
break;
case 0x06: /*Status*/
val = 0;
break;
case 0x07:
val = 0x02;
break;
case 0x59: /*PAM0*/
if ((dev->regs[0x59] ^ val) & 0xf0) {
i430lx_nx_map(0xf0000, 0x10000, val >> 4);
shadowbios = (val & 0x10);
}
break;
case 0x5a: /*PAM1*/
if ((dev->regs[0x5a] ^ val) & 0x0f)
i430lx_nx_map(0xc0000, 0x04000, val & 0xf);
if ((dev->regs[0x5a] ^ val) & 0xf0)
i430lx_nx_map(0xc4000, 0x04000, val >> 4);
break;
case 0x5b: /*PAM2*/
if ((dev->regs[0x5b] ^ val) & 0x0f)
i430lx_nx_map(0xc8000, 0x04000, val & 0xf);
if ((dev->regs[0x5b] ^ val) & 0xf0)
i430lx_nx_map(0xcc000, 0x04000, val >> 4);
break;
case 0x5c: /*PAM3*/
if ((dev->regs[0x5c] ^ val) & 0x0f)
i430lx_nx_map(0xd0000, 0x04000, val & 0xf);
if ((dev->regs[0x5c] ^ val) & 0xf0)
i430lx_nx_map(0xd4000, 0x04000, val >> 4);
break;
case 0x5d: /*PAM4*/
if ((dev->regs[0x5d] ^ val) & 0x0f)
i430lx_nx_map(0xd8000, 0x04000, val & 0xf);
if ((dev->regs[0x5d] ^ val) & 0xf0)
i430lx_nx_map(0xdc000, 0x04000, val >> 4);
break;
case 0x5e: /*PAM5*/
if ((dev->regs[0x5e] ^ val) & 0x0f)
i430lx_nx_map(0xe0000, 0x04000, val & 0xf);
if ((dev->regs[0x5e] ^ val) & 0xf0)
i430lx_nx_map(0xe4000, 0x04000, val >> 4);
break;
case 0x5f: /*PAM6*/
if ((dev->regs[0x5f] ^ val) & 0x0f)
i430lx_nx_map(0xe8000, 0x04000, val & 0xf);
if ((dev->regs[0x5f] ^ val) & 0xf0)
i430lx_nx_map(0xec000, 0x04000, val >> 4);
break;
}
dev->regs[addr] = val;
}
static uint8_t
i430lx_nx_read(int func, int addr, void *priv)
{
i430lx_nx_t *dev = (i430lx_nx_t *) priv;
if (func)
return 0xff;
return dev->regs[addr];
}
static void
i430lx_nx_reset(void *priv)
{
i430lx_nx_write(0, 0x59, 0x00, priv);
}
static void
i430lx_nx_close(void *p)
{
i430lx_nx_t *i430lx_nx = (i430lx_nx_t *)p;
free(i430lx_nx);
}
static void
*i430lx_nx_init(const device_t *info)
{
i430lx_nx_t *i430lx_nx = (i430lx_nx_t *) malloc(sizeof(i430lx_nx_t));
memset(i430lx_nx, 0, sizeof(i430lx_nx_t));
i430lx_nx->regs[0x00] = 0x86; i430lx_nx->regs[0x01] = 0x80; /*Intel*/
i430lx_nx->regs[0x02] = 0xa3; i430lx_nx->regs[0x03] = 0x04; /*82434LX/NX*/
i430lx_nx->regs[0x04] = 0x06; i430lx_nx->regs[0x05] = 0x00;
i430lx_nx->regs[0x06] = 0x00; i430lx_nx->regs[0x07] = 0x02;
i430lx_nx->regs[0x09] = 0x00; i430lx_nx->regs[0x0a] = 0x00; i430lx_nx->regs[0x0b] = 0x06;
i430lx_nx->regs[0x57] = 0x31;
i430lx_nx->regs[0x60] = i430lx_nx->regs[0x61] = i430lx_nx->regs[0x62] = i430lx_nx->regs[0x63] = 0x02;
i430lx_nx->regs[0x64] = 0x02;
if (info->local == 1) {
i430lx_nx->regs[0x08] = 0x10; /*A0 stepping*/
i430lx_nx->regs[0x50] = 0xA0;
i430lx_nx->regs[0x52] = 0x44; /*256kb PLB cache*/
i430lx_nx->regs[0x66] = i430lx_nx->regs[0x67] = 0x02;
} else {
i430lx_nx->regs[0x08] = 0x03; /*A3 stepping*/
i430lx_nx->regs[0x50] = 0x80;
i430lx_nx->regs[0x52] = 0x40; /*256kb PLB cache*/
}
pci_add_card(0, i430lx_nx_read, i430lx_nx_write, i430lx_nx);
return i430lx_nx;
}
const device_t i430lx_device =
{
"Intel 82434LX",
DEVICE_PCI,
0,
i430lx_nx_init,
i430lx_nx_close,
i430lx_nx_reset,
NULL,
NULL,
NULL,
NULL
};
const device_t i430nx_device =
{
"Intel 82434NX",
DEVICE_PCI,
1,
i430lx_nx_init,
i430lx_nx_close,
i430lx_nx_reset,
NULL,
NULL,
NULL,
NULL
};
static void
machine_at_premiere_common_init(const machine_t *model)
{
machine_at_common_init(model);
device_add(&keyboard_ps2_ami_pci_device);
memregs_init();
pci_init(PCI_CONFIG_TYPE_2);
pci_register_slot(0x00, PCI_CARD_SPECIAL, 0, 0, 0, 0);
pci_register_slot(0x01, PCI_CARD_SPECIAL, 0, 0, 0, 0);
pci_register_slot(0x06, PCI_CARD_NORMAL, 3, 2, 1, 4);
pci_register_slot(0x0E, PCI_CARD_NORMAL, 2, 1, 3, 4);
pci_register_slot(0x0C, PCI_CARD_NORMAL, 1, 3, 2, 4);
pci_register_slot(0x02, PCI_CARD_SPECIAL, 0, 0, 0, 0);
device_add(&sio_device);
fdc37c665_init();
intel_batman_init();
device_add(&intel_flash_bxt_ami_device);
}
void
machine_at_batman_init(const machine_t *model)
{
machine_at_premiere_common_init(model);
device_add(&i430lx_device);
}
void
machine_at_plato_init(const machine_t *model)
{
machine_at_premiere_common_init(model);
device_add(&i430nx_device);
}

View File

@@ -1,285 +0,0 @@
/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
*
* This file is part of the 86Box distribution.
*
* Implementation of the Intel 430VX PCISet chip.
*
* Version: @(#)m_at_430vx.c 1.0.13 2018/04/26
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
*
* Copyright 2008-2018 Sarah Walker.
* Copyright 2016-2018 Miran Grca.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include "../86box.h"
#include "../device.h"
#include "../keyboard.h"
#include "../io.h"
#include "../pci.h"
#include "../mem.h"
#include "../memregs.h"
#include "../piix.h"
#include "../intel_flash.h"
#include "../sio.h"
#include "machine.h"
typedef struct
{
uint8_t regs[256];
} i430vx_t;
static void
i430vx_map(uint32_t addr, uint32_t size, int state)
{
switch (state & 3) {
case 0:
mem_set_mem_state(addr, size, MEM_READ_EXTERNAL | MEM_WRITE_EXTERNAL);
break;
case 1:
mem_set_mem_state(addr, size, MEM_READ_INTERNAL | MEM_WRITE_EXTERNAL);
break;
case 2:
mem_set_mem_state(addr, size, MEM_READ_EXTERNAL | MEM_WRITE_INTERNAL);
break;
case 3:
mem_set_mem_state(addr, size, MEM_READ_INTERNAL | MEM_WRITE_INTERNAL);
break;
}
flushmmucache_nopc();
}
static void
i430vx_write(int func, int addr, uint8_t val, void *priv)
{
i430vx_t *dev = (i430vx_t *) priv;
if (func)
return;
if ((addr >= 0x10) && (addr < 0x4f))
return;
switch (addr) {
case 0x00: case 0x01: case 0x02: case 0x03:
case 0x08: case 0x09: case 0x0a: case 0x0b:
case 0x0c: case 0x0e:
return;
case 0x04: /*Command register*/
val &= 0x02;
val |= 0x04;
break;
case 0x05:
val = 0;
break;
case 0x06: /*Status*/
val = 0;
break;
case 0x07:
val &= 0x80;
val |= 0x02;
break;
case 0x59: /*PAM0*/
if ((dev->regs[0x59] ^ val) & 0xf0) {
i430vx_map(0xf0000, 0x10000, val >> 4);
shadowbios = (val & 0x10);
}
break;
case 0x5a: /*PAM1*/
if ((dev->regs[0x5a] ^ val) & 0x0f)
i430vx_map(0xc0000, 0x04000, val & 0xf);
if ((dev->regs[0x5a] ^ val) & 0xf0)
i430vx_map(0xc4000, 0x04000, val >> 4);
break;
case 0x5b: /*PAM2*/
if ((dev->regs[0x5b] ^ val) & 0x0f)
i430vx_map(0xc8000, 0x04000, val & 0xf);
if ((dev->regs[0x5b] ^ val) & 0xf0)
i430vx_map(0xcc000, 0x04000, val >> 4);
break;
case 0x5c: /*PAM3*/
if ((dev->regs[0x5c] ^ val) & 0x0f)
i430vx_map(0xd0000, 0x04000, val & 0xf);
if ((dev->regs[0x5c] ^ val) & 0xf0)
i430vx_map(0xd4000, 0x04000, val >> 4);
break;
case 0x5d: /*PAM4*/
if ((dev->regs[0x5d] ^ val) & 0x0f)
i430vx_map(0xd8000, 0x04000, val & 0xf);
if ((dev->regs[0x5d] ^ val) & 0xf0)
i430vx_map(0xdc000, 0x04000, val >> 4);
break;
case 0x5e: /*PAM5*/
if ((dev->regs[0x5e] ^ val) & 0x0f)
i430vx_map(0xe0000, 0x04000, val & 0xf);
if ((dev->regs[0x5e] ^ val) & 0xf0)
i430vx_map(0xe4000, 0x04000, val >> 4);
break;
case 0x5f: /*PAM6*/
if ((dev->regs[0x5f] ^ val) & 0x0f)
i430vx_map(0xe8000, 0x04000, val & 0xf);
if ((dev->regs[0x5f] ^ val) & 0xf0)
i430vx_map(0xec000, 0x04000, val >> 4);
break;
case 0x72: /*SMRAM*/
if ((dev->regs[0x72] ^ val) & 0x48)
i430vx_map(0xa0000, 0x20000, ((val & 0x48) == 0x48) ? 3 : 0);
break;
}
dev->regs[addr] = val;
}
static uint8_t i430vx_read(int func, int addr, void *priv)
{
i430vx_t *dev = (i430vx_t *) priv;
if (func)
return 0xff;
return dev->regs[addr];
}
static void
i430vx_reset(void *priv)
{
i430vx_write(0, 0x59, 0x00, priv);
i430vx_write(0, 0x72, 0x02, priv);
}
static void
i430vx_close(void *p)
{
i430vx_t *i430vx = (i430vx_t *)p;
free(i430vx);
}
static void
*i430vx_init(const device_t *info)
{
i430vx_t *i430vx = (i430vx_t *) malloc(sizeof(i430vx_t));
memset(i430vx, 0, sizeof(i430vx_t));
i430vx->regs[0x00] = 0x86; i430vx->regs[0x01] = 0x80; /*Intel*/
i430vx->regs[0x02] = 0x30; i430vx->regs[0x03] = 0x70; /*82437VX*/
i430vx->regs[0x04] = 0x06; i430vx->regs[0x05] = 0x00;
i430vx->regs[0x06] = 0x00; i430vx->regs[0x07] = 0x02;
i430vx->regs[0x08] = 0x00; /*A0 stepping*/
i430vx->regs[0x09] = 0x00; i430vx->regs[0x0a] = 0x00; i430vx->regs[0x0b] = 0x06;
i430vx->regs[0x52] = 0x42; /*256kb PLB cache*/
i430vx->regs[0x53] = 0x14;
i430vx->regs[0x56] = 0x52; /*DRAM control*/
i430vx->regs[0x57] = 0x01;
i430vx->regs[0x60] = i430vx->regs[0x61] = i430vx->regs[0x62] = i430vx->regs[0x63] = 0x02;
i430vx->regs[0x64] = 0x02;
i430vx->regs[0x67] = 0x11;
i430vx->regs[0x69] = 0x03;
i430vx->regs[0x70] = 0x20;
i430vx->regs[0x72] = 0x02;
i430vx->regs[0x74] = 0x0e;
i430vx->regs[0x78] = 0x23;
pci_add_card(0, i430vx_read, i430vx_write, i430vx);
return i430vx;
}
const device_t i430vx_device =
{
"Intel 82437VX",
DEVICE_PCI,
0,
i430vx_init,
i430vx_close,
i430vx_reset,
NULL,
NULL,
NULL,
NULL
};
void
machine_at_p55tvp4_init(const machine_t *model)
{
machine_at_common_init(model);
device_add(&keyboard_ps2_pci_device);
memregs_init();
pci_init(PCI_CONFIG_TYPE_1);
pci_register_slot(0x00, PCI_CARD_SPECIAL, 0, 0, 0, 0);
pci_register_slot(0x0C, PCI_CARD_NORMAL, 1, 2, 3, 4);
pci_register_slot(0x0B, PCI_CARD_NORMAL, 2, 3, 4, 1);
pci_register_slot(0x0A, PCI_CARD_NORMAL, 3, 4, 1, 2);
pci_register_slot(0x09, PCI_CARD_NORMAL, 4, 1, 2, 3);
pci_register_slot(0x07, PCI_CARD_SPECIAL, 0, 0, 0, 0);
device_add(&i430vx_device);
device_add(&piix3_device);
w83877f_init();
device_add(&intel_flash_bxt_device);
}
void
machine_at_i430vx_init(const machine_t *model)
{
machine_at_common_init(model);
device_add(&keyboard_ps2_pci_device);
memregs_init();
pci_init(PCI_CONFIG_TYPE_1);
pci_register_slot(0x00, PCI_CARD_SPECIAL, 0, 0, 0, 0);
pci_register_slot(0x11, PCI_CARD_NORMAL, 2, 3, 4, 1);
pci_register_slot(0x12, PCI_CARD_NORMAL, 1, 2, 3, 4);
pci_register_slot(0x14, PCI_CARD_NORMAL, 3, 4, 1, 2);
pci_register_slot(0x13, PCI_CARD_NORMAL, 4, 1, 2, 3);
pci_register_slot(0x07, PCI_CARD_SPECIAL, 0, 0, 0, 0);
device_add(&i430vx_device);
device_add(&piix3_device);
um8669f_init();
device_add(&intel_flash_bxt_device);
}
void
machine_at_p55va_init(const machine_t *model)
{
machine_at_common_init(model);
device_add(&keyboard_ps2_pci_device);
pci_init(PCI_CONFIG_TYPE_1);
pci_register_slot(0x00, PCI_CARD_SPECIAL, 0, 0, 0, 0);
pci_register_slot(0x08, PCI_CARD_NORMAL, 1, 2, 3, 4);
pci_register_slot(0x09, PCI_CARD_NORMAL, 2, 3, 4, 1);
pci_register_slot(0x0A, PCI_CARD_NORMAL, 3, 4, 1, 2);
pci_register_slot(0x0B, PCI_CARD_NORMAL, 4, 1, 2, 3);
pci_register_slot(0x07, PCI_CARD_SPECIAL, 0, 0, 0, 0);
device_add(&i430vx_device);
device_add(&piix3_device);
fdc37c932fr_init();
device_add(&intel_flash_bxt_device);
}

View File

@@ -1,271 +0,0 @@
/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
*
* This file is part of the 86Box distribution.
*
* Implementation of the Intel 440FX PCISet chip.
*
* Version: @(#)m_at_440fx.c 1.0.13 2018/04/26
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
*
* Copyright 2008-2018 Sarah Walker.
* Copyright 2016-2018 Miran Grca.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include "../86box.h"
#include "../io.h"
#include "../pci.h"
#include "../mem.h"
#include "../memregs.h"
#include "../device.h"
#include "../keyboard.h"
#include "../piix.h"
#include "../intel_flash.h"
#include "../sio.h"
#include "machine.h"
typedef struct
{
uint8_t regs[256];
} i440fx_t;
static void
i440fx_map(uint32_t addr, uint32_t size, int state)
{
switch (state & 3) {
case 0:
mem_set_mem_state(addr, size, MEM_READ_EXTERNAL | MEM_WRITE_EXTERNAL);
break;
case 1:
mem_set_mem_state(addr, size, MEM_READ_INTERNAL | MEM_WRITE_EXTERNAL);
break;
case 2:
mem_set_mem_state(addr, size, MEM_READ_EXTERNAL | MEM_WRITE_INTERNAL);
break;
case 3:
mem_set_mem_state(addr, size, MEM_READ_INTERNAL | MEM_WRITE_INTERNAL);
break;
}
flushmmucache_nopc();
}
static void
i440fx_write(int func, int addr, uint8_t val, void *priv)
{
i440fx_t *dev = (i440fx_t *) priv;
if (func)
return;
if ((addr >= 0x10) && (addr < 0x4f))
return;
switch (addr) {
case 0x00: case 0x01: case 0x02: case 0x03:
case 0x08: case 0x09: case 0x0a: case 0x0b:
case 0x0c: case 0x0e:
return;
case 0x04: /*Command register*/
val &= 0x02;
val |= 0x04;
break;
case 0x05:
val = 0;
break;
case 0x06: /*Status*/
val = 0;
break;
case 0x07:
val &= 0x80;
val |= 0x02;
break;
case 0x59: /*PAM0*/
if ((dev->regs[0x59] ^ val) & 0xf0) {
i440fx_map(0xf0000, 0x10000, val >> 4);
shadowbios = (val & 0x10);
}
break;
case 0x5a: /*PAM1*/
if ((dev->regs[0x5a] ^ val) & 0x0f)
i440fx_map(0xc0000, 0x04000, val & 0xf);
if ((dev->regs[0x5a] ^ val) & 0xf0)
i440fx_map(0xc4000, 0x04000, val >> 4);
break;
case 0x5b: /*PAM2*/
if ((dev->regs[0x5b] ^ val) & 0x0f)
i440fx_map(0xc8000, 0x04000, val & 0xf);
if ((dev->regs[0x5b] ^ val) & 0xf0)
i440fx_map(0xcc000, 0x04000, val >> 4);
break;
case 0x5c: /*PAM3*/
if ((dev->regs[0x5c] ^ val) & 0x0f)
i440fx_map(0xd0000, 0x04000, val & 0xf);
if ((dev->regs[0x5c] ^ val) & 0xf0)
i440fx_map(0xd4000, 0x04000, val >> 4);
break;
case 0x5d: /*PAM4*/
if ((dev->regs[0x5d] ^ val) & 0x0f)
i440fx_map(0xd8000, 0x04000, val & 0xf);
if ((dev->regs[0x5d] ^ val) & 0xf0)
i440fx_map(0xdc000, 0x04000, val >> 4);
break;
case 0x5e: /*PAM5*/
if ((dev->regs[0x5e] ^ val) & 0x0f)
i440fx_map(0xe0000, 0x04000, val & 0xf);
if ((dev->regs[0x5e] ^ val) & 0xf0)
i440fx_map(0xe4000, 0x04000, val >> 4);
break;
case 0x5f: /*PAM6*/
if ((dev->regs[0x5f] ^ val) & 0x0f)
i440fx_map(0xe8000, 0x04000, val & 0xf);
if ((dev->regs[0x5f] ^ val) & 0xf0)
i440fx_map(0xec000, 0x04000, val >> 4);
break;
case 0x72: /*SMRAM*/
if ((dev->regs[0x72] ^ val) & 0x48)
i440fx_map(0xa0000, 0x20000, ((val & 0x48) == 0x48) ? 3 : 0);
break;
}
dev->regs[addr] = val;
}
static uint8_t
i440fx_read(int func, int addr, void *priv)
{
i440fx_t *dev = (i440fx_t *) priv;
if (func)
return 0xff;
return dev->regs[addr];
}
static void
i440fx_reset(void *priv)
{
i440fx_write(0, 0x59, 0x00, priv);
i440fx_write(0, 0x72, 0x02, priv);
}
static void
i440fx_close(void *p)
{
i440fx_t *i440fx = (i440fx_t *)p;
free(i440fx);
}
static void
*i440fx_init(const device_t *info)
{
i440fx_t *i440fx = (i440fx_t *) malloc(sizeof(i440fx_t));
memset(i440fx, 0, sizeof(i440fx_t));
i440fx->regs[0x00] = 0x86; i440fx->regs[0x01] = 0x80; /*Intel*/
i440fx->regs[0x02] = 0x37; i440fx->regs[0x03] = 0x12; /*82441FX*/
i440fx->regs[0x04] = 0x03; i440fx->regs[0x05] = 0x01;
i440fx->regs[0x06] = 0x80; i440fx->regs[0x07] = 0x00;
i440fx->regs[0x08] = 0x02; /*A0 stepping*/
i440fx->regs[0x09] = 0x00; i440fx->regs[0x0a] = 0x00; i440fx->regs[0x0b] = 0x06;
i440fx->regs[0x0d] = 0x00;
i440fx->regs[0x0f] = 0x00;
i440fx->regs[0x2c] = 0xf4;
i440fx->regs[0x2d] = 0x1a;
i440fx->regs[0x2e] = 0x00;
i440fx->regs[0x2f] = 0x11;
i440fx->regs[0x50] = 0x00;
i440fx->regs[0x51] = 0x01;
i440fx->regs[0x52] = i440fx->regs[0x54] = i440fx->regs[0x55] = i440fx->regs[0x56] = 0x00;
i440fx->regs[0x53] = 0x80;
i440fx->regs[0x57] = 0x01;
i440fx->regs[0x58] = 0x10;
i440fx->regs[0x5a] = i440fx->regs[0x5b] = i440fx->regs[0x5c] = i440fx->regs[0x5d] = 0x11;
i440fx->regs[0x5e] = 0x11;
i440fx->regs[0x5f] = 0x31;
i440fx->regs[0x72] = 0x02;
pci_add_card(0, i440fx_read, i440fx_write, i440fx);
return i440fx;
}
const device_t i440fx_device =
{
"Intel 82441FX",
DEVICE_PCI,
0,
i440fx_init,
i440fx_close,
i440fx_reset,
NULL,
NULL,
NULL,
NULL
};
void
machine_at_i440fx_init(const machine_t *model)
{
machine_at_common_init(model);
device_add(&keyboard_ps2_pci_device);
memregs_init();
pci_init(PCI_CONFIG_TYPE_1);
pci_register_slot(0x00, PCI_CARD_SPECIAL, 0, 0, 0, 0);
pci_register_slot(0x0E, PCI_CARD_NORMAL, 1, 2, 3, 4);
pci_register_slot(0x0D, PCI_CARD_NORMAL, 2, 3, 4, 1);
pci_register_slot(0x0C, PCI_CARD_NORMAL, 3, 4, 1, 2);
pci_register_slot(0x0B, PCI_CARD_NORMAL, 4, 1, 2, 3);
pci_register_slot(0x0A, PCI_CARD_NORMAL, 1, 2, 3, 4);
pci_register_slot(0x07, PCI_CARD_SPECIAL, 0, 0, 0, 0);
device_add(&i440fx_device);
device_add(&piix3_device);
fdc37c665_init();
device_add(&intel_flash_bxt_device);
}
void
machine_at_s1668_init(const machine_t *model)
{
machine_at_common_init(model);
device_add(&keyboard_ps2_ami_pci_device);
memregs_init();
pci_init(PCI_CONFIG_TYPE_1);
pci_register_slot(0x00, PCI_CARD_SPECIAL, 0, 0, 0, 0);
pci_register_slot(0x07, PCI_CARD_SPECIAL, 0, 0, 0, 0);
pci_register_slot(0x0E, PCI_CARD_NORMAL, 1, 2, 3, 4);
pci_register_slot(0x0D, PCI_CARD_NORMAL, 2, 3, 4, 1);
pci_register_slot(0x0C, PCI_CARD_NORMAL, 3, 4, 1, 2);
pci_register_slot(0x0B, PCI_CARD_NORMAL, 4, 1, 2, 3);
pci_register_slot(0x0A, PCI_CARD_NORMAL, 1, 2, 3, 4);
device_add(&i440fx_device);
device_add(&piix3_device);
fdc37c665_init();
device_add(&intel_flash_bxt_device);
}

View File

@@ -203,7 +203,7 @@ europc_log(const char *fmt, ...)
* FIXME: should we mark NVR as dirty?
*/
static void
rtc_tick(nvr_t *nvr)
europc_rtc_tick(nvr_t *nvr)
{
uint8_t *regs;
int mon, yr;
@@ -757,7 +757,7 @@ machine_europc_init(const machine_t *model)
/* Set up any local handlers here. */
europc.nvr.reset = rtc_reset;
europc.nvr.start = rtc_start;
europc.nvr.tick = rtc_tick;
europc.nvr.tick = europc_rtc_tick;
/* Initialize the actual NVR. */
nvr_init(&europc.nvr);

View File

@@ -93,7 +93,7 @@ machine_common_init(const machine_t *model)
pit_init();
cpu_set();
if (AT)
if (machines[machine].cpu[cpu_manufacturer].cpus[cpu_effective].cpu_type >= CPU_286)
setrtcconst(machines[machine].cpu[cpu_manufacturer].cpus[cpu_effective].rspeed);
else
setrtcconst(14318184.0);

View File

@@ -11,7 +11,7 @@
* NOTES: OpenAT wip for 286-class machine with open BIOS.
* PS2_M80-486 wip, pending receipt of TRM's for machine.
*
* Version: @(#)machine_table.c 1.0.29 2018/05/10
* Version: @(#)machine_table.c 1.0.30 2018/05/26
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -88,7 +88,7 @@ const machine_t machines[] = {
{ "[386SX ISA] AMI 386SX clone", ROM_AMI386SX, "ami386", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 512,16384, 128, 127, machine_at_headland_init, NULL },
{ "[386SX ISA] Amstrad MegaPC", ROM_MEGAPC, "megapc", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_VIDEO | MACHINE_HDC, 1, 16, 1, 127, machine_at_wd76c10_init, NULL },
{ "[386SX ISA] Award 386SX clone", ROM_AWARD386SX_OPTI495, "award386sx", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 1, 64, 1, 127, machine_at_opti495_init, NULL },
{ "[386SX ISA] Award 386SX clone", ROM_AWARD386SX_OPTI495, "award386sx", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 1, 64, 1, 127, machine_at_opti495_init, NULL },
{ "[386SX ISA] DTK 386SX clone", ROM_DTK386, "dtk386", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 512,16384, 128, 127, machine_at_neat_init, NULL },
{ "[386SX ISA] IBM PS/1 model 2121", ROM_IBMPS1_2121, "ibmps1_2121", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC | MACHINE_VIDEO, 1, 6, 1, 63, machine_ps1_m2121_init, NULL },
{ "[386SX ISA] IBM PS/1 m.2121+ISA", ROM_IBMPS1_2121_ISA, "ibmps1_2121_isa", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC | MACHINE_VIDEO, 1, 6, 1, 63, machine_ps1_m2121_init, NULL },
@@ -98,7 +98,7 @@ const machine_t machines[] = {
{ "[386DX ISA] AMI 386DX clone", ROM_AMI386DX_OPTI495, "ami386dx", {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 1, 64, 1, 127, machine_at_opti495_ami_init, NULL },
{ "[386DX ISA] Amstrad MegaPC 386DX", ROM_MEGAPCDX, "megapcdx", {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC | MACHINE_VIDEO, 1, 32, 1, 127, machine_at_wd76c10_init, NULL },
{ "[386DX ISA] Award 386DX clone", ROM_AWARD386DX_OPTI495, "award386dx", {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 1, 64, 1, 127, machine_at_opti495_init, NULL },
{ "[386DX ISA] Award 386DX clone", ROM_AWARD386DX_OPTI495, "award386dx", {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 1, 64, 1, 127, machine_at_opti495_init, NULL },
{ "[386DX ISA] MR 386DX clone", ROM_MR386DX_OPTI495, "mr386dx", {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 1, 64, 1, 127, machine_at_opti495_ami_init, NULL },
#if defined(DEV_BRANCH) && defined(USE_PORTABLE3)
{ "[386DX ISA] Compaq Portable III (386)", ROM_PORTABLEIII386, "portableiii386", {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AT | MACHINE_HDC | MACHINE_VIDEO, 1, 14, 1, 127, machine_at_compaq_init, NULL },
@@ -123,7 +123,6 @@ const machine_t machines[] = {
{ "[Socket 5 NX] Intel Premiere/PCI II", ROM_PLATO, "plato", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"AMD", cpus_K5}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 2, 128, 2, 127, machine_at_plato_init, NULL },
{ "[Socket 5 FX] ASUS P/I-P54TP4XE", ROM_P54TP4XE, "p54tp4xe", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"AMD", cpus_K5}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 8, 128, 8, 127, machine_at_p54tp4xe_init, NULL },
{ "[Socket 5 FX] Intel Advanced/EV", ROM_ENDEAVOR, "endeavor", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"AMD", cpus_K5}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC | MACHINE_VIDEO, 8, 128, 8, 127, machine_at_endeavor_init, at_endeavor_get_device },
{ "[Socket 5 FX] Intel Advanced/ZP", ROM_ZAPPA, "zappa", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"AMD", cpus_K5}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 128, 8, 127, machine_at_zappa_init, NULL },
{ "[Socket 5 FX] PC Partner MB500N", ROM_MB500N, "mb500n", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"AMD", cpus_K5}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 8, 128, 8, 127, machine_at_mb500n_init, NULL },
{ "[Socket 5 FX] President Award 430FX PCI",ROM_PRESIDENT, "president", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"AMD", cpus_K5}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 8, 128, 8, 127, machine_at_president_init, NULL },
@@ -132,6 +131,7 @@ const machine_t machines[] = {
#if defined(DEV_BRANCH) && defined(USE_MRTHOR)
{ "[Socket 7 FX] MR Intel Advanced/ATX", ROM_MRTHOR, "mrthor", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 128, 8, 127, machine_at_thor_init, NULL },
#endif
{ "[Socket 7 FX] Intel Advanced/EV", ROM_ENDEAVOR, "endeavor", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC | MACHINE_VIDEO, 8, 128, 8, 127, machine_at_endeavor_init, at_endeavor_get_device },
{ "[Socket 7 FX] Packard Bell PB640", ROM_PB640, "pb640", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC | MACHINE_VIDEO, 8, 128, 8, 127, machine_at_pb640_init, NULL },
{ "[Socket 7 HX] Acer M3a", ROM_ACERM3A, "acerm3a", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"AMD", cpus_K56}, {"Cyrix", cpus_6x86},{"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 192, 8, 127, machine_at_acerm3a_init, NULL },
@@ -147,7 +147,6 @@ const machine_t machines[] = {
{ "[Socket 5 NX] Intel Premiere/PCI II", ROM_PLATO, "plato", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 2, 128, 2, 127, machine_at_plato_init, NULL },
{ "[Socket 5 FX] ASUS P/I-P54TP4XE", ROM_P54TP4XE, "p54tp4xe", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 8, 128, 8, 127, machine_at_p54tp4xe_init, NULL },
{ "[Socket 5 FX] Intel Advanced/EV", ROM_ENDEAVOR, "endeavor", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC | MACHINE_VIDEO, 8, 128, 8, 127, machine_at_endeavor_init, at_endeavor_get_device },
{ "[Socket 5 FX] Intel Advanced/ZP", ROM_ZAPPA, "zappa", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 128, 8, 127, machine_at_zappa_init, NULL },
{ "[Socket 5 FX] PC Partner MB500N", ROM_MB500N, "mb500n", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 8, 128, 8, 127, machine_at_mb500n_init, NULL },
{ "[Socket 5 FX] President Award 430FX PCI",ROM_PRESIDENT, "president", {{ "Intel", cpus_PentiumS5}, {"IDT", cpus_WinChip}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 8, 128, 8, 127, machine_at_president_init, NULL },
@@ -156,6 +155,7 @@ const machine_t machines[] = {
#if defined(DEV_BRANCH) && defined(USE_MRTHOR)
{ "[Socket 7 FX] MR Intel Advanced/ATX", ROM_MRTHOR, "mrthor", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"Cyrix", cpus_6x86}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 128, 8, 127, machine_at_thor_init, NULL },
#endif
{ "[Socket 7 FX] Intel Advanced/EV", ROM_ENDEAVOR, "endeavor", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"Cyrix", cpus_6x86}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC | MACHINE_VIDEO, 8, 128, 8, 127, machine_at_endeavor_init, at_endeavor_get_device },
{ "[Socket 7 FX] Packard Bell PB640", ROM_PB640, "pb640", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"Cyrix", cpus_6x86}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC | MACHINE_VIDEO, 8, 128, 8, 127, machine_at_pb640_init, NULL },
{ "[Socket 7 HX] Acer M3a", ROM_ACERM3A, "acerm3a", {{"Intel", cpus_Pentium}, {"IDT", cpus_WinChip}, {"Cyrix", cpus_6x86}, {"", NULL}, {"", NULL}}, 0, MACHINE_PCI | MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 192, 8, 127, machine_at_acerm3a_init, NULL },

View File

@@ -73,6 +73,8 @@ extern int mouse_get_type(int mouse);
extern int mouse_get_ndev(void);
extern int mouse_get_buttons(void);
extern void mouse_clear_data(void *priv);
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -79,6 +79,15 @@ mouse_ps2_log(const char *format, ...)
}
void
mouse_clear_data(void *priv)
{
mouse_t *dev = (mouse_t *)priv;
dev->flags &= ~FLAG_CTRLDAT;
}
static void
ps2_write(uint8_t val, void *priv)
{

1679
src/network/net_3c503.c Normal file

File diff suppressed because it is too large Load Diff

7
src/network/net_3c503.h Normal file
View File

@@ -0,0 +1,7 @@
#ifndef NET_3C503_H
# define NET_3C503_H
extern const device_t threec503_device;
#endif /*NET_3C503_H*/

35
src/network/net_dp8390.c Normal file
View File

@@ -0,0 +1,35 @@
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <wchar.h>
#include <time.h>
#define HAVE_STDARG_H
/*
* Return the 6-bit index into the multicast
* table. Stolen unashamedly from FreeBSD's if_ed.c
*/
int
mcast_index(const void *dst)
{
#define POLYNOMIAL 0x04c11db6
uint32_t crc = 0xffffffffL;
int carry, i, j;
uint8_t b;
uint8_t *ep = (uint8_t *)dst;
for (i=6; --i>=0;) {
b = *ep++;
for (j = 8; --j >= 0;) {
carry = ((crc & 0x80000000L) ? 1 : 0) ^ (b & 0x01);
crc <<= 1;
b >>= 1;
if (carry)
crc = ((crc ^ POLYNOMIAL) | carry);
}
}
return(crc >> 26);
#undef POLYNOMIAL
}

158
src/network/net_dp8390.h Normal file
View File

@@ -0,0 +1,158 @@
#ifndef NET_DP8390_H
# define NET_DP8390_H
/* Never completely fill the ne2k ring so that we never
hit the unclear completely full buffer condition. */
#define DP8390_NEVER_FULL_RING (1)
#define DP8390_DWORD_MEMSIZ (32*1024)
#define DP8390_DWORD_MEMSTART (16*1024)
#define DP8390_DWORD_MEMEND (DP8390_DWORD_MEMSTART+DP8390_DWORD_MEMSIZ)
#define DP8390_WORD_MEMSIZ (16*1024)
#define DP8390_WORD_MEMSTART (8*1024)
#define DP8390_WORD_MEMEND (DP8390_WORD_MEMSTART+DP8390_WORD_MEMSIZ)
typedef struct {
/* Page 0 */
/* Command Register - 00h read/write */
struct CR_t {
int stop; /* STP - Software Reset command */
int start; /* START - start the NIC */
int tx_packet; /* TXP - initiate packet transmission */
uint8_t rdma_cmd; /* RD0,RD1,RD2 - Remote DMA command */
uint8_t pgsel; /* PS0,PS1 - Page select */
} CR;
/* Interrupt Status Register - 07h read/write */
struct ISR_t {
int pkt_rx; /* PRX - packet received with no errors */
int pkt_tx; /* PTX - packet txed with no errors */
int rx_err; /* RXE - packet rxed with 1 or more errors */
int tx_err; /* TXE - packet txed " " " " " */
int overwrite; /* OVW - rx buffer resources exhausted */
int cnt_oflow; /* CNT - network tally counter MSB's set */
int rdma_done; /* RDC - remote DMA complete */
int reset; /* RST - reset status */
} ISR;
/* Interrupt Mask Register - 0fh write */
struct IMR_t {
int rx_inte; /* PRXE - packet rx interrupt enable */
int tx_inte; /* PTXE - packet tx interrput enable */
int rxerr_inte; /* RXEE - rx error interrupt enable */
int txerr_inte; /* TXEE - tx error interrupt enable */
int overw_inte; /* OVWE - overwrite warn int enable */
int cofl_inte; /* CNTE - counter o'flow int enable */
int rdma_inte; /* RDCE - remote DMA complete int enable */
int reserved; /* D7 - reserved */
} IMR;
/* Data Configuration Register - 0eh write */
struct DCR_t {
int wdsize; /* WTS - 8/16-bit select */
int endian; /* BOS - byte-order select */
int longaddr; /* LAS - long-address select */
int loop; /* LS - loopback select */
int auto_rx; /* AR - auto-remove rx pkts with remote DMA */
uint8_t fifo_size; /* FT0,FT1 - fifo threshold */
} DCR;
/* Transmit Configuration Register - 0dh write */
struct TCR_t {
int crc_disable; /* CRC - inhibit tx CRC */
uint8_t loop_cntl; /* LB0,LB1 - loopback control */
int ext_stoptx; /* ATD - allow tx disable by external mcast */
int coll_prio; /* OFST - backoff algorithm select */
uint8_t reserved; /* D5,D6,D7 - reserved */
} TCR;
/* Transmit Status Register - 04h read */
struct TSR_t {
int tx_ok; /* PTX - tx complete without error */
int reserved; /* D1 - reserved */
int collided; /* COL - tx collided >= 1 times */
int aborted; /* ABT - aborted due to excessive collisions */
int no_carrier; /* CRS - carrier-sense lost */
int fifo_ur; /* FU - FIFO underrun */
int cd_hbeat; /* CDH - no tx cd-heartbeat from transceiver */
int ow_coll; /* OWC - out-of-window collision */
} TSR;
/* Receive Configuration Register - 0ch write */
struct RCR_t {
int errors_ok; /* SEP - accept pkts with rx errors */
int runts_ok; /* AR - accept < 64-byte runts */
int broadcast; /* AB - accept eth broadcast address */
int multicast; /* AM - check mcast hash array */
int promisc; /* PRO - accept all packets */
int monitor; /* MON - check pkts, but don't rx */
uint8_t reserved; /* D6,D7 - reserved */
} RCR;
/* Receive Status Register - 0ch read */
struct RSR_t {
int rx_ok; /* PRX - rx complete without error */
int bad_crc; /* CRC - Bad CRC detected */
int bad_falign; /* FAE - frame alignment error */
int fifo_or; /* FO - FIFO overrun */
int rx_missed; /* MPA - missed packet error */
int rx_mbit; /* PHY - unicast or mcast/bcast address match */
int rx_disabled; /* DIS - set when in monitor mode */
int deferred; /* DFR - collision active */
} RSR;
uint16_t local_dma; /* 01,02h read ; current local DMA addr */
uint8_t page_start; /* 01h write ; page start regr */
uint8_t page_stop; /* 02h write ; page stop regr */
uint8_t bound_ptr; /* 03h read/write ; boundary pointer */
uint8_t tx_page_start; /* 04h write ; transmit page start reg */
uint8_t num_coll; /* 05h read ; number-of-collisions reg */
uint16_t tx_bytes; /* 05,06h write ; transmit byte-count reg */
uint8_t fifo; /* 06h read ; FIFO */
uint16_t remote_dma; /* 08,09h read ; current remote DMA addr */
uint16_t remote_start; /* 08,09h write ; remote start address reg */
uint16_t remote_bytes; /* 0a,0bh write ; remote byte-count reg */
uint8_t tallycnt_0; /* 0dh read ; tally ctr 0 (frame align errs) */
uint8_t tallycnt_1; /* 0eh read ; tally ctr 1 (CRC errors) */
uint8_t tallycnt_2; /* 0fh read ; tally ctr 2 (missed pkt errs) */
/* Page 1 */
/* Command Register 00h (repeated) */
uint8_t physaddr[6]; /* 01-06h read/write ; MAC address */
uint8_t curr_page; /* 07h read/write ; current page register */
uint8_t mchash[8]; /* 08-0fh read/write ; multicast hash array */
/* Page 2 - diagnostic use only */
/* Command Register 00h (repeated) */
/* Page Start Register 01h read (repeated)
* Page Stop Register 02h read (repeated)
* Current Local DMA Address 01,02h write (repeated)
* Transmit Page start address 04h read (repeated)
* Receive Configuration Register 0ch read (repeated)
* Transmit Configuration Register 0dh read (repeated)
* Data Configuration Register 0eh read (repeated)
* Interrupt Mask Register 0fh read (repeated)
*/
uint8_t rempkt_ptr; /* 03h read/write ; rmt next-pkt ptr */
uint8_t localpkt_ptr; /* 05h read/write ; lcl next-pkt ptr */
uint16_t address_cnt; /* 06,07h read/write ; address cter */
/* Page 3 - should never be modified. */
/* Novell ASIC state */
uint8_t mem[DP8390_DWORD_MEMSIZ]; /* on-chip packet memory */
int tx_timer_index;
int tx_timer_active;
} dp8390_t;
extern int mcast_index(const void *dst);
#endif /*NET_DP8390_H*/

File diff suppressed because it is too large Load Diff

View File

@@ -12,7 +12,7 @@
* it should be malloc'ed and then linked to the NETCARD def.
* Will be done later.
*
* Version: @(#)network.c 1.0.4 2018/04/29
* Version: @(#)network.c 1.0.5 2018/06/09
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*
@@ -60,12 +60,15 @@
#include "../plat.h"
#include "../ui.h"
#include "network.h"
#include "net_3c503.h"
#include "net_ne2000.h"
static netcard_t net_cards[] = {
{ "None", "none", NULL,
NULL },
{ "[ISA] 3Com EtherLink II (3C503)","3c503", &threec503_device,
NULL },
{ "[ISA] Novell NE1000", "ne1k", &ne1000_device,
NULL },
{ "[ISA] Novell NE2000", "ne2k", &ne2000_device,
@@ -296,7 +299,7 @@ network_reset(void)
if (i < 0) {
/* Tell user we can't do this (at the moment.) */
ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2139);
ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2102);
// FIXME: we should ask in the dialog if they want to
// reconfigure or quit, and throw them into the

View File

@@ -8,7 +8,7 @@
*
* Implement a generic NVRAM/CMOS/RTC device.
*
* Version: @(#)nvr.c 1.0.9 2018/04/29
* Version: @(#)nvr.c 1.0.10 2018/06/08
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*
@@ -117,7 +117,7 @@ nvr_get_days(int month, int year)
/* One more second has passed, update the internal clock. */
static void
void
rtc_tick(void)
{
/* Ping the internal clock. */
@@ -150,7 +150,8 @@ onesec_timer(void *priv)
if (++nvr->onesec_cnt >= 100) {
/* Update the internal clock. */
rtc_tick();
if (!(machines[machine].flags & MACHINE_AT))
rtc_tick();
/* Update the RTC device if needed. */
if (nvr->tick != NULL)
@@ -251,7 +252,8 @@ nvr_load(void)
if (saved_nvr == NULL) return(0);
/* Clear out any old data. */
memset(saved_nvr->regs, 0x00, sizeof(saved_nvr->regs));
// memset(saved_nvr->regs, 0x00, sizeof(saved_nvr->regs));
memset(saved_nvr->regs, 0xff, sizeof(saved_nvr->regs));
/* Set the defaults. */
if (saved_nvr->reset != NULL)

View File

@@ -8,7 +8,7 @@
*
* Definitions for the generic NVRAM/CMOS driver.
*
* Version: @(#)nvr.h 1.0.6 2018/04/11
* Version: @(#)nvr.h 1.0.7 2018/06/08
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*
@@ -79,12 +79,15 @@ typedef struct _nvr_ {
extern int nvr_dosave;
#ifdef EMU_DEVICE_H
extern const device_t at_nvr_old_device;
extern const device_t at_nvr_device;
extern const device_t ps_nvr_device;
extern const device_t amstrad_nvr_device;
#endif
extern void rtc_tick(void);
extern void nvr_init(nvr_t *);
extern wchar_t *nvr_path(wchar_t *str);
extern FILE *nvr_fopen(wchar_t *str, wchar_t *mode);

View File

@@ -311,7 +311,8 @@ time_get(nvr_t *nvr, struct tm *tm)
tm->tm_mday = nvr->regs[RTC_DOM];
tm->tm_mon = (nvr->regs[RTC_MONTH] - 1);
tm->tm_year = nvr->regs[RTC_YEAR];
tm->tm_year += (nvr->regs[local->cent] * 100) - 1900;
if (local->cent != 0xFF)
tm->tm_year += (nvr->regs[local->cent] * 100) - 1900;
} else {
/* NVR is in BCD data mode. */
tm->tm_sec = RTC_DCB(nvr->regs[RTC_SECONDS]);
@@ -321,7 +322,8 @@ time_get(nvr_t *nvr, struct tm *tm)
tm->tm_mday = RTC_DCB(nvr->regs[RTC_DOM]);
tm->tm_mon = (RTC_DCB(nvr->regs[RTC_MONTH]) - 1);
tm->tm_year = RTC_DCB(nvr->regs[RTC_YEAR]);
tm->tm_year += (RTC_DCB(nvr->regs[local->cent]) * 100) - 1900;
if (local->cent != 0xFF)
tm->tm_year += (RTC_DCB(nvr->regs[local->cent]) * 100) - 1900;
}
/* Adjust for 12/24 hour mode. */
@@ -347,7 +349,8 @@ time_set(nvr_t *nvr, struct tm *tm)
nvr->regs[RTC_DOM] = tm->tm_mday;
nvr->regs[RTC_MONTH] = (tm->tm_mon + 1);
nvr->regs[RTC_YEAR] = (year % 100);
nvr->regs[local->cent] = (year / 100);
if (local->cent != 0xFF)
nvr->regs[local->cent] = (year / 100);
if (nvr->regs[RTC_REGB] & REGB_2412) {
/* NVR is in 24h mode. */
@@ -366,7 +369,8 @@ time_set(nvr_t *nvr, struct tm *tm)
nvr->regs[RTC_DOM] = RTC_BCD(tm->tm_mday);
nvr->regs[RTC_MONTH] = RTC_BCD(tm->tm_mon + 1);
nvr->regs[RTC_YEAR] = RTC_BCD(year % 100);
nvr->regs[local->cent] = RTC_BCD(year / 100);
if (local->cent != 0xFF)
nvr->regs[local->cent] = RTC_BCD(year / 100);
if (nvr->regs[RTC_REGB] & REGB_2412) {
/* NVR is in 24h mode. */
@@ -451,9 +455,12 @@ timer_recalc(nvr_t *nvr, int add)
c = 1ULL << ((nvr->regs[RTC_REGA] & REGA_RS) - 1);
nt = (int64_t)(RTCCONST * c * (1<<TIMER_SHIFT));
if (add)
if (add == 2) {
local->rtctime = nt;
return;
} else if (add == 1)
local->rtctime += nt;
else if (local->rtctime > nt)
else if (local->rtctime > nt)
local->rtctime = nt;
}
@@ -494,7 +501,7 @@ timer_tick(nvr_t *nvr)
/* Set the UIP bit, announcing the update. */
local->stat = REGA_UIP;
timer_recalc(nvr, 0);
rtc_tick();
/* Schedule the actual update. */
local->ecount = (int64_t)((244.0 + 1984.0) * TIMER_USEC);
@@ -545,7 +552,7 @@ nvr_write(uint16_t addr, uint8_t val, void *priv)
break;
}
if ((local->addr < RTC_REGA) || (local->addr == local->cent)) {
if ((local->addr < RTC_REGA) || ((local->cent != 0xff) && (local->addr == local->cent))) {
if ((local->addr != 1) && (local->addr != 3) && (local->addr != 5)) {
if ((old != val) && !enable_sync) {
/* Update internal clock. */
@@ -611,7 +618,8 @@ nvr_reset(nvr_t *nvr)
nvr->regs[RTC_DOM] = 1;
nvr->regs[RTC_MONTH] = 1;
nvr->regs[RTC_YEAR] = RTC_BCD(80);
nvr->regs[local->cent] = RTC_BCD(19);
if (local->cent != 0xFF)
nvr->regs[local->cent] = RTC_BCD(19);
}
@@ -656,27 +664,34 @@ nvr_at_init(const device_t *info)
nvr = (nvr_t *)malloc(sizeof(nvr_t));
if (nvr == NULL) return(NULL);
/* FIXME: See which is correct, this or 0xFF. */
/* memset(nvr, 0x00, sizeof(nvr_t)); */
memset(nvr, 0xFF, sizeof(nvr_t));
if (info->local == 0)
memset(nvr, 0xff, sizeof(nvr_t));
else
memset(nvr, 0x00, sizeof(nvr_t));
local = (local_t *)malloc(sizeof(local_t));
memset(local, 0xff, sizeof(local_t));
memset(local, 0x00, sizeof(local_t));
nvr->data = local;
/* This is machine specific. */
nvr->size = machines[machine].nvrmask + 1;
switch(info->local) {
case 0: /* standard AT */
case 0: /* standard AT, no century register */
nvr->irq = 8;
local->cent = 0xff;
break;
case 1: /* standard AT */
nvr->irq = 8;
local->cent = RTC_CENTURY_AT;
break;
case 1: /* PS/1 or PS/2 */
case 2: /* PS/1 or PS/2 */
nvr->irq = 8;
local->cent = RTC_CENTURY_PS;
break;
case 2: /* Amstrad PC's */
case 3: /* Amstrad PC's */
nvr->irq = 1;
local->cent = RTC_CENTURY_AT;
break;
@@ -718,10 +733,19 @@ nvr_at_close(void *priv)
}
const device_t at_nvr_old_device = {
"PC/AT NVRAM (No century)",
DEVICE_ISA | DEVICE_AT,
0,
nvr_at_init, nvr_at_close, NULL,
NULL, NULL,
NULL
};
const device_t at_nvr_device = {
"PC/AT NVRAM",
DEVICE_ISA | DEVICE_AT,
0,
1,
nvr_at_init, nvr_at_close, NULL,
NULL, NULL,
NULL
@@ -730,7 +754,7 @@ const device_t at_nvr_device = {
const device_t ps_nvr_device = {
"PS/1 or PS/2 NVRAM",
DEVICE_PS2,
1,
2,
nvr_at_init, nvr_at_close, NULL,
NULL, NULL,
NULL
@@ -739,7 +763,7 @@ const device_t ps_nvr_device = {
const device_t amstrad_nvr_device = {
"Amstrad NVRAM",
MACHINE_ISA | MACHINE_AT,
2,
3,
nvr_at_init, nvr_at_close, NULL,
NULL, NULL,
NULL

View File

@@ -8,7 +8,7 @@
*
* Main emulator module where most things are controlled.
*
* Version: @(#)pc.c 1.0.71 2018/04/29
* Version: @(#)pc.c 1.0.73 2018/06/02
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -57,9 +57,10 @@
#include "disk/hdd.h"
#include "disk/hdc.h"
#include "disk/hdc_ide.h"
#include "disk/zip.h"
#include "scsi/scsi.h"
#include "cdrom/cdrom.h"
#include "disk/zip.h"
#include "scsi/scsi_disk.h"
#include "cdrom/cdrom_image.h"
#include "cdrom/cdrom_null.h"
#include "network/network.h"
@@ -103,8 +104,7 @@ int vid_cga_contrast = 0, /* (C) video */
video_fullscreen_scale = 0, /* (C) video */
video_fullscreen_first = 0, /* (C) video */
enable_overscan = 0, /* (C) video */
force_43 = 0, /* (C) video */
video_speed = 0; /* (C) video */
force_43 = 0; /* (C) video */
int serial_enabled[SERIAL_MAX] = {0,0}, /* (C) enable serial ports */
lpt_enabled = 0, /* (C) enable LPT ports */
bugger_enabled = 0; /* (C) enable ISAbugger */
@@ -416,6 +416,11 @@ usage:
*/
wcscpy(usr_path, path);
}
/* If the specified path does not yet exist,
create it. */
if (! plat_dir_check(path))
plat_dir_create(path);
}
/* Make sure we have a trailing backslash. */
@@ -484,6 +489,7 @@ usage:
mouse_init();
cdrom_global_init();
zip_global_init();
scsi_disk_global_init();
/* Load the configuration file. */
config_load();
@@ -500,9 +506,9 @@ pc_full_speed(void)
if (! atfullspeed) {
pc_log("Set fullspeed - %i %i %i\n", is386, AT, cpuspeed2);
if (AT)
if (machines[machine].cpu[cpu_manufacturer].cpus[cpu_effective].cpu_type >= CPU_286)
setpitclock(machines[machine].cpu[cpu_manufacturer].cpus[cpu_effective].rspeed);
else
else
setpitclock(14318184.0);
}
atfullspeed = 1;
@@ -514,9 +520,9 @@ pc_full_speed(void)
void
pc_speed_changed(void)
{
if (AT)
if (machines[machine].cpu[cpu_manufacturer].cpus[cpu_effective].cpu_type >= CPU_286)
setpitclock(machines[machine].cpu[cpu_manufacturer].cpus[cpu_effective].rspeed);
else
else
setpitclock(14318184.0);
nvr_period_recalc();
@@ -548,6 +554,8 @@ pc_reload(wchar_t *fn)
zip_hard_reset();
scsi_disk_hard_reset();
fdd_load(0, floppyfns[0]);
fdd_load(1, floppyfns[1]);
fdd_load(2, floppyfns[2]);
@@ -625,7 +633,8 @@ again2:
}
}
cpuspeed2 = (AT) ? 2 : 1;
// cpuspeed2 = (AT) ? 2 : 1;
cpuspeed2 = (machines[machine].cpu[cpu_manufacturer].cpus[cpu_effective].cpu_type >= CPU_286) ? 2 : 1;
atfullspeed = 0;
random_init();
@@ -650,8 +659,11 @@ again2:
hdc_init(hdc_name);
cdrom_hard_reset();
zip_hard_reset();
scsi_disk_hard_reset();
scsi_card_init();
pc_full_speed();
@@ -748,8 +760,11 @@ pc_reset_hard_init(void)
serial_init();
cdrom_hard_reset();
zip_hard_reset();
scsi_disk_hard_reset();
/* Initialize the actual machine and its basic modules. */
machine_init();
@@ -813,7 +828,7 @@ pc_reset_hard_init(void)
pic_reset();
cpu_cache_int_enabled = cpu_cache_ext_enabled = 0;
if (AT)
if (machines[machine].cpu[cpu_manufacturer].cpus[cpu_effective].cpu_type >= CPU_286)
setpitclock(machines[machine].cpu[cpu_manufacturer].cpus[cpu_effective].rspeed);
else
setpitclock(14318184.0);
@@ -876,9 +891,6 @@ pc_close(thread_t *ptr)
lpt_devices_close();
for (i=0; i<ZIP_NUM; i++)
zip_close(i);
for (i=0; i<FDD_NUM; i++)
fdd_close(i);
@@ -897,7 +909,9 @@ pc_close(thread_t *ptr)
sound_cd_thread_end();
cdrom_close();
zip_destroy_drives();
zip_close();
scsi_disk_close();
}
@@ -949,7 +963,7 @@ pc_thread(void *param)
else
#endif
exec386(clockrate/100);
} else if (AT) {
} else if (machines[machine].cpu[cpu_manufacturer].cpus[cpu_effective].cpu_type >= CPU_286) {
exec386(clockrate/100);
} else {
execx86(clockrate/100);

View File

@@ -2,6 +2,7 @@
Write B0
Write aa55
Expects aa55 back*/
#include <inttypes.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>

View File

@@ -8,7 +8,7 @@
*
* Handling of the SCSI controllers.
*
* Version: @(#)scsi.c 1.0.19 2018/04/29
* Version: @(#)scsi.c 1.0.20 2018/06/02
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -30,10 +30,12 @@
#include "../timer.h"
#include "../device.h"
#include "../disk/hdc.h"
#include "../disk/zip.h"
#include "../disk/hdd.h"
#include "../plat.h"
#include "scsi.h"
#include "../cdrom/cdrom.h"
#include "../disk/zip.h"
#include "scsi_disk.h"
#include "scsi_device.h"
#include "scsi_aha154x.h"
#include "scsi_buslogic.h"
@@ -45,11 +47,9 @@
#include "scsi_x54x.h"
scsi_device_t SCSIDevices[SCSI_ID_MAX][SCSI_LUN_MAX];
// uint8_t SCSIPhase = 0xff;
// uint8_t SCSIStatus = SCSI_STATUS_OK;
scsi_device_t SCSIDevices[SCSI_ID_MAX];
char scsi_fn[SCSI_NUM][512];
uint16_t scsi_hd_location[SCSI_NUM];
uint16_t scsi_disk_location[SCSI_NUM];
int scsi_card_current = 0;
int scsi_card_last = 0;
@@ -169,30 +169,30 @@ void scsi_mutex(uint8_t start)
void scsi_card_init(void)
{
int i, j;
int i;
if (!scsi_cards[scsi_card_current].device)
return;
scsi_log("Building SCSI hard disk map...\n");
build_scsi_hd_map();
build_scsi_disk_map();
scsi_log("Building SCSI CD-ROM map...\n");
build_scsi_cdrom_map();
scsi_log("Building SCSI ZIP map...\n");
build_scsi_zip_map();
for (i=0; i<SCSI_ID_MAX; i++) {
for (j=0; j<SCSI_LUN_MAX; j++) {
if (scsi_hard_disks[i][j] != 0xff)
SCSIDevices[i][j].LunType = SCSI_DISK;
else if (scsi_cdrom_drives[i][j] != 0xff)
SCSIDevices[i][j].LunType = SCSI_CDROM;
else if (scsi_zip_drives[i][j] != 0xff)
SCSIDevices[i][j].LunType = SCSI_ZIP;
else
SCSIDevices[i][j].LunType = SCSI_NONE;
SCSIDevices[i][j].CmdBuffer = NULL;
}
if (scsi_disks[i] != 0xff)
SCSIDevices[i].LunType = SCSI_DISK;
else if (scsi_cdrom_drives[i] != 0xff)
SCSIDevices[i].LunType = SCSI_CDROM;
else if (scsi_zip_drives[i] != 0xff)
SCSIDevices[i].LunType = SCSI_ZIP;
else
SCSIDevices[i].LunType = SCSI_NONE;
if (SCSIDevices[i].CmdBuffer)
free(SCSIDevices[i].CmdBuffer);
SCSIDevices[i].CmdBuffer = NULL;
}
device_add(scsi_cards[scsi_card_current].device);
@@ -202,27 +202,26 @@ void scsi_card_init(void)
/* Initialization function for the SCSI layer */
void SCSIReset(uint8_t id, uint8_t lun)
void SCSIReset(uint8_t id)
{
uint8_t cdrom_id = scsi_cdrom_drives[id][lun];
uint8_t zip_id = scsi_zip_drives[id][lun];
uint8_t hdc_id = scsi_hard_disks[id][lun];
uint8_t cdrom_id = scsi_cdrom_drives[id];
uint8_t zip_id = scsi_zip_drives[id];
uint8_t hdc_id = scsi_disks[id];
if (hdc_id != 0xff)
SCSIDevices[id][lun].LunType = SCSI_DISK;
SCSIDevices[id].LunType = SCSI_DISK;
else if (cdrom_id != 0xff)
SCSIDevices[id][lun].LunType = SCSI_CDROM;
SCSIDevices[id].LunType = SCSI_CDROM;
else if (zip_id != 0xff)
SCSIDevices[id][lun].LunType = SCSI_ZIP;
SCSIDevices[id].LunType = SCSI_ZIP;
else
SCSIDevices[id][lun].LunType = SCSI_NONE;
SCSIDevices[id].LunType = SCSI_NONE;
scsi_device_reset(id, lun);
scsi_device_reset(id);
if (SCSIDevices[id][lun].CmdBuffer != NULL) {
free(SCSIDevices[id][lun].CmdBuffer);
SCSIDevices[id][lun].CmdBuffer = NULL;
}
if (SCSIDevices[id].CmdBuffer)
free(SCSIDevices[id].CmdBuffer);
SCSIDevices[id].CmdBuffer = NULL;
}

View File

@@ -8,7 +8,7 @@
*
* SCSI controller handler header.
*
* Version: @(#)scsi_h 1.0.16 2018/03/28
* Version: @(#)scsi_h 1.0.17 2018/06/02
*
* Authors: TheCollector1995, <mariogplayer@gmail.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -290,9 +290,9 @@ typedef struct {
} scsi_device_t;
extern scsi_device_t SCSIDevices[SCSI_ID_MAX][SCSI_LUN_MAX];
extern scsi_device_t SCSIDevices[SCSI_ID_MAX];
extern void SCSIReset(uint8_t id, uint8_t lun);
extern void SCSIReset(uint8_t id);
extern int cdrom_add_error_and_subchannel(uint8_t *b, int real_sector_type);
extern int cdrom_LBAtoMSF_accurate(void);
@@ -314,17 +314,6 @@ extern int scsi_card_get_from_internal_name(char *s);
extern void scsi_mutex(uint8_t start);
extern void scsi_card_init(void);
extern uint8_t scsi_hard_disks[16][8];
extern int scsi_hd_err_stat_to_scsi(uint8_t id);
extern int scsi_hd_phase_to_scsi(uint8_t id);
extern int find_hdc_for_scsi_id(uint8_t scsi_id, uint8_t scsi_lun);
extern void build_scsi_hd_map(void);
extern void scsi_hd_reset(uint8_t id);
extern void scsi_hd_request_sense_for_scsi(uint8_t id, uint8_t *buffer, uint8_t alloc_length);
extern void scsi_hd_command(uint8_t id, uint8_t *cdb);
extern void scsi_hd_callback(uint8_t id);
#pragma pack(push,1)
typedef struct {

View File

@@ -10,7 +10,7 @@
* made by Adaptec, Inc. These controllers were designed for
* the ISA bus.
*
* Version: @(#)scsi_aha154x.c 1.0.41 2018/04/26
* Version: @(#)scsi_aha154x.c 1.0.42 2018/06/12
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Original Buslogic version by SA1988 and Miran Grca.
@@ -573,7 +573,7 @@ aha_mca_write(int port, uint8_t val, void *priv)
}
/* Say hello. */
pclog("AHA-1640: I/O=%04x, IRQ=%d, DMA=%d, BIOS @%05X, HOST ID %i\n",
aha_log("AHA-1640: I/O=%04x, IRQ=%d, DMA=%d, BIOS @%05X, HOST ID %i\n",
dev->Base, dev->Irq, dev->DmaChannel, dev->rom_addr, dev->HostID);
}
}

View File

@@ -8,7 +8,7 @@
*
* The generic SCSI bus operations handler.
*
* Version: @(#)scsi_bus.c 1.0.6 2018/01/06
* Version: @(#)scsi_bus.c 1.0.7 2018/06/18
*
* NOTES: For now ported from PCem with some modifications
* but at least it's a start.
@@ -94,7 +94,6 @@ int
scsi_bus_update(scsi_bus_t *bus, int bus_assert)
{
scsi_device_t *dev;
uint8_t lun = 0;
if (bus_assert & BUS_ARB)
bus->state = STATE_IDLE;
@@ -108,7 +107,7 @@ scsi_bus_update(scsi_bus_t *bus, int bus_assert)
bus->dev_id = get_dev_id(sel_data);
if ((bus->dev_id != -1) && scsi_device_present(bus->dev_id, 0)) {
if ((bus->dev_id != -1) && scsi_device_present(bus->dev_id)) {
bus->bus_out |= BUS_BSY;
bus->state = STATE_PHASESEL;
}
@@ -122,7 +121,7 @@ scsi_bus_update(scsi_bus_t *bus, int bus_assert)
if (! (bus_assert & BUS_SEL)) {
if (! (bus_assert & BUS_ATN)) {
if ((bus->dev_id != -1) &&
scsi_device_present(bus->dev_id, 0)) {
scsi_device_present(bus->dev_id)) {
bus->state = STATE_COMMAND;
bus->bus_out = BUS_BSY | BUS_REQ;
bus->command_pos = 0;
@@ -146,20 +145,17 @@ scsi_bus_update(scsi_bus_t *bus, int bus_assert)
bus->bus_out &= ~BUS_REQ;
if (get_cmd_len(bus->command[0]) == bus->command_pos) {
lun = (bus->command[1] >> 5) & 7;
bus->data_pos = 0;
dev = &SCSIDevices[bus->dev_id][lun];
dev = &SCSIDevices[bus->dev_id];
scsi_bus_log("Command 0x%02X\n", bus->command[0]);
dev->BufferLength = -1;
scsi_device_command_phase0(bus->dev_id, lun,
get_cmd_len(bus->command[0]),
bus->command);
scsi_device_command_phase0(bus->dev_id, bus->command);
scsi_bus_log("(%02X:%02X): Command %02X: Buffer Length %i, SCSI Phase %02X\n", bus->dev_id, lun, bus->command[0], dev->BufferLength, dev->Phase);
scsi_bus_log("(ID %02X): Command %02X: Buffer Length %i, SCSI Phase %02X\n", bus->dev_id, bus->command[0], dev->BufferLength, dev->Phase);
if ((dev->Phase == SCSI_PHASE_DATA_IN) ||
(dev->Phase == SCSI_PHASE_DATA_OUT)) {
@@ -178,7 +174,7 @@ scsi_bus_update(scsi_bus_t *bus, int bus_assert)
/* Other command - execute immediately. */
bus->new_state = dev->Phase;
if (dev->Phase == SCSI_PHASE_DATA_IN) {
scsi_device_command_phase1(bus->dev_id, lun);
scsi_device_command_phase1(bus->dev_id);
}
bus->change_state_delay = 4;
@@ -198,12 +194,9 @@ scsi_bus_update(scsi_bus_t *bus, int bus_assert)
scsi_bus_log("State Data In\n");
/* This seems to be read, so we first execute the command, then we return the bytes to the host. */
dev = &SCSIDevices[bus->dev_id];
lun = (bus->command[1] >> 5) & 7;
dev = &SCSIDevices[bus->dev_id][lun];
if (bus->data_pos >= SCSIDevices[bus->dev_id][lun].BufferLength) {
if (bus->data_pos >= SCSIDevices[bus->dev_id].BufferLength) {
free(dev->CmdBuffer);
dev->CmdBuffer = NULL;
bus->bus_out &= ~BUS_REQ;
@@ -224,18 +217,15 @@ scsi_bus_update(scsi_bus_t *bus, int bus_assert)
case STATE_DATAOUT:
if ((bus_assert & BUS_ACK) && !(bus->bus_in & BUS_ACK)) {
scsi_bus_log("State Data Out\n");
lun = (bus->command[1] >> 5) & 7;
dev = &SCSIDevices[bus->dev_id][lun];
dev = &SCSIDevices[bus->dev_id];
/* This is write, so first get the data from the host, then execute the last phase of the command. */
dev->CmdBuffer[bus->data_pos++] = BUS_GETDATA(bus_assert);
if (bus->data_pos >= SCSIDevices[bus->dev_id][lun].BufferLength) {
if (bus->data_pos >= SCSIDevices[bus->dev_id].BufferLength) {
/* scsi_bus_log("%04X bytes written (%02X %02X)\n", bus->data_pos, bus->command[0], bus->command[1]); */
scsi_bus_log("Actually executing write command\n");
scsi_device_command_phase1(bus->dev_id, lun);
scsi_device_command_phase1(bus->dev_id);
free(dev->CmdBuffer);
dev->CmdBuffer = NULL;
bus->bus_out &= ~BUS_REQ;
@@ -281,7 +271,6 @@ int
scsi_bus_read(scsi_bus_t *bus)
{
scsi_device_t *dev;
uint8_t lun = 0;
if (bus->clear_req) {
bus->clear_req--;
@@ -304,8 +293,7 @@ scsi_bus_read(scsi_bus_t *bus)
switch (bus->bus_out & SCSI_PHASE_MESSAGE_IN) {
case SCSI_PHASE_DATA_IN:
lun = (bus->command[1] >> 5) & 7;
dev = &SCSIDevices[bus->dev_id][lun];
dev = &SCSIDevices[bus->dev_id];
scsi_bus_log("Phase data in\n");
bus->state = STATE_DATAIN;
@@ -324,8 +312,7 @@ scsi_bus_read(scsi_bus_t *bus)
break;
case SCSI_PHASE_STATUS:
lun = (bus->command[1] >> 5) & 7;
dev = &SCSIDevices[bus->dev_id][lun];
dev = &SCSIDevices[bus->dev_id];
scsi_bus_log("Phase status\n");
bus->state = STATE_STATUS;

View File

@@ -11,7 +11,7 @@
* 1 - BT-545S ISA;
* 2 - BT-958D PCI
*
* Version: @(#)scsi_buslogic.c 1.0.38 2018/04/26
* Version: @(#)scsi_buslogic.c 1.0.39 2018/06/11
*
* Authors: TheCollector1995, <mariogplayer@gmail.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -480,7 +480,7 @@ buslogic_get_irq(void *p)
HALocalRAM *HALR = &bl->LocalRAM;
if (bl->chip == CHIP_BUSLOGIC_PCI)
if ((bl->chip == CHIP_BUSLOGIC_ISA_542) || (bl->chip == CHIP_BUSLOGIC_PCI))
return dev->Irq;
else
return bl_irq[HALR->structured.autoSCSIData.uIrqChannel];
@@ -499,6 +499,8 @@ buslogic_get_dma(void *p)
if (bl->chip == CHIP_BUSLOGIC_PCI)
return (dev->Base ? 7 : 0);
else if (bl->chip == CHIP_BUSLOGIC_ISA_542)
return dev->DmaChannel;
else
return bl_dma[HALR->structured.autoSCSIData.uDMAChannel];
}
@@ -548,7 +550,7 @@ buslogic_param_len(void *p)
static void
BuslogicSCSIBIOSDMATransfer(ESCMD *ESCSICmd, uint8_t TargetID, uint8_t LUN, int dir)
BuslogicSCSIBIOSDMATransfer(ESCMD *ESCSICmd, uint8_t TargetID, int dir)
{
uint32_t DataPointer = ESCSICmd->DataPointer;
int DataLength = ESCSICmd->DataLength;
@@ -565,16 +567,16 @@ BuslogicSCSIBIOSDMATransfer(ESCMD *ESCSICmd, uint8_t TargetID, uint8_t LUN, int
/* If the control byte is 0x00, it means that the transfer direction is set up by the SCSI command without
checking its length, so do this procedure for both read/write commands. */
if ((DataLength > 0) && (SCSIDevices[TargetID][LUN].BufferLength > 0)) {
if ((DataLength > 0) && (SCSIDevices[TargetID].BufferLength > 0)) {
Address = DataPointer;
TransferLength = MIN(DataLength, SCSIDevices[TargetID][LUN].BufferLength);
TransferLength = MIN(DataLength, SCSIDevices[TargetID].BufferLength);
if (dir && ((ESCSICmd->DataDirection == CCB_DATA_XFER_OUT) || (ESCSICmd->DataDirection == 0x00))) {
buslogic_log("BusLogic BIOS DMA: Reading %i bytes from %08X\n", TransferLength, Address);
DMAPageRead(Address, (uint8_t *)SCSIDevices[TargetID][LUN].CmdBuffer, TransferLength);
DMAPageRead(Address, (uint8_t *)SCSIDevices[TargetID].CmdBuffer, TransferLength);
} else if (!dir && ((ESCSICmd->DataDirection == CCB_DATA_XFER_IN) || (ESCSICmd->DataDirection == 0x00))) {
buslogic_log("BusLogic BIOS DMA: Writing %i bytes at %08X\n", TransferLength, Address);
DMAPageWrite(Address, (uint8_t *)SCSIDevices[TargetID][LUN].CmdBuffer, TransferLength);
DMAPageWrite(Address, (uint8_t *)SCSIDevices[TargetID].CmdBuffer, TransferLength);
}
}
}
@@ -600,14 +602,14 @@ BuslogicSCSIBIOSRequestSetup(x54x_t *dev, uint8_t *CmdBuf, uint8_t *DataInBuf, u
buslogic_log("Scanning SCSI Target ID %i\n", ESCSICmd->TargetId);
SCSIDevices[ESCSICmd->TargetId][ESCSICmd->LogicalUnit].Status = SCSI_STATUS_OK;
SCSIDevices[ESCSICmd->TargetId].Status = SCSI_STATUS_OK;
if (!scsi_device_present(ESCSICmd->TargetId, 0)) {
buslogic_log("SCSI Target ID %i has no device attached\n",ESCSICmd->TargetId,ESCSICmd->LogicalUnit);
if (!scsi_device_present(ESCSICmd->TargetId)) {
buslogic_log("SCSI Target ID %i has no device attached\n", ESCSICmd->TargetId);
DataInBuf[2] = CCB_SELECTION_TIMEOUT;
DataInBuf[3] = SCSI_STATUS_OK;
} else {
buslogic_log("SCSI Target ID %i detected and working\n", ESCSICmd->TargetId, ESCSICmd->LogicalUnit);
buslogic_log("SCSI Target ID %i detected and working\n", ESCSICmd->TargetId);
buslogic_log("Transfer Control %02X\n", ESCSICmd->DataDirection);
buslogic_log("CDB Length %i\n", ESCSICmd->CDBLength);
@@ -617,11 +619,11 @@ BuslogicSCSIBIOSRequestSetup(x54x_t *dev, uint8_t *CmdBuf, uint8_t *DataInBuf, u
}
}
x54x_buf_alloc(ESCSICmd->TargetId, ESCSICmd->LogicalUnit, ESCSICmd->DataLength);
x54x_buf_alloc(ESCSICmd->TargetId, ESCSICmd->DataLength);
target_cdb_len = scsi_device_cdb_length(ESCSICmd->TargetId, ESCSICmd->LogicalUnit);
target_cdb_len = 12;
if (!scsi_device_valid(ESCSICmd->TargetId, ESCSICmd->LogicalUnit)) fatal("SCSI target on %02i:%02i has disappeared\n", ESCSICmd->TargetId, ESCSICmd->LogicalUnit);
if (!scsi_device_valid(ESCSICmd->TargetId)) fatal("SCSI target on ID %02i has disappeared\n", ESCSICmd->TargetId);
buslogic_log("SCSI target command being executed on: SCSI ID %i, SCSI LUN %i, Target %i\n", ESCSICmd->TargetId, ESCSICmd->LogicalUnit, target_id);
@@ -637,26 +639,26 @@ BuslogicSCSIBIOSRequestSetup(x54x_t *dev, uint8_t *CmdBuf, uint8_t *DataInBuf, u
memcpy(temp_cdb, ESCSICmd->CDB, target_cdb_len);
}
SCSIDevices[ESCSICmd->TargetId][ESCSICmd->LogicalUnit].BufferLength = ESCSICmd->DataLength;
scsi_device_command_phase0(ESCSICmd->TargetId, ESCSICmd->LogicalUnit, ESCSICmd->CDBLength, temp_cdb);
SCSIDevices[ESCSICmd->TargetId].BufferLength = ESCSICmd->DataLength;
scsi_device_command_phase0(ESCSICmd->TargetId, temp_cdb);
phase = SCSIDevices[ESCSICmd->TargetId][ESCSICmd->LogicalUnit].Phase;
phase = SCSIDevices[ESCSICmd->TargetId].Phase;
if (phase != SCSI_PHASE_STATUS) {
if (phase == SCSI_PHASE_DATA_IN)
scsi_device_command_phase1(ESCSICmd->TargetId, ESCSICmd->LogicalUnit);
BuslogicSCSIBIOSDMATransfer(ESCSICmd, ESCSICmd->TargetId, ESCSICmd->LogicalUnit, (phase == SCSI_PHASE_DATA_OUT));
scsi_device_command_phase1(ESCSICmd->TargetId);
BuslogicSCSIBIOSDMATransfer(ESCSICmd, ESCSICmd->TargetId, (phase == SCSI_PHASE_DATA_OUT));
if (phase == SCSI_PHASE_DATA_OUT)
scsi_device_command_phase1(ESCSICmd->TargetId, ESCSICmd->LogicalUnit);
scsi_device_command_phase1(ESCSICmd->TargetId);
}
x54x_buf_free(ESCSICmd->TargetId, ESCSICmd->LogicalUnit);
x54x_buf_free(ESCSICmd->TargetId);
buslogic_log("BIOS Request complete\n");
if (SCSIDevices[ESCSICmd->TargetId][ESCSICmd->LogicalUnit].Status == SCSI_STATUS_OK) {
if (SCSIDevices[ESCSICmd->TargetId].Status == SCSI_STATUS_OK) {
DataInBuf[2] = CCB_COMPLETE;
DataInBuf[3] = SCSI_STATUS_OK;
} else if (SCSIDevices[ESCSICmd->TargetId][ESCSICmd->LogicalUnit].Status == SCSI_STATUS_CHECK_CONDITION) {
} else if (SCSIDevices[ESCSICmd->TargetId].Status == SCSI_STATUS_CHECK_CONDITION) {
DataInBuf[2] = CCB_COMPLETE;
DataInBuf[3] = SCSI_STATUS_CHECK_CONDITION;
}
@@ -677,7 +679,6 @@ buslogic_cmds(void *p)
uint16_t TargetsPresentMask = 0;
uint32_t Offset;
int i = 0;
int j = 0;
MailboxInitExtended_t *MailboxInitE;
ReplyInquireExtendedSetupInformation *ReplyIESI;
BuslogicPCIInformation_t *ReplyPI;
@@ -697,16 +698,14 @@ buslogic_cmds(void *p)
memset(dev->DataBuf, 0, 8);
for (i = 8; i < 15; i++) {
dev->DataBuf[i-8] = 0;
for (j=0; j<8; j++) {
if (scsi_device_present(i, j) && (i != buslogic_get_host_id(dev)))
dev->DataBuf[i-8] |= (1<<j);
}
if (scsi_device_present(i) && (i != buslogic_get_host_id(dev)))
dev->DataBuf[i-8] |= 1;
}
dev->DataReplyLeft = 8;
break;
case 0x24:
for (i=0; i<15; i++) {
if (scsi_device_present(i, 0) && (i != buslogic_get_host_id(dev)))
if (scsi_device_present(i) && (i != buslogic_get_host_id(dev)))
TargetsPresentMask |= (1 << i);
}
dev->DataBuf[0] = TargetsPresentMask & 0xFF;
@@ -1387,6 +1386,7 @@ buslogic_mca_write(int port, uint8_t val, void *priv)
* pos[2]=000xxxxx = 0
*/
dev->HostID = (dev->pos_regs[4] >> 5) & 0x07;
HALR->structured.autoSCSIData.uSCSIId = dev->HostID;
/*
* SYNC mode is pos[2]=xxxxxx1x.
@@ -1406,6 +1406,45 @@ buslogic_mca_write(int port, uint8_t val, void *priv)
HALR->structured.autoSCSIData.uBIOSConfiguration &= ~4;
HALR->structured.autoSCSIData.uBIOSConfiguration |= (dev->pos_regs[4] & 8) ? 4 : 0;
switch(dev->DmaChannel) {
case 5:
HALR->structured.autoSCSIData.uDMAChannel = 1;
break;
case 6:
HALR->structured.autoSCSIData.uDMAChannel = 2;
break;
case 7:
HALR->structured.autoSCSIData.uDMAChannel = 3;
break;
default:
HALR->structured.autoSCSIData.uDMAChannel = 0;
break;
}
switch(dev->Irq) {
case 9:
HALR->structured.autoSCSIData.uIrqChannel = 1;
break;
case 10:
HALR->structured.autoSCSIData.uIrqChannel = 2;
break;
case 11:
HALR->structured.autoSCSIData.uIrqChannel = 3;
break;
case 12:
HALR->structured.autoSCSIData.uIrqChannel = 4;
break;
case 14:
HALR->structured.autoSCSIData.uIrqChannel = 5;
break;
case 15:
HALR->structured.autoSCSIData.uIrqChannel = 6;
break;
default:
HALR->structured.autoSCSIData.uIrqChannel = 0;
break;
}
/*
* The PS/2 Model 80 BIOS always enables a card if it finds one,
* even if no resources were assigned yet (because we only added
@@ -1430,8 +1469,8 @@ buslogic_mca_write(int port, uint8_t val, void *priv)
}
/* Say hello. */
pclog("BT-640A: I/O=%04x, IRQ=%d, DMA=%d, BIOS @%05X, HOST ID %i\n",
dev->Base, dev->Irq, dev->DmaChannel, bl->bios_addr, dev->HostID);
buslogic_log("BT-640A: I/O=%04x, IRQ=%d, DMA=%d, BIOS @%05X, HOST ID %i\n",
dev->Base, dev->Irq, dev->DmaChannel, bl->bios_addr, dev->HostID);
}
}

View File

@@ -8,7 +8,7 @@
*
* The generic SCSI device command handler.
*
* Version: @(#)scsi_device.c 1.0.16 2018/03/26
* Version: @(#)scsi_device.c 1.0.17 2018/06/02
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -23,120 +23,85 @@
#include "../86box.h"
#include "../device.h"
#include "../disk/hdd.h"
#include "../disk/zip.h"
#include "scsi.h"
#include "scsi_device.h"
#include "../cdrom/cdrom.h"
#include "../disk/zip.h"
#include "scsi_disk.h"
static uint8_t scsi_null_device_sense[14] = { 0x70,0,SENSE_ILLEGAL_REQUEST,0,0,0,0,0,0,0,0,0,ASC_INV_LUN,0 };
uint8_t scsi_null_device_sense[18] = { 0x70,0,SENSE_ILLEGAL_REQUEST,0,0,0,0,0,0,0,0,0,ASC_INV_LUN,0,0,0,0,0 };
static uint8_t scsi_device_target_command(int lun_type, uint8_t id, uint8_t *cdb)
static uint8_t
scsi_device_target_command(int lun_type, uint8_t id, uint8_t *cdb)
{
if (lun_type == SCSI_DISK)
{
scsi_hd_command(id, cdb);
return scsi_hd_err_stat_to_scsi(id);
}
else if (lun_type == SCSI_CDROM)
{
switch(lun_type) {
case SCSI_DISK:
scsi_disk_command(scsi_disk[id], cdb);
return scsi_disk_err_stat_to_scsi(scsi_disk[id]);
case SCSI_CDROM:
cdrom_command(cdrom[id], cdb);
return cdrom_CDROM_PHASE_to_scsi(cdrom[id]);
}
else if (lun_type == SCSI_ZIP)
{
zip_command(id, cdb);
return zip_ZIP_PHASE_to_scsi(id);
}
else
{
case SCSI_ZIP:
zip_command(zip[id], cdb);
return zip_ZIP_PHASE_to_scsi(zip[id]);
default:
return SCSI_STATUS_CHECK_CONDITION;
}
}
}
static void scsi_device_target_phase_callback(int lun_type, uint8_t id)
{
if (lun_type == SCSI_DISK)
{
scsi_hd_callback(id);
}
else if (lun_type == SCSI_CDROM)
{
switch(lun_type) {
case SCSI_DISK:
scsi_disk_callback(scsi_disk[id]);
break;
case SCSI_CDROM:
cdrom_phase_callback(cdrom[id]);
}
else if (lun_type == SCSI_ZIP)
{
zip_phase_callback(id);
}
else
{
return;
}
break;
case SCSI_ZIP:
zip_phase_callback(zip[id]);
break;
}
return;
}
static int scsi_device_target_err_stat_to_scsi(int lun_type, uint8_t id)
{
if (lun_type == SCSI_DISK)
{
return scsi_hd_err_stat_to_scsi(id);
}
else if (lun_type == SCSI_CDROM)
{
switch(lun_type) {
case SCSI_DISK:
return scsi_disk_err_stat_to_scsi(scsi_disk[id]);
case SCSI_CDROM:
return cdrom_CDROM_PHASE_to_scsi(cdrom[id]);
}
else if (lun_type == SCSI_ZIP)
{
return zip_ZIP_PHASE_to_scsi(id);
}
else
{
case SCSI_ZIP:
return zip_ZIP_PHASE_to_scsi(zip[id]);
default:
return SCSI_STATUS_CHECK_CONDITION;
}
}
}
static void scsi_device_target_save_cdb_byte(int lun_type, uint8_t id, uint8_t cdb_byte)
int64_t scsi_device_get_callback(uint8_t scsi_id)
{
if (lun_type == SCSI_DISK)
{
shdc[id].request_length = cdb_byte;
}
else if (lun_type == SCSI_CDROM)
{
cdrom[id]->request_length = cdb_byte;
}
else if (lun_type == SCSI_ZIP)
{
zip[id]->request_length = cdb_byte;
}
else
{
return;
}
}
int64_t scsi_device_get_callback(uint8_t scsi_id, uint8_t scsi_lun)
{
uint8_t lun_type = SCSIDevices[scsi_id][scsi_lun].LunType;
uint8_t lun_type = SCSIDevices[scsi_id].LunType;
uint8_t id = 0;
switch (lun_type)
{
case SCSI_DISK:
id = scsi_hard_disks[scsi_id][scsi_lun];
return shdc[id].callback;
id = scsi_disks[scsi_id];
return scsi_disk[id]->callback;
break;
case SCSI_CDROM:
id = scsi_cdrom_drives[scsi_id][scsi_lun];
id = scsi_cdrom_drives[scsi_id];
return cdrom[id]->callback;
break;
case SCSI_ZIP:
id = scsi_zip_drives[scsi_id][scsi_lun];
id = scsi_zip_drives[scsi_id];
return zip[id]->callback;
break;
default:
@@ -146,24 +111,24 @@ int64_t scsi_device_get_callback(uint8_t scsi_id, uint8_t scsi_lun)
}
uint8_t *scsi_device_sense(uint8_t scsi_id, uint8_t scsi_lun)
uint8_t *scsi_device_sense(uint8_t scsi_id)
{
uint8_t lun_type = SCSIDevices[scsi_id][scsi_lun].LunType;
uint8_t lun_type = SCSIDevices[scsi_id].LunType;
uint8_t id = 0;
switch (lun_type)
{
case SCSI_DISK:
id = scsi_hard_disks[scsi_id][scsi_lun];
return shdc[id].sense;
id = scsi_disks[scsi_id];
return scsi_disk[id]->sense;
break;
case SCSI_CDROM:
id = scsi_cdrom_drives[scsi_id][scsi_lun];
id = scsi_cdrom_drives[scsi_id];
return cdrom[id]->sense;
break;
case SCSI_ZIP:
id = scsi_zip_drives[scsi_id][scsi_lun];
id = scsi_zip_drives[scsi_id];
return zip[id]->sense;
break;
default:
@@ -173,25 +138,25 @@ uint8_t *scsi_device_sense(uint8_t scsi_id, uint8_t scsi_lun)
}
void scsi_device_request_sense(uint8_t scsi_id, uint8_t scsi_lun, uint8_t *buffer, uint8_t alloc_length)
void scsi_device_request_sense(uint8_t scsi_id, uint8_t *buffer, uint8_t alloc_length)
{
uint8_t lun_type = SCSIDevices[scsi_id][scsi_lun].LunType;
uint8_t lun_type = SCSIDevices[scsi_id].LunType;
uint8_t id = 0;
switch (lun_type)
{
case SCSI_DISK:
id = scsi_hard_disks[scsi_id][scsi_lun];
scsi_hd_request_sense_for_scsi(id, buffer, alloc_length);
id = scsi_disks[scsi_id];
scsi_disk_request_sense_for_scsi(scsi_disk[id], buffer, alloc_length);
break;
case SCSI_CDROM:
id = scsi_cdrom_drives[scsi_id][scsi_lun];
id = scsi_cdrom_drives[scsi_id];
cdrom_request_sense_for_scsi(cdrom[id], buffer, alloc_length);
break;
case SCSI_ZIP:
id = scsi_zip_drives[scsi_id][scsi_lun];
zip_request_sense_for_scsi(id, buffer, alloc_length);
id = scsi_zip_drives[scsi_id];
zip_request_sense_for_scsi(zip[id], buffer, alloc_length);
break;
default:
memcpy(buffer, scsi_null_device_sense, alloc_length);
@@ -200,33 +165,33 @@ void scsi_device_request_sense(uint8_t scsi_id, uint8_t scsi_lun, uint8_t *buffe
}
void scsi_device_reset(uint8_t scsi_id, uint8_t scsi_lun)
void scsi_device_reset(uint8_t scsi_id)
{
uint8_t lun_type = SCSIDevices[scsi_id][scsi_lun].LunType;
uint8_t lun_type = SCSIDevices[scsi_id].LunType;
uint8_t id = 0;
switch (lun_type)
{
case SCSI_DISK:
id = scsi_hard_disks[scsi_id][scsi_lun];
scsi_hd_reset(id);
id = scsi_disks[scsi_id];
scsi_disk_reset(scsi_disk[id]);
break;
case SCSI_CDROM:
id = scsi_cdrom_drives[scsi_id][scsi_lun];
id = scsi_cdrom_drives[scsi_id];
cdrom_reset(cdrom[id]);
break;
case SCSI_ZIP:
id = scsi_zip_drives[scsi_id][scsi_lun];
zip_reset(id);
id = scsi_zip_drives[scsi_id];
zip_reset(zip[id]);
break;
}
}
void scsi_device_type_data(uint8_t scsi_id, uint8_t scsi_lun, uint8_t *type, uint8_t *rmb)
void scsi_device_type_data(uint8_t scsi_id, uint8_t *type, uint8_t *rmb)
{
uint8_t lun_type = SCSIDevices[scsi_id][scsi_lun].LunType;
uint8_t lun_type = SCSIDevices[scsi_id].LunType;
switch (lun_type)
{
@@ -248,32 +213,32 @@ void scsi_device_type_data(uint8_t scsi_id, uint8_t scsi_lun, uint8_t *type, uin
}
int scsi_device_read_capacity(uint8_t scsi_id, uint8_t scsi_lun, uint8_t *cdb, uint8_t *buffer, uint32_t *len)
int scsi_device_read_capacity(uint8_t scsi_id, uint8_t *cdb, uint8_t *buffer, uint32_t *len)
{
uint8_t lun_type = SCSIDevices[scsi_id][scsi_lun].LunType;
uint8_t lun_type = SCSIDevices[scsi_id].LunType;
uint8_t id = 0;
switch (lun_type)
{
case SCSI_DISK:
id = scsi_hard_disks[scsi_id][scsi_lun];
return scsi_hd_read_capacity(id, cdb, buffer, len);
id = scsi_disks[scsi_id];
return scsi_disk_read_capacity(scsi_disk[id], cdb, buffer, len);
case SCSI_CDROM:
id = scsi_cdrom_drives[scsi_id][scsi_lun];
id = scsi_cdrom_drives[scsi_id];
return cdrom_read_capacity(cdrom[id], cdb, buffer, len);
case SCSI_ZIP:
id = scsi_zip_drives[scsi_id][scsi_lun];
return zip_read_capacity(id, cdb, buffer, len);
id = scsi_zip_drives[scsi_id];
return zip_read_capacity(zip[id], cdb, buffer, len);
default:
return 0;
}
}
int scsi_device_present(uint8_t scsi_id, uint8_t scsi_lun)
int scsi_device_present(uint8_t scsi_id)
{
uint8_t lun_type = SCSIDevices[scsi_id][scsi_lun].LunType;
uint8_t lun_type = SCSIDevices[scsi_id].LunType;
switch (lun_type)
{
@@ -285,22 +250,22 @@ int scsi_device_present(uint8_t scsi_id, uint8_t scsi_lun)
}
int scsi_device_valid(uint8_t scsi_id, uint8_t scsi_lun)
int scsi_device_valid(uint8_t scsi_id)
{
uint8_t lun_type = SCSIDevices[scsi_id][scsi_lun].LunType;
uint8_t lun_type = SCSIDevices[scsi_id].LunType;
uint8_t id = 0;
switch (lun_type)
{
case SCSI_DISK:
id = scsi_hard_disks[scsi_id][scsi_lun];
id = scsi_disks[scsi_id];
break;
case SCSI_CDROM:
id = scsi_cdrom_drives[scsi_id][scsi_lun];
id = scsi_cdrom_drives[scsi_id];
break;
case SCSI_ZIP:
id = scsi_zip_drives[scsi_id][scsi_lun];
id = scsi_zip_drives[scsi_id];
break;
default:
id = 0;
@@ -311,106 +276,74 @@ int scsi_device_valid(uint8_t scsi_id, uint8_t scsi_lun)
}
int scsi_device_cdb_length(uint8_t scsi_id, uint8_t scsi_lun)
int scsi_device_cdb_length(uint8_t scsi_id)
{
uint8_t lun_type = SCSIDevices[scsi_id][scsi_lun].LunType;
uint8_t id = 0;
switch (lun_type)
{
case SCSI_CDROM:
id = scsi_cdrom_drives[scsi_id][scsi_lun];
return cdrom[id]->cdb_len;
case SCSI_ZIP:
id = scsi_zip_drives[scsi_id][scsi_lun];
return zip[id]->cdb_len;
default:
return 12;
}
/* Right now, it's 12 for all devices. */
return 12;
}
void scsi_device_command_phase0(uint8_t scsi_id, uint8_t scsi_lun, int cdb_len, uint8_t *cdb)
void scsi_device_command_phase0(uint8_t scsi_id, uint8_t *cdb)
{
uint8_t lun_type = SCSIDevices[scsi_id][scsi_lun].LunType;
uint8_t id = 0;
uint8_t lun_type = SCSIDevices[scsi_id].LunType;
switch (lun_type)
{
switch (lun_type) {
case SCSI_DISK:
id = scsi_hard_disks[scsi_id][scsi_lun];
id = scsi_disks[scsi_id];
break;
case SCSI_CDROM:
id = scsi_cdrom_drives[scsi_id][scsi_lun];
id = scsi_cdrom_drives[scsi_id];
break;
case SCSI_ZIP:
id = scsi_zip_drives[scsi_id][scsi_lun];
id = scsi_zip_drives[scsi_id];
break;
default:
id = 0;
SCSIDevices[scsi_id][scsi_lun].Phase = SCSI_PHASE_STATUS;
SCSIDevices[scsi_id][scsi_lun].Status = SCSI_STATUS_CHECK_CONDITION;
SCSIDevices[scsi_id].Phase = SCSI_PHASE_STATUS;
SCSIDevices[scsi_id].Status = SCSI_STATUS_CHECK_CONDITION;
return;
}
/*
* Since that field in the target struct is never used when
* the bus type is SCSI, let's use it for this scope.
*/
scsi_device_target_save_cdb_byte(lun_type, id, cdb[1]);
if (cdb_len != 12) {
/*
* Make sure the LUN field of the temporary CDB is always 0,
* otherwise Daemon Tools drives will misbehave when a command
* is passed through to them.
*/
cdb[1] &= 0x1f;
}
/* Finally, execute the SCSI command immediately and get the transfer length. */
SCSIDevices[scsi_id][scsi_lun].Phase = SCSI_PHASE_COMMAND;
SCSIDevices[scsi_id][scsi_lun].Status = scsi_device_target_command(lun_type, id, cdb);
SCSIDevices[scsi_id].Phase = SCSI_PHASE_COMMAND;
SCSIDevices[scsi_id].Status = scsi_device_target_command(lun_type, id, cdb);
if (SCSIDevices[scsi_id][scsi_lun].Phase == SCSI_PHASE_STATUS) {
if (SCSIDevices[scsi_id].Phase == SCSI_PHASE_STATUS) {
/* Command completed (either OK or error) - call the phase callback to complete the command. */
scsi_device_target_phase_callback(lun_type, id);
}
/* If the phase is DATA IN or DATA OUT, finish this here. */
}
void scsi_device_command_phase1(uint8_t scsi_id, uint8_t scsi_lun)
void scsi_device_command_phase1(uint8_t scsi_id)
{
uint8_t lun_type = SCSIDevices[scsi_id][scsi_lun].LunType;
uint8_t id = 0;
uint8_t lun_type = SCSIDevices[scsi_id].LunType;
uint8_t id = 0;
switch (lun_type) {
case SCSI_DISK:
id = scsi_disks[scsi_id];
break;
case SCSI_CDROM:
id = scsi_cdrom_drives[scsi_id];
break;
case SCSI_ZIP:
id = scsi_zip_drives[scsi_id];
break;
default:
id = 0;
return;
}
switch (lun_type)
{
case SCSI_DISK:
id = scsi_hard_disks[scsi_id][scsi_lun];
break;
case SCSI_CDROM:
id = scsi_cdrom_drives[scsi_id][scsi_lun];
break;
case SCSI_ZIP:
id = scsi_zip_drives[scsi_id][scsi_lun];
break;
default:
id = 0;
return;
}
/* Call the second phase. */
scsi_device_target_phase_callback(lun_type, id);
SCSIDevices[scsi_id][scsi_lun].Status = scsi_device_target_err_stat_to_scsi(lun_type, id);
/* Command second phase complete - call the callback to complete the command. */
scsi_device_target_phase_callback(lun_type, id);
/* Call the second phase. */
scsi_device_target_phase_callback(lun_type, id);
SCSIDevices[scsi_id].Status = scsi_device_target_err_stat_to_scsi(lun_type, id);
/* Command second phase complete - call the callback to complete the command. */
scsi_device_target_phase_callback(lun_type, id);
}
int32_t *scsi_device_get_buf_len(uint8_t scsi_id, uint8_t scsi_lun)
int32_t *scsi_device_get_buf_len(uint8_t scsi_id)
{
return &SCSIDevices[scsi_id][scsi_lun].BufferLength;
return &SCSIDevices[scsi_id].BufferLength;
}

View File

@@ -8,7 +8,7 @@
*
* Definitions for the generic SCSI device command handler.
*
* Version: @(#)scsi_device.h 1.0.7 2018/03/29
* Version: @(#)scsi_device.h 1.0.8 2018/06/12
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -32,26 +32,21 @@ typedef struct
int new_req_delay;
} scsi_bus_t;
extern uint8_t *scsi_device_sense(uint8_t id, uint8_t lun);
extern void scsi_device_type_data(uint8_t id, uint8_t lun,
uint8_t *type, uint8_t *rmb);
extern int64_t scsi_device_get_callback(uint8_t scsi_id, uint8_t scsi_lun);
extern void scsi_device_request_sense(uint8_t scsi_id, uint8_t scsi_lun,
uint8_t *buffer,
extern uint8_t *scsi_device_sense(uint8_t id);
extern void scsi_device_type_data(uint8_t id, uint8_t *type, uint8_t *rmb);
extern int64_t scsi_device_get_callback(uint8_t scsi_id);
extern void scsi_device_request_sense(uint8_t scsi_id, uint8_t *buffer,
uint8_t alloc_length);
extern void scsi_device_reset(uint8_t scsi_id, uint8_t scsi_lun);
extern int scsi_device_read_capacity(uint8_t id, uint8_t lun,
uint8_t *cdb, uint8_t *buffer,
uint32_t *len);
extern int scsi_device_present(uint8_t id, uint8_t lun);
extern int scsi_device_valid(uint8_t id, uint8_t lun);
extern int scsi_device_cdb_length(uint8_t id, uint8_t lun);
extern void scsi_device_command(uint8_t id, uint8_t lun, int cdb_len,
uint8_t *cdb);
extern void scsi_device_command_phase0(uint8_t scsi_id, uint8_t scsi_lun,
int cdb_len, uint8_t *cdb);
extern void scsi_device_command_phase1(uint8_t scsi_id, uint8_t scsi_lun);
extern int32_t *scsi_device_get_buf_len(uint8_t scsi_id, uint8_t scsi_lun);
extern void scsi_device_reset(uint8_t scsi_id);
extern int scsi_device_read_capacity(uint8_t id, uint8_t *cdb,
uint8_t *buffer, uint32_t *len);
extern int scsi_device_present(uint8_t id);
extern int scsi_device_valid(uint8_t id);
extern int scsi_device_cdb_length(uint8_t id);
extern void scsi_device_command(uint8_t id, int cdb_len, uint8_t *cdb);
extern void scsi_device_command_phase0(uint8_t scsi_id, uint8_t *cdb);
extern void scsi_device_command_phase1(uint8_t scsi_id);
extern int32_t *scsi_device_get_buf_len(uint8_t scsi_id);
extern int scsi_bus_update(scsi_bus_t *bus, int bus_assert);
extern int scsi_bus_read(scsi_bus_t *bus);

File diff suppressed because it is too large Load Diff

View File

@@ -6,7 +6,7 @@
*
* Emulation of SCSI fixed and removable disks.
*
* Version: @(#)scsi_disk.h 1.0.4 2018/04/24
* Version: @(#)scsi_disk.h 1.0.5 2018/06/02
*
* Author: Miran Grca, <mgrca8@gmail.com>
* Copyright 2017,2018 Miran Grca.
@@ -14,32 +14,47 @@
typedef struct {
/* Stuff for SCSI hard disks. */
uint8_t status, phase,
error,
current_cdb[16],
sense[256];
mode_sense_pages_t ms_pages_saved;
uint16_t request_length;
hard_disk_t *drv;
int requested_blocks, block_total,
packet_status, callback,
block_descriptor_len,
total_length, do_page_save;
/* Stuff for SCSI hard disks. */
uint8_t status, phase,
error, id,
current_cdb[16],
sense[256];
uint32_t sector_pos, sector_len,
packet_len;
uint16_t request_length;
uint64_t current_page_code;
int requested_blocks, block_total,
packet_status, callback,
block_descriptor_len,
total_length, do_page_save;
uint8_t *temp_buffer;
} scsi_hard_disk_t;
uint32_t sector_pos, sector_len,
packet_len;
uint64_t current_page_code;
uint8_t *temp_buffer;
} scsi_disk_t;
extern scsi_hard_disk_t shdc[HDD_NUM];
extern FILE *shdf[HDD_NUM];
extern scsi_disk_t *scsi_disk[HDD_NUM];
extern uint8_t scsi_disks[16];
extern void scsi_loadhd(int scsi_id, int scsi_lun, int id);
extern void scsi_loadhd(int scsi_id, int id);
extern void scsi_disk_global_init(void);
extern void scsi_disk_hard_reset(void);
extern void scsi_disk_close(void);
int scsi_hd_read_capacity(uint8_t id, uint8_t *cdb, uint8_t *buffer, uint32_t *len);
extern int scsi_disk_read_capacity(scsi_disk_t *dev, uint8_t *cdb, uint8_t *buffer, uint32_t *len);
extern int scsi_disk_err_stat_to_scsi(scsi_disk_t *dev);
extern int scsi_disk_phase_to_scsi(scsi_disk_t *dev);
extern int find_hdd_for_scsi_id(uint8_t scsi_id);
extern void build_scsi_disk_map(void);
extern void scsi_disk_reset(scsi_disk_t *dev);
extern void scsi_disk_request_sense_for_scsi(scsi_disk_t *dev, uint8_t *buffer, uint8_t alloc_length);
extern void scsi_disk_command(scsi_disk_t *dev, uint8_t *cdb);
extern void scsi_disk_callback(scsi_disk_t *dev);

View File

@@ -9,7 +9,7 @@
* Implementation of the NCR 5380 series of SCSI Host Adapters
* made by NCR. These controllers were designed for the ISA bus.
*
* Version: @(#)scsi_ncr5380.c 1.0.14 2018/04/26
* Version: @(#)scsi_ncr5380.c 1.0.15 2018/06/13
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* TheCollector1995, <mariogplayer@gmail.com>
@@ -290,7 +290,7 @@ ncr_write(uint16_t port, uint8_t val, void *priv)
default:
#if 1
pclog("NCR5380: bad write %04x %02x\n", port, val);
ncr_log("NCR5380: bad write %04x %02x\n", port, val);
#endif
break;
}
@@ -496,7 +496,7 @@ dma_callback(void *priv)
default:
#if 1
pclog("DMA callback bad mode %i\n", scsi->ncr.dma_mode);
ncr_log("DMA callback bad mode %i\n", scsi->ncr.dma_mode);
#endif
break;
}
@@ -668,9 +668,12 @@ t130b_read(uint32_t addr, void *priv)
uint8_t ret = 0xff;
addr &= 0x3fff;
if (addr < 0x1800)
if ((addr < 0x1800) && scsi->rom_addr)
ret = scsi->bios_rom.rom[addr & 0x1fff];
else
if ((addr < 0x1800) && !scsi->rom_addr)
ret = 0xff;
else
if (addr < 0x1880)
ret = scsi->ext_ram[addr & 0x7f];
@@ -849,47 +852,79 @@ ncr_init(const device_t *info)
break;
case 1: /* Ranco RT1000B */
scsi->rom_addr = 0xDC000;
rom_init(&scsi->bios_rom, RT1000B_ROM,
scsi->rom_addr, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL);
scsi->base = device_get_config_hex16("base");
scsi->rom_addr = device_get_config_hex20("bios_addr");
mem_mapping_disable(&scsi->bios_rom.mapping);
if (scsi->rom_addr) {
rom_init(&scsi->bios_rom, RT1000B_ROM,
scsi->rom_addr, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL);
mem_mapping_disable(&scsi->bios_rom.mapping);
} else {
scsi->bios_rom.rom = (uint8_t *) malloc(0x4000);
memset(scsi->bios_rom.rom, 0xff, 0x4000);
}
mem_mapping_add(&scsi->mapping, scsi->rom_addr, 0x4000,
memio_read, NULL, NULL,
memio_write, NULL, NULL,
scsi->bios_rom.rom, 0, scsi);
if (scsi->base) {
io_sethandler(scsi->base, 16,
t130b_in,NULL,NULL, t130b_out,NULL,NULL, scsi);
}
break;
case 2: /* Trantor T130B */
scsi->rom_addr = 0xDC000;
scsi->base = 0x0350;
rom_init(&scsi->bios_rom, T130B_ROM,
scsi->rom_addr, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL);
scsi->base = device_get_config_hex16("base");
scsi->rom_addr = device_get_config_hex20("bios_addr");
if (scsi->rom_addr) {
rom_init(&scsi->bios_rom, T130B_ROM,
scsi->rom_addr, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL);
mem_mapping_disable(&scsi->bios_rom.mapping);
} else {
scsi->bios_rom.rom = (uint8_t *) malloc(0x4000);
memset(scsi->bios_rom.rom, 0xff, 0x4000);
}
mem_mapping_add(&scsi->mapping, scsi->rom_addr, 0x4000,
t130b_read, NULL, NULL,
t130b_write, NULL, NULL,
scsi->bios_rom.rom, 0, scsi);
io_sethandler(scsi->base, 16,
t130b_in,NULL,NULL, t130b_out,NULL,NULL, scsi);
if (scsi->base) {
io_sethandler(scsi->base, 16,
t130b_in,NULL,NULL, t130b_out,NULL,NULL, scsi);
}
break;
case 3: /* Sumo SCSI-AT */
scsi->base = device_get_config_hex16("base");
scsi->irq = device_get_config_int("irq");
scsi->rom_addr = device_get_config_hex20("bios_addr");
rom_init(&scsi->bios_rom, SCSIAT_ROM,
scsi->rom_addr, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL);
if (scsi->rom_addr) {
rom_init(&scsi->bios_rom, SCSIAT_ROM,
scsi->rom_addr, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL);
mem_mapping_disable(&scsi->bios_rom.mapping);
} else {
scsi->bios_rom.rom = (uint8_t *) malloc(0x4000);
memset(scsi->bios_rom.rom, 0xff, 0x4000);
}
mem_mapping_add(&scsi->mapping, scsi->rom_addr, 0x4000,
t130b_read, NULL, NULL,
t130b_write, NULL, NULL,
scsi->bios_rom.rom, 0, scsi);
io_sethandler(scsi->base, 16,
scsiat_in,NULL,NULL, scsiat_out,NULL,NULL, scsi);
if (scsi->base) {
io_sethandler(scsi->base, 16,
scsiat_in,NULL,NULL, scsiat_out,NULL,NULL, scsi);
}
break;
}
@@ -898,7 +933,7 @@ ncr_init(const device_t *info)
sprintf(&temp[strlen(temp)], " I/O=%04x", scsi->base);
if (scsi->irq != 0)
sprintf(&temp[strlen(temp)], " IRQ=%d", scsi->irq);
pclog("%s\n", temp);
ncr_log("%s\n", temp);
ncr5380_reset(&scsi->ncr);
@@ -948,6 +983,59 @@ scsiat_available(void)
}
static const device_config_t ncr5380_config[] = {
{
"base", "Address", CONFIG_HEX16, "", 0x0350,
{
{
"None", 0
},
{
"240H", 0x0240
},
{
"250H", 0x0250
},
{
"340H", 0x0340
},
{
"350H", 0x0350
},
{
""
}
},
},
{
"bios_addr", "BIOS Address", CONFIG_HEX20, "", 0xDC000,
{
{
"Disabled", 0
},
{
"C800H", 0xc8000
},
{
"CC00H", 0xcc000
},
{
"D800H", 0xd8000
},
{
"DC00H", 0xdc000
},
{
""
}
},
},
{
"", "", -1
}
};
static const device_config_t scsiat_config[] = {
{
"base", "Address", CONFIG_HEX16, "", 0x0310,
@@ -1064,7 +1152,7 @@ const device_t scsi_rt1000b_device =
ncr_init, ncr_close, NULL,
rt1000b_available,
NULL, NULL,
NULL
ncr5380_config
};
const device_t scsi_t130b_device =
@@ -1075,7 +1163,7 @@ const device_t scsi_t130b_device =
ncr_init, ncr_close, NULL,
t130b_available,
NULL, NULL,
NULL
ncr5380_config
};
const device_t scsi_scsiat_device =

View File

@@ -10,7 +10,7 @@
* NCR and later Symbios and LSI. This controller was designed
* for the PCI bus.
*
* Version: @(#)scsi_ncr53c810.c 1.0.13 2018/05/23
* Version: @(#)scsi_ncr53c810.c 1.0.14 2018/05/28
*
* Authors: Paul Brook (QEMU)
* Artyom Tarasenko (QEMU)
@@ -22,11 +22,12 @@
* Copyright 2017,2018 Miran Grca.
*/
#include <inttypes.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#define HAVE_STDARG_H
#include <wchar.h>
#include "../86box.h"
#include "../io.h"
@@ -333,7 +334,7 @@ ncr53c810_irq_on_rsl(ncr53c810_t *dev)
static void
ncr53c810_soft_reset(ncr53c810_t *dev)
{
int i, j;
int i;
ncr53c810_log("LSI Reset\n");
dev->timer_period = dev->timer_enabled = 0;
@@ -390,10 +391,8 @@ ncr53c810_soft_reset(ncr53c810_t *dev)
dev->gpreg0 = 0;
dev->sstop = 1;
for (i = 0; i < 16; i++) {
for (j = 0; j < 8; j++)
scsi_device_reset(i, j);
}
for (i = 0; i < 16; i++)
scsi_device_reset(i);
}
@@ -598,9 +597,9 @@ ncr53c810_do_dma(ncr53c810_t *dev, int out, uint8_t id)
scsi_device_t *sd;
sd = &SCSIDevices[id][dev->current_lun];
sd = &SCSIDevices[id];
if ((!scsi_device_present(id, dev->current_lun))) {
if ((!scsi_device_present(id))) {
ncr53c810_log("(ID=%02i LUN=%02i) SCSI Command 0x%02x: Device not present when attempting to do DMA\n", id, dev->current_lun, dev->last_command);
return;
}
@@ -627,7 +626,7 @@ ncr53c810_do_dma(ncr53c810_t *dev, int out, uint8_t id)
else {
if (!dev->buffer_pos) {
ncr53c810_log("(ID=%02i LUN=%02i) SCSI Command 0x%02x: SCSI Command Phase 1 on PHASE_DI\n", id, dev->current_lun, dev->last_command);
scsi_device_command_phase1(dev->current->tag, dev->current_lun);
scsi_device_command_phase1(dev->current->tag);
}
ncr53c810_write(dev, addr, sd->CmdBuffer+dev->buffer_pos, count);
}
@@ -638,7 +637,7 @@ ncr53c810_do_dma(ncr53c810_t *dev, int out, uint8_t id)
if (dev->temp_buf_len <= 0) {
if (out) {
ncr53c810_log("(ID=%02i LUN=%02i) SCSI Command 0x%02x: SCSI Command Phase 1 on PHASE_DO\n", id, dev->current_lun, dev->last_command);
scsi_device_command_phase1(id, dev->current_lun);
scsi_device_command_phase1(id);
}
if (sd->CmdBuffer != NULL) {
free(sd->CmdBuffer);
@@ -684,8 +683,8 @@ ncr53c810_do_command(ncr53c810_t *dev, uint8_t id)
dev->sfbr = buf[0];
dev->command_complete = 0;
sd = &SCSIDevices[id][dev->current_lun];
if (!scsi_device_present(id, dev->current_lun)) {
sd = &SCSIDevices[id];
if (!scsi_device_present(id)) {
ncr53c810_log("(ID=%02i LUN=%02i) SCSI Command 0x%02x: Bad Selection\n", id, dev->current_lun, buf[0]);
ncr53c810_bad_selection(dev, id);
return 0;
@@ -699,7 +698,7 @@ ncr53c810_do_command(ncr53c810_t *dev, uint8_t id)
ncr53c810_log("(ID=%02i LUN=%02i) SCSI Command 0x%02x: DBC=%i\n", id, dev->current_lun, buf[0], dev->dbc);
dev->last_command = buf[0];
scsi_device_command_phase0(dev->current->tag, dev->current_lun, dev->dbc, buf);
scsi_device_command_phase0(dev->current->tag, buf);
dev->hba_private = (void *)dev->current;
dev->waiting = 0;
@@ -715,7 +714,7 @@ ncr53c810_do_command(ncr53c810_t *dev, uint8_t id)
if ((sd->Phase == SCSI_PHASE_DATA_IN) && (sd->BufferLength > 0)) {
ncr53c810_log("(ID=%02i LUN=%02i) SCSI Command 0x%02x: PHASE_DI\n", id, dev->current_lun, buf[0]);
ncr53c810_set_phase(dev, PHASE_DI);
p = scsi_device_get_callback(dev->current->tag, dev->current_lun);
p = scsi_device_get_callback(dev->current->tag);
if (p <= 0LL) {
period = ((double) sd->BufferLength) * 0.1 * ((double) TIMER_USEC); /* Fast SCSI: 10000000 bytes per second */
dev->timer_period += (int64_t) period;
@@ -723,9 +722,9 @@ ncr53c810_do_command(ncr53c810_t *dev, uint8_t id)
dev->timer_period += p;
return 1;
} else if ((sd->Phase == SCSI_PHASE_DATA_OUT) && (sd->BufferLength > 0)) {
ncr53c810_log("(ID=%02i LUN=%02i) SCSI Command 0x%02x: PHASE_DO\n", id, dev->current_lun, buf[0]);
ncr53c810_log("(ID=%02i LUN=%02i) SCSI Command 0x%02x: PHASE_DO\n", id, buf[0]);
ncr53c810_set_phase(dev, PHASE_DO);
p = scsi_device_get_callback(dev->current->tag, dev->current_lun);
p = scsi_device_get_callback(dev->current->tag);
if (p <= 0LL) {
period = ((double) sd->BufferLength) * 0.1 * ((double) TIMER_USEC); /* Fast SCSI: 10000000 bytes per second */
dev->timer_period += (int64_t) period;
@@ -833,7 +832,7 @@ ncr53c810_do_msgout(ncr53c810_t *dev, uint8_t id)
uint32_t current_tag;
scsi_device_t *sd;
sd = &SCSIDevices[id][dev->current_lun];
sd = &SCSIDevices[id];
current_tag = id;
@@ -1079,7 +1078,7 @@ again:
}
dev->sstat0 |= NCR_SSTAT0_WOA;
dev->scntl1 &= ~NCR_SCNTL1_IARB;
if (!scsi_device_present(id, 0)) {
if (!scsi_device_present(id)) {
ncr53c810_bad_selection(dev, id);
break;
}
@@ -1098,8 +1097,12 @@ again:
break;
case 2: /* Wait Reselect */
ncr53c810_log("Wait Reselect\n");
if (!ncr53c810_irq_on_rsl(dev))
dev->waiting = 1;
if (dev->istat & NCR_ISTAT_SIGP)
dev->dsp = dev->dnad; /* If SIGP is set, this command causes an immediate jump to DNAD. */
else {
if (!ncr53c810_irq_on_rsl(dev))
dev->waiting = 1;
}
break;
case 3: /* Set */
ncr53c810_log("Set%s%s%s%s\n", insn & (1 << 3) ? " ATN" : "",
@@ -1462,7 +1465,7 @@ ncr53c810_reg_writeb(ncr53c810_t *dev, uint32_t offset, uint8_t val)
ncr53c810_update_irq(dev);
}
if (dev->waiting == 1 && val & NCR_ISTAT_SIGP) {
if ((dev->waiting == 1) && (val & NCR_ISTAT_SIGP)) {
ncr53c810_log("Woken by SIGP\n");
dev->waiting = 0;
dev->dsp = dev->dnad;
@@ -1668,7 +1671,8 @@ ncr53c810_reg_readb(ncr53c810_t *dev, uint32_t offset)
CASE_GET_REG32(dsa, 0x10)
case 0x14: /* ISTAT */
ncr53c810_log("NCR 810: Read ISTAT %02X\n", dev->istat);
return dev->istat;
tmp = dev->istat;
return tmp;
case 0x16: /* MBOX0 */
ncr53c810_log("NCR 810: Read MBOX0 %02X\n", dev->mbox0);
return dev->mbox0;
@@ -2170,7 +2174,7 @@ ncr53c810_init(const device_t *info)
/* Enable our BIOS space in PCI, if needed. */
if (dev->has_bios)
rom_init(&dev->bios, NCR53C810_ROM, 0xd8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL);
rom_init(&dev->bios, NCR53C810_ROM, 0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL);
return(dev);
}

View File

@@ -11,7 +11,7 @@
* series of SCSI Host Adapters made by Mylex.
* These controllers were designed for various buses.
*
* Version: @(#)scsi_x54x.c 1.0.21 2018/03/28
* Version: @(#)scsi_x54x.c 1.0.21 2018/06/12
*
* Authors: TheCollector1995, <mariogplayer@gmail.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -90,24 +90,21 @@ x54x_irq(x54x_t *dev, int set)
if (dev->bus & DEVICE_PCI) {
x54x_log("PCI IRQ: %02X, PCI_INTA\n", dev->pci_slot);
if (set) {
if (set)
pci_set_irq(dev->pci_slot, PCI_INTA);
} else {
else
pci_clear_irq(dev->pci_slot, PCI_INTA);
}
} else {
if (set) {
if (dev->interrupt_type)
int_type = dev->interrupt_type(dev);
if (int_type) {
if (int_type)
picintlevel(1 << irq);
} else {
else
picint(1 << irq);
}
} else {
} else
picintc(1 << irq);
}
}
}
@@ -157,10 +154,10 @@ clear_irq(x54x_t *dev)
static void
target_check(uint8_t id, uint8_t lun)
target_check(uint8_t id)
{
if (! scsi_device_valid(id, lun)) {
fatal("BIOS INT13 device on %02i:%02i has disappeared\n", id, lun);
if (! scsi_device_valid(id)) {
fatal("BIOS INT13 device on ID %02i has disappeared\n", id);
}
}
@@ -235,15 +232,15 @@ completion_code(uint8_t *sense)
static uint8_t
x54x_bios_command_08(uint8_t id, uint8_t lun, uint8_t *buffer)
x54x_bios_command_08(uint8_t id, uint8_t *buffer)
{
uint8_t cdb[12] = { GPCMD_READ_CDROM_CAPACITY, 0,0,0,0,0,0,0,0,0,0,0 };
uint8_t rcbuf[8] = { 0,0,0,0,0,0,0,0 };
uint32_t len = 0;
int i, ret, sc;
ret = scsi_device_read_capacity(id, lun, cdb, rcbuf, &len);
sc = completion_code(scsi_device_sense(id, lun));
ret = scsi_device_read_capacity(id, cdb, rcbuf, &len);
sc = completion_code(scsi_device_sense(id));
if (ret == 0) return(sc);
memset(buffer, 0x00, 6);
@@ -259,21 +256,21 @@ x54x_bios_command_08(uint8_t id, uint8_t lun, uint8_t *buffer)
static int
x54x_bios_command_15(uint8_t id, uint8_t lun, uint8_t *buffer)
x54x_bios_command_15(uint8_t id, uint8_t *buffer)
{
uint8_t cdb[12] = { GPCMD_READ_CDROM_CAPACITY, 0,0,0,0,0,0,0,0,0,0,0 };
uint8_t rcbuf[8] = { 0,0,0,0,0,0,0,0 };
uint32_t len = 0;
int i, ret, sc;
ret = scsi_device_read_capacity(id, lun, cdb, rcbuf, &len);
sc = completion_code(scsi_device_sense(id, lun));
ret = scsi_device_read_capacity(id, cdb, rcbuf, &len);
sc = completion_code(scsi_device_sense(id));
memset(buffer, 0x00, 6);
for (i=0; i<4; i++)
buffer[i] = (ret == 0) ? 0 : rcbuf[i];
scsi_device_type_data(id, lun, &(buffer[4]), &(buffer[5]));
scsi_device_type_data(id, &(buffer[4]), &(buffer[5]));
x54x_log("BIOS Command 0x15: %02X %02X %02X %02X %02X %02X\n",
buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5]);
@@ -306,19 +303,22 @@ x54x_bios_command(x54x_t *x54x, uint8_t max_id, BIOSCMD *cmd, int8_t islba)
return(0x80);
}
if (cmd->lun) {
x54x_log("BIOS Target LUN is not 0\n");
return(0x80);
}
/* Get pointer to selected device. */
dev = &SCSIDevices[cmd->id][cmd->lun];
dev = &SCSIDevices[cmd->id];
dev->BufferLength = 0;
if (! scsi_device_present(cmd->id, cmd->lun)) {
x54x_log("BIOS Target ID %i and LUN %i have no device attached\n",
cmd->id, cmd->lun);
if (! scsi_device_present(cmd->id)) {
x54x_log("BIOS Target ID %i has no device attached\n", cmd->id);
return(0x80);
}
if ((dev->LunType == SCSI_CDROM) && !x54x->cdrom_boot) {
x54x_log("BIOS Target ID %i and LUN %i is CD-ROM on unsupported BIOS\n",
cmd->id, cmd->lun);
x54x_log("BIOS Target ID %i is CD-ROM on unsupported BIOS\n", cmd->id);
return(0x80);
}
@@ -337,7 +337,7 @@ x54x_bios_command(x54x_t *x54x, uint8_t max_id, BIOSCMD *cmd, int8_t islba)
return(0);
case 0x01: /* Read Status of Last Operation */
target_check(cmd->id, cmd->lun);
target_check(cmd->id);
/*
* Assuming 14 bytes because that is the default
@@ -352,7 +352,7 @@ x54x_bios_command(x54x_t *x54x, uint8_t max_id, BIOSCMD *cmd, int8_t islba)
x54x_log("BIOS DMA: Reading 14 bytes at %08X\n",
dma_address);
DMAPageWrite(dma_address,
scsi_device_sense(cmd->id, cmd->lun), 14);
scsi_device_sense(cmd->id), 14);
}
if (dev->CmdBuffer != NULL) {
@@ -363,7 +363,7 @@ x54x_bios_command(x54x_t *x54x, uint8_t max_id, BIOSCMD *cmd, int8_t islba)
return(0);
case 0x02: /* Read Desired Sectors to Memory */
target_check(cmd->id, cmd->lun);
target_check(cmd->id);
dev->BufferLength = -1;
@@ -379,14 +379,14 @@ x54x_bios_command(x54x_t *x54x, uint8_t max_id, BIOSCMD *cmd, int8_t islba)
x54x_log("BIOS CMD(READ, %08lx, %d)\n", lba, cmd->secount);
#endif
scsi_device_command_phase0(cmd->id, cmd->lun, 12, cdb);
scsi_device_command_phase0(cmd->id, cdb);
if (dev->Phase == SCSI_PHASE_STATUS)
goto skip_read_phase1;
dev->CmdBuffer = (uint8_t *)malloc(dev->BufferLength);
scsi_device_command_phase1(cmd->id, cmd->lun);
scsi_device_command_phase1(cmd->id);
if (sector_len > 0) {
x54x_log("BIOS DMA: Reading %i bytes at %08X\n",
dev->BufferLength, dma_address);
@@ -400,10 +400,10 @@ skip_read_phase1:
dev->CmdBuffer = NULL;
}
return(completion_code(scsi_device_sense(cmd->id, cmd->lun)));
return(completion_code(scsi_device_sense(cmd->id)));
case 0x03: /* Write Desired Sectors from Memory */
target_check(cmd->id, cmd->lun);
target_check(cmd->id);
dev->BufferLength = -1;
@@ -419,7 +419,7 @@ skip_read_phase1:
x54x_log("BIOS CMD(WRITE, %08lx, %d)\n", lba, cmd->secount);
#endif
scsi_device_command_phase0(cmd->id, cmd->lun, 12, cdb);
scsi_device_command_phase0(cmd->id, cdb);
if (dev->Phase == SCSI_PHASE_STATUS)
goto skip_write_phase1;
@@ -433,7 +433,7 @@ skip_read_phase1:
dev->CmdBuffer, dev->BufferLength);
}
scsi_device_command_phase1(cmd->id, cmd->lun);
scsi_device_command_phase1(cmd->id);
skip_write_phase1:
if (dev->CmdBuffer != NULL) {
@@ -441,10 +441,10 @@ skip_write_phase1:
dev->CmdBuffer = NULL;
}
return(completion_code(scsi_device_sense(cmd->id, cmd->lun)));
return(completion_code(scsi_device_sense(cmd->id)));
case 0x04: /* Verify Desired Sectors */
target_check(cmd->id, cmd->lun);
target_check(cmd->id);
cdb[0] = GPCMD_VERIFY_10;
cdb[1] = (cmd->lun & 7) << 5;
@@ -455,9 +455,9 @@ skip_write_phase1:
cdb[7] = 0;
cdb[8] = sector_len;
scsi_device_command_phase0(cmd->id, cmd->lun, 12, cdb);
scsi_device_command_phase0(cmd->id, cdb);
return(completion_code(scsi_device_sense(cmd->id, cmd->lun)));
return(completion_code(scsi_device_sense(cmd->id)));
case 0x05: /* Format Track, invalid since SCSI has no tracks */
//FIXME: add a longer delay here --FvK
@@ -468,23 +468,23 @@ skip_write_phase1:
return(0);
case 0x07: /* Format Unit */
target_check(cmd->id, cmd->lun);
target_check(cmd->id);
cdb[0] = GPCMD_FORMAT_UNIT;
cdb[1] = (cmd->lun & 7) << 5;
scsi_device_command_phase0(cmd->id, cmd->lun, 12, cdb);
scsi_device_command_phase0(cmd->id, cdb);
return(completion_code(scsi_device_sense(cmd->id, cmd->lun)));
return(completion_code(scsi_device_sense(cmd->id)));
case 0x08: /* Read Drive Parameters */
target_check(cmd->id, cmd->lun);
target_check(cmd->id);
dev->BufferLength = 6;
dev->CmdBuffer = (uint8_t *)malloc(dev->BufferLength);
memset(dev->CmdBuffer, 0x00, dev->BufferLength);
ret = x54x_bios_command_08(cmd->id, cmd->lun, dev->CmdBuffer);
ret = x54x_bios_command_08(cmd->id, dev->CmdBuffer);
x54x_log("BIOS DMA: Reading 6 bytes at %08X\n", dma_address);
DMAPageWrite(dma_address,
@@ -502,7 +502,7 @@ skip_write_phase1:
return(0);
case 0x0c: /* Seek */
target_check(cmd->id, cmd->lun);
target_check(cmd->id);
cdb[0] = GPCMD_SEEK_10;
cdb[1] = (cmd->lun & 7) << 5;
@@ -511,7 +511,7 @@ skip_write_phase1:
cdb[4] = (lba >> 8) & 0xff;
cdb[5] = lba & 0xff;
scsi_device_command_phase0(cmd->id, cmd->lun, 12, cdb);
scsi_device_command_phase0(cmd->id, cdb);
return((dev->Status == SCSI_STATUS_OK) ? 1 : 0);
@@ -520,37 +520,37 @@ skip_write_phase1:
return(0);
case 0x10: /* Test Drive Ready */
target_check(cmd->id, cmd->lun);
target_check(cmd->id);
cdb[0] = GPCMD_TEST_UNIT_READY;
cdb[1] = (cmd->lun & 7) << 5;
scsi_device_command_phase0(cmd->id, cmd->lun, 12, cdb);
scsi_device_command_phase0(cmd->id, cdb);
return(completion_code(scsi_device_sense(cmd->id, cmd->lun)));
return(completion_code(scsi_device_sense(cmd->id)));
case 0x11: /* Recalibrate */
target_check(cmd->id, cmd->lun);
target_check(cmd->id);
cdb[0] = GPCMD_REZERO_UNIT;
cdb[1] = (cmd->lun & 7) << 5;
scsi_device_command_phase0(cmd->id, cmd->lun, 12, cdb);
scsi_device_command_phase0(cmd->id, cdb);
return(completion_code(scsi_device_sense(cmd->id, cmd->lun)));
return(completion_code(scsi_device_sense(cmd->id)));
case 0x14: /* Controller Diagnostic */
//FIXME: add a longer delay here --FvK
return(0);
case 0x15: /* Read DASD Type */
target_check(cmd->id, cmd->lun);
target_check(cmd->id);
dev->BufferLength = 6;
dev->CmdBuffer = (uint8_t *)malloc(dev->BufferLength);
memset(dev->CmdBuffer, 0x00, dev->BufferLength);
ret = x54x_bios_command_15(cmd->id, cmd->lun, dev->CmdBuffer);
ret = x54x_bios_command_15(cmd->id, dev->CmdBuffer);
x54x_log("BIOS DMA: Reading 6 bytes at %08X\n", dma_address);
DMAPageWrite(dma_address,
@@ -762,7 +762,7 @@ x54x_set_residue(Req_t *req, int32_t TransferLength)
{
uint32_t Residue = 0;
addr24 Residue24;
int32_t BufLen = SCSIDevices[req->TargetID][req->LUN].BufferLength;
int32_t BufLen = SCSIDevices[req->TargetID].BufferLength;
if ((req->CmdBlock.common.Opcode == SCSI_INITIATOR_COMMAND_RES) ||
(req->CmdBlock.common.Opcode == SCATTER_GATHER_COMMAND_RES)) {
@@ -793,7 +793,7 @@ x54x_buf_dma_transfer(Req_t *req, int Is24bit, int TransferLength, int dir)
uint32_t DataPointer, DataLength;
uint32_t SGEntryLength = (Is24bit ? sizeof(SGE) : sizeof(SGE32));
uint32_t Address, i;
int32_t BufLen = SCSIDevices[req->TargetID][req->LUN].BufferLength;
int32_t BufLen = SCSIDevices[req->TargetID].BufferLength;
uint8_t read_from_host = (dir && ((req->CmdBlock.common.ControlByte == CCB_DATA_XFER_OUT) || (req->CmdBlock.common.ControlByte == 0x00)));
uint8_t write_to_host = (!dir && ((req->CmdBlock.common.ControlByte == CCB_DATA_XFER_IN) || (req->CmdBlock.common.ControlByte == 0x00)));
int sg_pos = 0;
@@ -807,8 +807,8 @@ x54x_buf_dma_transfer(Req_t *req, int Is24bit, int TransferLength, int dir)
DataPointer = req->CmdBlock.new.DataPointer;
DataLength = req->CmdBlock.new.DataLength;
}
x54x_log("Data Buffer %s: length %d, pointer 0x%04X\n",
dir ? "write" : "read", BufLen, DataPointer);
x54x_log("Data Buffer %s: length %d (%u), pointer 0x%04X\n",
dir ? "write" : "read", BufLen, DataLength, DataPointer);
if ((req->CmdBlock.common.ControlByte != 0x03) && TransferLength && BufLen) {
if ((req->CmdBlock.common.Opcode == SCATTER_GATHER_COMMAND) ||
@@ -825,11 +825,11 @@ x54x_buf_dma_transfer(Req_t *req, int Is24bit, int TransferLength, int dir)
if (read_from_host && DataToTransfer) {
x54x_log("Reading S/G segment %i: length %i, pointer %08X\n", i, DataToTransfer, Address);
DMAPageRead(Address, &(SCSIDevices[req->TargetID][req->LUN].CmdBuffer[sg_pos]), DataToTransfer);
DMAPageRead(Address, &(SCSIDevices[req->TargetID].CmdBuffer[sg_pos]), DataToTransfer);
}
else if (write_to_host && DataToTransfer) {
x54x_log("Writing S/G segment %i: length %i, pointer %08X\n", i, DataToTransfer, Address);
DMAPageWrite(Address, &(SCSIDevices[req->TargetID][req->LUN].CmdBuffer[sg_pos]), DataToTransfer);
DMAPageWrite(Address, &(SCSIDevices[req->TargetID].CmdBuffer[sg_pos]), DataToTransfer);
}
else
x54x_log("No action on S/G segment %i: length %i, pointer %08X\n", i, DataToTransfer, Address);
@@ -849,9 +849,9 @@ x54x_buf_dma_transfer(Req_t *req, int Is24bit, int TransferLength, int dir)
if ((DataLength > 0) && (BufLen > 0) && (req->CmdBlock.common.ControlByte < 0x03)) {
if (read_from_host)
DMAPageRead(Address, SCSIDevices[req->TargetID][req->LUN].CmdBuffer, MIN(BufLen, (int) DataLength));
DMAPageRead(Address, SCSIDevices[req->TargetID].CmdBuffer, MIN(BufLen, (int) DataLength));
else if (write_to_host)
DMAPageWrite(Address, SCSIDevices[req->TargetID][req->LUN].CmdBuffer, MIN(BufLen, (int) DataLength));
DMAPageWrite(Address, SCSIDevices[req->TargetID].CmdBuffer, MIN(BufLen, (int) DataLength));
}
}
}
@@ -859,25 +859,25 @@ x54x_buf_dma_transfer(Req_t *req, int Is24bit, int TransferLength, int dir)
void
x54x_buf_alloc(uint8_t id, uint8_t lun, int length)
x54x_buf_alloc(uint8_t id, int length)
{
if (SCSIDevices[id][lun].CmdBuffer != NULL) {
free(SCSIDevices[id][lun].CmdBuffer);
SCSIDevices[id][lun].CmdBuffer = NULL;
if (SCSIDevices[id].CmdBuffer != NULL) {
free(SCSIDevices[id].CmdBuffer);
SCSIDevices[id].CmdBuffer = NULL;
}
x54x_log("Allocating data buffer (%i bytes)\n", length);
SCSIDevices[id][lun].CmdBuffer = (uint8_t *) malloc(length);
memset(SCSIDevices[id][lun].CmdBuffer, 0, length);
SCSIDevices[id].CmdBuffer = (uint8_t *) malloc(length);
memset(SCSIDevices[id].CmdBuffer, 0, length);
}
void
x54x_buf_free(uint8_t id, uint8_t lun)
x54x_buf_free(uint8_t id)
{
if (SCSIDevices[id][lun].CmdBuffer != NULL) {
free(SCSIDevices[id][lun].CmdBuffer);
SCSIDevices[id][lun].CmdBuffer = NULL;
if (SCSIDevices[id].CmdBuffer != NULL) {
free(SCSIDevices[id].CmdBuffer);
SCSIDevices[id].CmdBuffer = NULL;
}
}
@@ -921,7 +921,7 @@ SenseBufferFree(Req_t *req, int Copy)
uint8_t temp_sense[256];
if (SenseLength && Copy) {
scsi_device_request_sense(req->TargetID, req->LUN, temp_sense, SenseLength);
scsi_device_request_sense(req->TargetID, temp_sense, SenseLength);
/*
* The sense address, in 32-bit mode, is located in the
@@ -960,11 +960,11 @@ x54x_scsi_cmd(x54x_t *dev)
id = req->TargetID;
lun = req->LUN;
target_cdb_len = scsi_device_cdb_length(id, lun);
target_cdb_len = 12;
target_data_len = x54x_get_length(req, bit24);
if (!scsi_device_valid(id, lun))
fatal("SCSI target on %02i:%02i has disappeared\n", id, lun);
if (!scsi_device_valid(id))
fatal("SCSI target on %02i has disappeared\n", id);
x54x_log("target_data_len = %i\n", target_data_len);
@@ -986,14 +986,14 @@ x54x_scsi_cmd(x54x_t *dev)
dev->Residue = 0;
BufLen = scsi_device_get_buf_len(id, lun);
BufLen = scsi_device_get_buf_len(id);
*BufLen = target_data_len;
x54x_log("Command buffer: %08X\n", SCSIDevices[id][lun].CmdBuffer);
x54x_log("Command buffer: %08X\n", SCSIDevices[id].CmdBuffer);
scsi_device_command_phase0(id, lun, req->CmdBlock.common.CdbLength, temp_cdb);
scsi_device_command_phase0(id, temp_cdb);
phase = SCSIDevices[id][lun].Phase;
phase = SCSIDevices[id].Phase;
x54x_log("Control byte: %02X\n", (req->CmdBlock.common.ControlByte == 0x03));
@@ -1001,46 +1001,46 @@ x54x_scsi_cmd(x54x_t *dev)
if ((temp_cdb[0] == 0x03) && (req->CmdBlock.common.ControlByte == 0x03)) {
/* Request sense in non-data mode - sense goes to sense buffer. */
*BufLen = ConvertSenseLength(req->CmdBlock.common.RequestSenseLength);
x54x_buf_alloc(id, lun, *BufLen);
scsi_device_command_phase1(id, lun);
if ((SCSIDevices[id][lun].Status != SCSI_STATUS_OK) && (*BufLen > 0)) {
x54x_buf_alloc(id, *BufLen);
scsi_device_command_phase1(id);
if ((SCSIDevices[id].Status != SCSI_STATUS_OK) && (*BufLen > 0)) {
SenseBufferAddress = SenseBufferPointer(req);
DMAPageWrite(SenseBufferAddress, SCSIDevices[id][lun].CmdBuffer, *BufLen);
DMAPageWrite(SenseBufferAddress, SCSIDevices[id].CmdBuffer, *BufLen);
x54x_add_to_period(*BufLen);
}
} else {
p = scsi_device_get_callback(id, lun);
p = scsi_device_get_callback(id);
if (p <= 0LL)
x54x_add_to_period(*BufLen);
else
dev->media_period += p;
x54x_buf_alloc(id, lun, MIN(target_data_len, *BufLen));
x54x_buf_alloc(id, MIN(target_data_len, *BufLen));
if (phase == SCSI_PHASE_DATA_OUT)
x54x_buf_dma_transfer(req, bit24, target_data_len, 1);
scsi_device_command_phase1(id, lun);
scsi_device_command_phase1(id);
if (phase == SCSI_PHASE_DATA_IN)
x54x_buf_dma_transfer(req, bit24, target_data_len, 0);
SenseBufferFree(req, (SCSIDevices[id][lun].Status != SCSI_STATUS_OK));
SenseBufferFree(req, (SCSIDevices[id].Status != SCSI_STATUS_OK));
}
} else
SenseBufferFree(req, (SCSIDevices[id][lun].Status != SCSI_STATUS_OK));
SenseBufferFree(req, (SCSIDevices[id].Status != SCSI_STATUS_OK));
x54x_set_residue(req, target_data_len);
x54x_buf_free(id, lun);
x54x_buf_free(id);
x54x_log("Request complete\n");
if (SCSIDevices[id][lun].Status == SCSI_STATUS_OK) {
if (SCSIDevices[id].Status == SCSI_STATUS_OK) {
x54x_mbi_setup(dev, req->CCBPointer, &req->CmdBlock,
CCB_COMPLETE, SCSI_STATUS_OK, MBI_SUCCESS);
} else if (SCSIDevices[id][lun].Status == SCSI_STATUS_CHECK_CONDITION) {
} else if (SCSIDevices[id].Status == SCSI_STATUS_CHECK_CONDITION) {
x54x_mbi_setup(dev, req->CCBPointer, &req->CmdBlock,
CCB_COMPLETE, SCSI_STATUS_CHECK_CONDITION, MBI_ERROR);
}
x54x_log("SCSIDevices[%02i][%02i].Status = %02X\n", id, lun, SCSIDevices[id][lun].Status);
x54x_log("SCSIDevices[%02i].Status = %02X\n", id, SCSIDevices[id].Status);
}
@@ -1082,10 +1082,10 @@ x54x_req_setup(x54x_t *dev, uint32_t CCBPointer, Mailbox32_t *Mailbox32)
x54x_log("Scanning SCSI Target ID %i\n", id);
SCSIDevices[id][lun].Status = SCSI_STATUS_OK;
SCSIDevices[id].Status = SCSI_STATUS_OK;
/* If there is no device at ID:0, timeout the selection - the LUN is then checked later. */
if (! scsi_device_present(id, 0)) {
if (! scsi_device_present(id)) {
x54x_log("SCSI Target ID %i and LUN %i have no device attached\n",id,lun);
x54x_mbi_setup(dev, CCBPointer, &req->CmdBlock,
CCB_SELECTION_TIMEOUT, SCSI_STATUS_OK, MBI_ERROR);
@@ -1107,7 +1107,7 @@ x54x_req_setup(x54x_t *dev, uint32_t CCBPointer, Mailbox32_t *Mailbox32)
}
if (req->CmdBlock.common.Opcode == 0x81) {
x54x_log("Bus reset opcode\n");
scsi_device_reset(id, lun);
scsi_device_reset(id);
x54x_mbi_setup(dev, req->CCBPointer, &req->CmdBlock,
CCB_COMPLETE, SCSI_STATUS_OK, MBI_SUCCESS);
x54x_log("%s: Callback: Send incoming mailbox\n", dev->name);
@@ -1423,7 +1423,7 @@ x54x_reset_poll(void *priv)
static void
x54x_reset(x54x_t *dev)
{
int i, j;
int i;
clear_irq(dev);
if (dev->int_geom_writable)
@@ -1443,10 +1443,8 @@ x54x_reset(x54x_t *dev)
dev->MailboxOutPosCur = 0;
/* Reset all devices on controller reset. */
for (i = 0; i < 16; i++) {
for (j = 0; j < 8; j++)
scsi_device_reset(i, j);
}
for (i = 0; i < 16; i++)
scsi_device_reset(i);
if (dev->ven_reset)
dev->ven_reset(dev);
@@ -1479,7 +1477,6 @@ x54x_out(uint16_t port, uint8_t val, void *priv)
x54x_t *dev = (x54x_t *)priv;
MailboxInit_t *mbi;
int i = 0;
uint8_t j = 0;
BIOSCMD *cmd;
uint16_t cyl = 0;
int suppress = 0;
@@ -1503,10 +1500,8 @@ x54x_out(uint16_t port, uint8_t val, void *priv)
if (val & CTRL_SCRST) {
/* Reset all devices on SCSI bus reset. */
for (i = 0; i < 16; i++) {
for (j = 0; j < 8; j++)
scsi_device_reset(i, j);
}
for (i = 0; i < 16; i++)
scsi_device_reset(i);
}
if (val & CTRL_IRST) {
@@ -1682,10 +1677,9 @@ x54x_out(uint16_t port, uint8_t val, void *priv)
/* Skip the HA .. */
if (i == host_id) continue;
for (j=0; j<SCSI_LUN_MAX; j++) {
if (scsi_device_present(i, j))
dev->DataBuf[i] |= (1<<j);
}
/* TODO: Query device for LUN's. */
if (scsi_device_present(i))
dev->DataBuf[i] |= 1;
}
dev->DataReplyLeft = i;
break;

View File

@@ -492,8 +492,8 @@ typedef struct
extern void x54x_reset_ctrl(x54x_t *dev, uint8_t Reset);
extern void x54x_buf_alloc(uint8_t id, uint8_t lun, int length);
extern void x54x_buf_free(uint8_t id, uint8_t lun);
extern void x54x_buf_alloc(uint8_t id, int length);
extern void x54x_buf_free(uint8_t id);
extern uint8_t x54x_mbo_process(x54x_t *dev);
extern void x54x_wait_for_poll(void);
extern void x54x_io_set(x54x_t *dev, uint32_t base, uint8_t len);

View File

@@ -247,7 +247,7 @@ void* fluidsynth_init(const device_t *info)
#endif
if (fluidsynth_handle == NULL)
{
ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2171);
ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2081);
return NULL;
}

View File

@@ -11,7 +11,7 @@
* This is intended to be used by another SVGA driver,
* and not as a card in it's own right.
*
* Version: @(#)vid_svga.c 1.0.30 2018/04/26
* Version: @(#)vid_svga.c 1.0.31 2018/05/26
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -966,7 +966,7 @@ uint8_t
svga_read_common(uint32_t addr, uint8_t linear, void *p)
{
svga_t *svga = (svga_t *)p;
uint32_t latch_addr, ret;
uint32_t latch_addr = 0, ret;
int readplane = svga->readplane;
uint8_t ret8;
@@ -1104,7 +1104,7 @@ svga_doblit(int y1, int y2, int wx, int wy, svga_t *svga)
p = &((uint32_t *)buffer32->line[i & 0x7ff])[32];
for (j = 0; j < (xsize + x_add); j++)
p[j] = svga_color_transform(svga->overscan_color);
p[j] = svga->overscan_color;
}
/* Draw (overscan_size + scroll size) lines of overscan on the bottom. */
@@ -1112,7 +1112,7 @@ svga_doblit(int y1, int y2, int wx, int wy, svga_t *svga)
p = &((uint32_t *)buffer32->line[(ysize + (y_add >> 1) + i) & 0x7ff])[32];
for (j = 0; j < (xsize + x_add); j++)
p[j] = svga_color_transform(svga->overscan_color);
p[j] = svga->overscan_color;
}
for (i = (y_add >> 1); i < (ysize + (y_add >> 1)); i ++) {
@@ -1120,7 +1120,7 @@ svga_doblit(int y1, int y2, int wx, int wy, svga_t *svga)
for (j = 0; j < 8; j++) {
p[j] = svga->pallook[svga->overscan_color];
p[xsize + (x_add >> 1) + j] = svga_color_transform(svga->overscan_color);
p[xsize + (x_add >> 1) + j] = svga->overscan_color;
}
}
}

View File

@@ -8,7 +8,7 @@
*
* Generic SVGA handling.
*
* Version: @(#)vid_svga.h 1.0.11 2018/04/01
* Version: @(#)vid_svga.h 1.0.12 2018/05/26
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -170,36 +170,3 @@ enum {
RAMDAC_6BIT = 0,
RAMDAC_8BIT
};
extern uint32_t shade[5][256];
static __inline__ uint32_t
svga_color_transform(uint32_t color)
{
uint8_t *clr8 = (uint8_t *) &color;
if (!video_grayscale && !invert_display)
return color;
if (video_grayscale) {
if (video_graytype) {
if (video_graytype == 1)
color = ((54 * (uint32_t)clr8[2]) + (183 * (uint32_t)clr8[1]) + (18 * (uint32_t)clr8[0])) / 255;
else
color = ((uint32_t)clr8[2] + (uint32_t)clr8[1] + (uint32_t)clr8[0]) / 3;
} else
color = ((76 * (uint32_t)clr8[2]) + (150 * (uint32_t)clr8[1]) + (29 * (uint32_t)clr8[0])) / 255;
switch (video_grayscale) {
case 2: case 3: case 4:
color = shade[video_grayscale][color];
break;
default:
clr8[3] = 0;
clr8[0] = color;
clr8[1] = clr8[2] = clr8[0];
break;
}
}
if (invert_display)
color ^= 0x00ffffff;
return color;
}

View File

@@ -8,7 +8,7 @@
*
* SVGA renderers.
*
* Version: @(#)vid_svga_render.c 1.0.10 2018/03/19
* Version: @(#)vid_svga_render.c 1.0.11 2018/05/26
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -27,71 +27,6 @@
#include "vid_svga_render.h"
int invert_display = 0;
int video_grayscale = 0;
int video_graytype = 0;
uint32_t shade[5][256] =
{
{0}, // RGB Color (unused)
{0}, // RGB Grayscale (unused)
{ // Amber monitor
0x000000, 0x060000, 0x090000, 0x0d0000, 0x100000, 0x120100, 0x150100, 0x170100, 0x1a0100, 0x1c0100, 0x1e0200, 0x210200, 0x230200, 0x250300, 0x270300, 0x290300,
0x2b0400, 0x2d0400, 0x2f0400, 0x300500, 0x320500, 0x340500, 0x360600, 0x380600, 0x390700, 0x3b0700, 0x3d0700, 0x3f0800, 0x400800, 0x420900, 0x440900, 0x450a00,
0x470a00, 0x480b00, 0x4a0b00, 0x4c0c00, 0x4d0c00, 0x4f0d00, 0x500d00, 0x520e00, 0x530e00, 0x550f00, 0x560f00, 0x581000, 0x591000, 0x5b1100, 0x5c1200, 0x5e1200,
0x5f1300, 0x601300, 0x621400, 0x631500, 0x651500, 0x661600, 0x671600, 0x691700, 0x6a1800, 0x6c1800, 0x6d1900, 0x6e1a00, 0x701a00, 0x711b00, 0x721c00, 0x741c00,
0x751d00, 0x761e00, 0x781e00, 0x791f00, 0x7a2000, 0x7c2000, 0x7d2100, 0x7e2200, 0x7f2300, 0x812300, 0x822400, 0x832500, 0x842600, 0x862600, 0x872700, 0x882800,
0x8a2900, 0x8b2900, 0x8c2a00, 0x8d2b00, 0x8e2c00, 0x902c00, 0x912d00, 0x922e00, 0x932f00, 0x953000, 0x963000, 0x973100, 0x983200, 0x993300, 0x9b3400, 0x9c3400,
0x9d3500, 0x9e3600, 0x9f3700, 0xa03800, 0xa23900, 0xa33a00, 0xa43a00, 0xa53b00, 0xa63c00, 0xa73d00, 0xa93e00, 0xaa3f00, 0xab4000, 0xac4000, 0xad4100, 0xae4200,
0xaf4300, 0xb14400, 0xb24500, 0xb34600, 0xb44700, 0xb54800, 0xb64900, 0xb74a00, 0xb94a00, 0xba4b00, 0xbb4c00, 0xbc4d00, 0xbd4e00, 0xbe4f00, 0xbf5000, 0xc05100,
0xc15200, 0xc25300, 0xc45400, 0xc55500, 0xc65600, 0xc75700, 0xc85800, 0xc95900, 0xca5a00, 0xcb5b00, 0xcc5c00, 0xcd5d00, 0xce5e00, 0xcf5f00, 0xd06000, 0xd26101,
0xd36201, 0xd46301, 0xd56401, 0xd66501, 0xd76601, 0xd86701, 0xd96801, 0xda6901, 0xdb6a01, 0xdc6b01, 0xdd6c01, 0xde6d01, 0xdf6e01, 0xe06f01, 0xe17001, 0xe27201,
0xe37301, 0xe47401, 0xe57501, 0xe67602, 0xe77702, 0xe87802, 0xe97902, 0xeb7a02, 0xec7b02, 0xed7c02, 0xee7e02, 0xef7f02, 0xf08002, 0xf18103, 0xf28203, 0xf38303,
0xf48403, 0xf58503, 0xf68703, 0xf78803, 0xf88903, 0xf98a04, 0xfa8b04, 0xfb8c04, 0xfc8d04, 0xfd8f04, 0xfe9005, 0xff9105, 0xff9205, 0xff9305, 0xff9405, 0xff9606,
0xff9706, 0xff9806, 0xff9906, 0xff9a07, 0xff9b07, 0xff9d07, 0xff9e08, 0xff9f08, 0xffa008, 0xffa109, 0xffa309, 0xffa409, 0xffa50a, 0xffa60a, 0xffa80a, 0xffa90b,
0xffaa0b, 0xffab0c, 0xffac0c, 0xffae0d, 0xffaf0d, 0xffb00e, 0xffb10e, 0xffb30f, 0xffb40f, 0xffb510, 0xffb610, 0xffb811, 0xffb912, 0xffba12, 0xffbb13, 0xffbd14,
0xffbe14, 0xffbf15, 0xffc016, 0xffc217, 0xffc317, 0xffc418, 0xffc619, 0xffc71a, 0xffc81b, 0xffca1c, 0xffcb1d, 0xffcc1e, 0xffcd1f, 0xffcf20, 0xffd021, 0xffd122,
0xffd323, 0xffd424, 0xffd526, 0xffd727, 0xffd828, 0xffd92a, 0xffdb2b, 0xffdc2c, 0xffdd2e, 0xffdf2f, 0xffe031, 0xffe133, 0xffe334, 0xffe436, 0xffe538, 0xffe739
},
{ // Green monitor
0x000000, 0x000400, 0x000700, 0x000900, 0x000b00, 0x000d00, 0x000f00, 0x001100, 0x001300, 0x001500, 0x001600, 0x001800, 0x001a00, 0x001b00, 0x001d00, 0x001e00,
0x002000, 0x002100, 0x002300, 0x002400, 0x002601, 0x002701, 0x002901, 0x002a01, 0x002b01, 0x002d01, 0x002e01, 0x002f01, 0x003101, 0x003201, 0x003301, 0x003401,
0x003601, 0x003702, 0x003802, 0x003902, 0x003b02, 0x003c02, 0x003d02, 0x003e02, 0x004002, 0x004102, 0x004203, 0x004303, 0x004403, 0x004503, 0x004703, 0x004803,
0x004903, 0x004a03, 0x004b04, 0x004c04, 0x004d04, 0x004e04, 0x005004, 0x005104, 0x005205, 0x005305, 0x005405, 0x005505, 0x005605, 0x005705, 0x005806, 0x005906,
0x005a06, 0x005b06, 0x005d06, 0x005e07, 0x005f07, 0x006007, 0x006107, 0x006207, 0x006308, 0x006408, 0x006508, 0x006608, 0x006708, 0x006809, 0x006909, 0x006a09,
0x006b09, 0x016c0a, 0x016d0a, 0x016e0a, 0x016f0a, 0x01700b, 0x01710b, 0x01720b, 0x01730b, 0x01740c, 0x01750c, 0x01760c, 0x01770c, 0x01780d, 0x01790d, 0x017a0d,
0x017b0d, 0x017b0e, 0x017c0e, 0x017d0e, 0x017e0f, 0x017f0f, 0x01800f, 0x018110, 0x028210, 0x028310, 0x028410, 0x028511, 0x028611, 0x028711, 0x028812, 0x028912,
0x028a12, 0x028a13, 0x028b13, 0x028c13, 0x028d14, 0x028e14, 0x038f14, 0x039015, 0x039115, 0x039215, 0x039316, 0x039416, 0x039417, 0x039517, 0x039617, 0x039718,
0x049818, 0x049918, 0x049a19, 0x049b19, 0x049c19, 0x049c1a, 0x049d1a, 0x049e1b, 0x059f1b, 0x05a01b, 0x05a11c, 0x05a21c, 0x05a31c, 0x05a31d, 0x05a41d, 0x06a51e,
0x06a61e, 0x06a71f, 0x06a81f, 0x06a920, 0x06aa20, 0x07aa21, 0x07ab21, 0x07ac21, 0x07ad22, 0x07ae22, 0x08af23, 0x08b023, 0x08b024, 0x08b124, 0x08b225, 0x09b325,
0x09b426, 0x09b526, 0x09b527, 0x0ab627, 0x0ab728, 0x0ab828, 0x0ab929, 0x0bba29, 0x0bba2a, 0x0bbb2a, 0x0bbc2b, 0x0cbd2b, 0x0cbe2c, 0x0cbf2c, 0x0dbf2d, 0x0dc02d,
0x0dc12e, 0x0ec22e, 0x0ec32f, 0x0ec42f, 0x0fc430, 0x0fc530, 0x0fc631, 0x10c731, 0x10c832, 0x10c932, 0x11c933, 0x11ca33, 0x11cb34, 0x12cc35, 0x12cd35, 0x12cd36,
0x13ce36, 0x13cf37, 0x13d037, 0x14d138, 0x14d139, 0x14d239, 0x15d33a, 0x15d43a, 0x16d43b, 0x16d53b, 0x17d63c, 0x17d73d, 0x17d83d, 0x18d83e, 0x18d93e, 0x19da3f,
0x19db40, 0x1adc40, 0x1adc41, 0x1bdd41, 0x1bde42, 0x1cdf43, 0x1ce043, 0x1de044, 0x1ee145, 0x1ee245, 0x1fe346, 0x1fe446, 0x20e447, 0x20e548, 0x21e648, 0x22e749,
0x22e74a, 0x23e84a, 0x23e94b, 0x24ea4c, 0x25ea4c, 0x25eb4d, 0x26ec4e, 0x27ed4e, 0x27ee4f, 0x28ee50, 0x29ef50, 0x29f051, 0x2af152, 0x2bf153, 0x2cf253, 0x2cf354,
0x2df455, 0x2ef455, 0x2ff556, 0x2ff657, 0x30f758, 0x31f758, 0x32f859, 0x32f95a, 0x33fa5a, 0x34fa5b, 0x35fb5c, 0x36fc5d, 0x37fd5d, 0x38fd5e, 0x38fe5f, 0x39ff60
},
{ // White monitor
0x000000, 0x010102, 0x020203, 0x020304, 0x030406, 0x040507, 0x050608, 0x060709, 0x07080a, 0x08090c, 0x080a0d, 0x090b0e, 0x0a0c0f, 0x0b0d10, 0x0c0e11, 0x0d0f12,
0x0e1013, 0x0f1115, 0x101216, 0x111317, 0x121418, 0x121519, 0x13161a, 0x14171b, 0x15181c, 0x16191d, 0x171a1e, 0x181b1f, 0x191c20, 0x1a1d21, 0x1b1e22, 0x1c1f23,
0x1d2024, 0x1e2125, 0x1f2226, 0x202327, 0x212428, 0x222529, 0x22262b, 0x23272c, 0x24282d, 0x25292e, 0x262a2f, 0x272b30, 0x282c30, 0x292d31, 0x2a2e32, 0x2b2f33,
0x2c3034, 0x2d3035, 0x2e3136, 0x2f3237, 0x303338, 0x313439, 0x32353a, 0x33363b, 0x34373c, 0x35383d, 0x36393e, 0x373a3f, 0x383b40, 0x393c41, 0x3a3d42, 0x3b3e43,
0x3c3f44, 0x3d4045, 0x3e4146, 0x3f4247, 0x404348, 0x414449, 0x42454a, 0x43464b, 0x44474c, 0x45484d, 0x46494d, 0x474a4e, 0x484b4f, 0x484c50, 0x494d51, 0x4a4e52,
0x4b4f53, 0x4c5054, 0x4d5155, 0x4e5256, 0x4f5357, 0x505458, 0x515559, 0x52565a, 0x53575b, 0x54585b, 0x55595c, 0x565a5d, 0x575b5e, 0x585c5f, 0x595d60, 0x5a5e61,
0x5b5f62, 0x5c6063, 0x5d6164, 0x5e6265, 0x5f6366, 0x606466, 0x616567, 0x626668, 0x636769, 0x64686a, 0x65696b, 0x666a6c, 0x676b6d, 0x686c6e, 0x696d6f, 0x6a6e70,
0x6b6f70, 0x6c7071, 0x6d7172, 0x6f7273, 0x707374, 0x707475, 0x717576, 0x727677, 0x747778, 0x757879, 0x767979, 0x777a7a, 0x787b7b, 0x797c7c, 0x7a7d7d, 0x7b7e7e,
0x7c7f7f, 0x7d8080, 0x7e8181, 0x7f8281, 0x808382, 0x818483, 0x828584, 0x838685, 0x848786, 0x858887, 0x868988, 0x878a89, 0x888b89, 0x898c8a, 0x8a8d8b, 0x8b8e8c,
0x8c8f8d, 0x8d8f8e, 0x8e908f, 0x8f9190, 0x909290, 0x919391, 0x929492, 0x939593, 0x949694, 0x959795, 0x969896, 0x979997, 0x989a98, 0x999b98, 0x9a9c99, 0x9b9d9a,
0x9c9e9b, 0x9d9f9c, 0x9ea09d, 0x9fa19e, 0xa0a29f, 0xa1a39f, 0xa2a4a0, 0xa3a5a1, 0xa4a6a2, 0xa6a7a3, 0xa7a8a4, 0xa8a9a5, 0xa9aaa5, 0xaaaba6, 0xabaca7, 0xacada8,
0xadaea9, 0xaeafaa, 0xafb0ab, 0xb0b1ac, 0xb1b2ac, 0xb2b3ad, 0xb3b4ae, 0xb4b5af, 0xb5b6b0, 0xb6b7b1, 0xb7b8b2, 0xb8b9b2, 0xb9bab3, 0xbabbb4, 0xbbbcb5, 0xbcbdb6,
0xbdbeb7, 0xbebfb8, 0xbfc0b8, 0xc0c1b9, 0xc1c2ba, 0xc2c3bb, 0xc3c4bc, 0xc5c5bd, 0xc6c6be, 0xc7c7be, 0xc8c8bf, 0xc9c9c0, 0xcacac1, 0xcbcbc2, 0xccccc3, 0xcdcdc3,
0xcecec4, 0xcfcfc5, 0xd0d0c6, 0xd1d1c7, 0xd2d2c8, 0xd3d3c9, 0xd4d4c9, 0xd5d5ca, 0xd6d6cb, 0xd7d7cc, 0xd8d8cd, 0xd9d9ce, 0xdadacf, 0xdbdbcf, 0xdcdcd0, 0xdeddd1,
0xdfded2, 0xe0dfd3, 0xe1e0d4, 0xe2e1d4, 0xe3e2d5, 0xe4e3d6, 0xe5e4d7, 0xe6e5d8, 0xe7e6d9, 0xe8e7d9, 0xe9e8da, 0xeae9db, 0xebeadc, 0xecebdd, 0xedecde, 0xeeeddf,
0xefeedf, 0xf0efe0, 0xf1f0e1, 0xf2f1e2, 0xf3f2e3, 0xf4f3e3, 0xf6f3e4, 0xf7f4e5, 0xf8f5e6, 0xf9f6e7, 0xfaf7e8, 0xfbf8e9, 0xfcf9e9, 0xfdfaea, 0xfefbeb, 0xfffcec
}
};
void svga_render_blank(svga_t *svga)
{
int x, xx;
@@ -107,16 +42,16 @@ void svga_render_blank(svga_t *svga)
switch (svga->seqregs[1] & 9)
{
case 0:
for (xx = 0; xx < 9; xx++) ((uint32_t *)buffer32->line[svga->displine + y_add])[(x * 9) + xx + 32 + x_add] = svga_color_transform(0);
for (xx = 0; xx < 9; xx++) ((uint32_t *)buffer32->line[svga->displine + y_add])[(x * 9) + xx + 32 + x_add] = 0;
break;
case 1:
for (xx = 0; xx < 8; xx++) ((uint32_t *)buffer32->line[svga->displine + y_add])[(x * 8) + xx + 32 + x_add] = svga_color_transform(0);
for (xx = 0; xx < 8; xx++) ((uint32_t *)buffer32->line[svga->displine + y_add])[(x * 8) + xx + 32 + x_add] = 0;
break;
case 8:
for (xx = 0; xx < 18; xx++) ((uint32_t *)buffer32->line[svga->displine + y_add])[(x * 18) + xx + 32 + x_add] = svga_color_transform(0);
for (xx = 0; xx < 18; xx++) ((uint32_t *)buffer32->line[svga->displine + y_add])[(x * 18) + xx + 32 + x_add] = 0;
break;
case 9:
for (xx = 0; xx < 16; xx++) ((uint32_t *)buffer32->line[svga->displine + y_add])[(x * 16) + xx + 32 + x_add] = svga_color_transform(0);
for (xx = 0; xx < 16; xx++) ((uint32_t *)buffer32->line[svga->displine + y_add])[(x * 16) + xx + 32 + x_add] = 0;
break;
}
}
@@ -166,9 +101,6 @@ void svga_render_text_40(svga_t *svga)
}
}
fg = svga_color_transform(fg);
bg = svga_color_transform(bg);
dat = svga->vram[charaddr + (svga->sc << 2)];
if (svga->seqregs[1] & 1)
{
@@ -237,9 +169,6 @@ void svga_render_text_80(svga_t *svga)
}
}
fg = svga_color_transform(fg);
bg = svga_color_transform(bg);
dat = svga->vram[charaddr + (svga->sc << 2)];
if (svga->seqregs[1] & 1)
{
@@ -306,9 +235,6 @@ void svga_render_text_80_ksc5601(svga_t *svga)
}
}
fg = svga_color_transform(fg);
bg = svga_color_transform(bg);
if(x + xinc < svga->hdisp && (chr & nextchr & 0x80))
{
if((chr == 0xc9 || chr == 0xfe) && (nextchr > 0xa0 && nextchr < 0xff))
@@ -417,14 +343,14 @@ void svga_render_2bpp_lowres(svga_t *svga)
svga->ma += 4;
svga->ma &= svga->vram_display_mask;
p[0] = p[1] = svga_color_transform(svga->pallook[svga->egapal[(dat[0] >> 6) & 3]]);
p[2] = p[3] = svga_color_transform(svga->pallook[svga->egapal[(dat[0] >> 4) & 3]]);
p[4] = p[5] = svga_color_transform(svga->pallook[svga->egapal[(dat[0] >> 2) & 3]]);
p[6] = p[7] = svga_color_transform(svga->pallook[svga->egapal[dat[0] & 3]]);
p[8] = p[9] = svga_color_transform(svga->pallook[svga->egapal[(dat[1] >> 6) & 3]]);
p[10] = p[11] = svga_color_transform(svga->pallook[svga->egapal[(dat[1] >> 4) & 3]]);
p[12] = p[13] = svga_color_transform(svga->pallook[svga->egapal[(dat[1] >> 2) & 3]]);
p[14] = p[15] = svga_color_transform(svga->pallook[svga->egapal[dat[1] & 3]]);
p[0] = p[1] = svga->pallook[svga->egapal[(dat[0] >> 6) & 3]];
p[2] = p[3] = svga->pallook[svga->egapal[(dat[0] >> 4) & 3]];
p[4] = p[5] = svga->pallook[svga->egapal[(dat[0] >> 2) & 3]];
p[6] = p[7] = svga->pallook[svga->egapal[dat[0] & 3]];
p[8] = p[9] = svga->pallook[svga->egapal[(dat[1] >> 6) & 3]];
p[10] = p[11] = svga->pallook[svga->egapal[(dat[1] >> 4) & 3]];
p[12] = p[13] = svga->pallook[svga->egapal[(dat[1] >> 2) & 3]];
p[14] = p[15] = svga->pallook[svga->egapal[dat[1] & 3]];
p += 16;
}
@@ -459,14 +385,14 @@ void svga_render_2bpp_highres(svga_t *svga)
svga->ma += 4;
svga->ma &= svga->vram_display_mask;
p[0] = svga_color_transform(svga->pallook[svga->egapal[(dat[0] >> 6) & 3]]);
p[1] = svga_color_transform(svga->pallook[svga->egapal[(dat[0] >> 4) & 3]]);
p[2] = svga_color_transform(svga->pallook[svga->egapal[(dat[0] >> 2) & 3]]);
p[3] = svga_color_transform(svga->pallook[svga->egapal[dat[0] & 3]]);
p[4] = svga_color_transform(svga->pallook[svga->egapal[(dat[1] >> 6) & 3]]);
p[5] = svga_color_transform(svga->pallook[svga->egapal[(dat[1] >> 4) & 3]]);
p[6] = svga_color_transform(svga->pallook[svga->egapal[(dat[1] >> 2) & 3]]);
p[7] = svga_color_transform(svga->pallook[svga->egapal[dat[1] & 3]]);
p[0] = svga->pallook[svga->egapal[(dat[0] >> 6) & 3]];
p[1] = svga->pallook[svga->egapal[(dat[0] >> 4) & 3]];
p[2] = svga->pallook[svga->egapal[(dat[0] >> 2) & 3]];
p[3] = svga->pallook[svga->egapal[dat[0] & 3]];
p[4] = svga->pallook[svga->egapal[(dat[1] >> 6) & 3]];
p[5] = svga->pallook[svga->egapal[(dat[1] >> 4) & 3]];
p[6] = svga->pallook[svga->egapal[(dat[1] >> 2) & 3]];
p[7] = svga->pallook[svga->egapal[dat[1] & 3]];
p += 8;
}
@@ -498,17 +424,17 @@ void svga_render_4bpp_lowres(svga_t *svga)
svga->ma &= svga->vram_display_mask;
dat = edatlookup[edat[0] >> 6][edat[1] >> 6] | (edatlookup[edat[2] >> 6][edat[3] >> 6] << 2);
p[0] = p[1] = svga_color_transform(svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]);
p[2] = p[3] = svga_color_transform(svga->pallook[svga->egapal[dat & svga->plane_mask]]);
p[0] = p[1] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]];
p[2] = p[3] = svga->pallook[svga->egapal[dat & svga->plane_mask]];
dat = edatlookup[(edat[0] >> 4) & 3][(edat[1] >> 4) & 3] | (edatlookup[(edat[2] >> 4) & 3][(edat[3] >> 4) & 3] << 2);
p[4] = p[5] = svga_color_transform(svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]);
p[6] = p[7] = svga_color_transform(svga->pallook[svga->egapal[dat & svga->plane_mask]]);
p[4] = p[5] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]];
p[6] = p[7] = svga->pallook[svga->egapal[dat & svga->plane_mask]];
dat = edatlookup[(edat[0] >> 2) & 3][(edat[1] >> 2) & 3] | (edatlookup[(edat[2] >> 2) & 3][(edat[3] >> 2) & 3] << 2);
p[8] = p[9] = svga_color_transform(svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]);
p[10] = p[11] = svga_color_transform(svga->pallook[svga->egapal[dat & svga->plane_mask]]);
p[8] = p[9] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]];
p[10] = p[11] = svga->pallook[svga->egapal[dat & svga->plane_mask]];
dat = edatlookup[edat[0] & 3][edat[1] & 3] | (edatlookup[edat[2] & 3][edat[3] & 3] << 2);
p[12] = p[13] = svga_color_transform(svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]);
p[14] = p[15] = svga_color_transform(svga->pallook[svga->egapal[dat & svga->plane_mask]]);
p[12] = p[13] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]];
p[14] = p[15] = svga->pallook[svga->egapal[dat & svga->plane_mask]];
p += 16;
}
@@ -544,17 +470,17 @@ void svga_render_4bpp_highres(svga_t *svga)
svga->ma &= svga->vram_display_mask;
dat = edatlookup[edat[0] >> 6][edat[1] >> 6] | (edatlookup[edat[2] >> 6][edat[3] >> 6] << 2);
p[0] = svga_color_transform(svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]);
p[1] = svga_color_transform(svga->pallook[svga->egapal[dat & svga->plane_mask]]);
p[0] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]];
p[1] = svga->pallook[svga->egapal[dat & svga->plane_mask]];
dat = edatlookup[(edat[0] >> 4) & 3][(edat[1] >> 4) & 3] | (edatlookup[(edat[2] >> 4) & 3][(edat[3] >> 4) & 3] << 2);
p[2] = svga_color_transform(svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]);
p[3] = svga_color_transform(svga->pallook[svga->egapal[dat & svga->plane_mask]]);
p[2] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]];
p[3] = svga->pallook[svga->egapal[dat & svga->plane_mask]];
dat = edatlookup[(edat[0] >> 2) & 3][(edat[1] >> 2) & 3] | (edatlookup[(edat[2] >> 2) & 3][(edat[3] >> 2) & 3] << 2);
p[4] = svga_color_transform(svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]);
p[5] = svga_color_transform(svga->pallook[svga->egapal[dat & svga->plane_mask]]);
p[4] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]];
p[5] = svga->pallook[svga->egapal[dat & svga->plane_mask]];
dat = edatlookup[edat[0] & 3][edat[1] & 3] | (edatlookup[edat[2] & 3][edat[3] & 3] << 2);
p[6] = svga_color_transform(svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]);
p[7] = svga_color_transform(svga->pallook[svga->egapal[dat & svga->plane_mask]]);
p[6] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]];
p[7] = svga->pallook[svga->egapal[dat & svga->plane_mask]];
p += 8;
}
@@ -580,10 +506,10 @@ void svga_render_8bpp_lowres(svga_t *svga)
{
uint32_t dat = *(uint32_t *)(&svga->vram[svga->ma & svga->vram_display_mask]);
p[0] = p[1] = svga_color_transform(svga->pallook[dat & 0xff]);
p[2] = p[3] = svga_color_transform(svga->pallook[(dat >> 8) & 0xff]);
p[4] = p[5] = svga_color_transform(svga->pallook[(dat >> 16) & 0xff]);
p[6] = p[7] = svga_color_transform(svga->pallook[(dat >> 24) & 0xff]);
p[0] = p[1] = svga->pallook[dat & 0xff];
p[2] = p[3] = svga->pallook[(dat >> 8) & 0xff];
p[4] = p[5] = svga->pallook[(dat >> 16) & 0xff];
p[6] = p[7] = svga->pallook[(dat >> 24) & 0xff];
svga->ma += 4;
p += 8;
@@ -611,16 +537,16 @@ void svga_render_8bpp_highres(svga_t *svga)
{
uint32_t dat;
dat = *(uint32_t *)(&svga->vram[svga->ma & svga->vram_display_mask]);
p[0] = svga_color_transform(svga->pallook[dat & 0xff]);
p[1] = svga_color_transform(svga->pallook[(dat >> 8) & 0xff]);
p[2] = svga_color_transform(svga->pallook[(dat >> 16) & 0xff]);
p[3] = svga_color_transform(svga->pallook[(dat >> 24) & 0xff]);
p[0] = svga->pallook[dat & 0xff];
p[1] = svga->pallook[(dat >> 8) & 0xff];
p[2] = svga->pallook[(dat >> 16) & 0xff];
p[3] = svga->pallook[(dat >> 24) & 0xff];
dat = *(uint32_t *)(&svga->vram[(svga->ma + 4) & svga->vram_display_mask]);
p[4] = svga_color_transform(svga->pallook[dat & 0xff]);
p[5] = svga_color_transform(svga->pallook[(dat >> 8) & 0xff]);
p[6] = svga_color_transform(svga->pallook[(dat >> 16) & 0xff]);
p[7] = svga_color_transform(svga->pallook[(dat >> 24) & 0xff]);
p[4] = svga->pallook[dat & 0xff];
p[5] = svga->pallook[(dat >> 8) & 0xff];
p[6] = svga->pallook[(dat >> 16) & 0xff];
p[7] = svga->pallook[(dat >> 24) & 0xff];
svga->ma += 8;
p += 8;
@@ -648,13 +574,13 @@ void svga_render_15bpp_lowres(svga_t *svga)
{
uint32_t dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1)) & svga->vram_display_mask]);
p[x] = svga_color_transform(video_15to32[dat & 0xffff]);
p[x + 1] = svga_color_transform(video_15to32[dat >> 16]);
p[x] = video_15to32[dat & 0xffff];
p[x + 1] = video_15to32[dat >> 16];
dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 4) & svga->vram_display_mask]);
p[x] = svga_color_transform(video_15to32[dat & 0xffff]);
p[x + 1] = svga_color_transform(video_15to32[dat >> 16]);
p[x] = video_15to32[dat & 0xffff];
p[x + 1] = video_15to32[dat >> 16];
}
svga->ma += x << 1;
svga->ma &= svga->vram_display_mask;
@@ -679,20 +605,20 @@ void svga_render_15bpp_highres(svga_t *svga)
for (x = 0; x <= svga->hdisp; x += 8)
{
uint32_t dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1)) & svga->vram_display_mask]);
p[x] = svga_color_transform(video_15to32[dat & 0xffff]);
p[x + 1] = svga_color_transform(video_15to32[dat >> 16]);
p[x] = video_15to32[dat & 0xffff];
p[x + 1] = video_15to32[dat >> 16];
dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 4) & svga->vram_display_mask]);
p[x + 2] = svga_color_transform(video_15to32[dat & 0xffff]);
p[x + 3] = svga_color_transform(video_15to32[dat >> 16]);
p[x + 2] = video_15to32[dat & 0xffff];
p[x + 3] = video_15to32[dat >> 16];
dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 8) & svga->vram_display_mask]);
p[x + 4] = svga_color_transform(video_15to32[dat & 0xffff]);
p[x + 5] = svga_color_transform(video_15to32[dat >> 16]);
p[x + 4] = video_15to32[dat & 0xffff];
p[x + 5] = video_15to32[dat >> 16];
dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 12) & svga->vram_display_mask]);
p[x + 6] = svga_color_transform(video_15to32[dat & 0xffff]);
p[x + 7] = svga_color_transform(video_15to32[dat >> 16]);
p[x + 6] = video_15to32[dat & 0xffff];
p[x + 7] = video_15to32[dat >> 16];
}
svga->ma += x << 1;
svga->ma &= svga->vram_display_mask;
@@ -718,13 +644,13 @@ void svga_render_16bpp_lowres(svga_t *svga)
{
uint32_t dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1)) & svga->vram_display_mask]);
p[x] = svga_color_transform(video_16to32[dat & 0xffff]);
p[x + 1] = svga_color_transform(video_16to32[dat >> 16]);
p[x] = video_16to32[dat & 0xffff];
p[x + 1] = video_16to32[dat >> 16];
dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 4) & svga->vram_display_mask]);
p[x] = svga_color_transform(video_16to32[dat & 0xffff]);
p[x + 1] = svga_color_transform(video_16to32[dat >> 16]);
p[x] = video_16to32[dat & 0xffff];
p[x + 1] = video_16to32[dat >> 16];
}
svga->ma += x << 1;
svga->ma &= svga->vram_display_mask;
@@ -749,20 +675,20 @@ void svga_render_16bpp_highres(svga_t *svga)
for (x = 0; x <= svga->hdisp; x += 8)
{
uint32_t dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1)) & svga->vram_display_mask]);
p[x] = svga_color_transform(video_16to32[dat & 0xffff]);
p[x + 1] = svga_color_transform(video_16to32[dat >> 16]);
p[x] = video_16to32[dat & 0xffff];
p[x + 1] = video_16to32[dat >> 16];
dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 4) & svga->vram_display_mask]);
p[x + 2] = svga_color_transform(video_16to32[dat & 0xffff]);
p[x + 3] = svga_color_transform(video_16to32[dat >> 16]);
p[x + 2] = video_16to32[dat & 0xffff];
p[x + 3] = video_16to32[dat >> 16];
dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 8) & svga->vram_display_mask]);
p[x + 4] = svga_color_transform(video_16to32[dat & 0xffff]);
p[x + 5] = svga_color_transform(video_16to32[dat >> 16]);
p[x + 4] = video_16to32[dat & 0xffff];
p[x + 5] = video_16to32[dat >> 16];
dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 12) & svga->vram_display_mask]);
p[x + 6] = svga_color_transform(video_16to32[dat & 0xffff]);
p[x + 7] = svga_color_transform(video_16to32[dat >> 16]);
p[x + 6] = video_16to32[dat & 0xffff];
p[x + 7] = video_16to32[dat >> 16];
}
svga->ma += x << 1;
svga->ma &= svga->vram_display_mask;
@@ -790,7 +716,7 @@ void svga_render_24bpp_lowres(svga_t *svga)
fg = svga->vram[svga->ma] | (svga->vram[svga->ma + 1] << 8) | (svga->vram[svga->ma + 2] << 16);
svga->ma += 3;
svga->ma &= svga->vram_display_mask;
((uint32_t *)buffer32->line[svga->displine + y_add])[(x << 1) + offset + x_add] = ((uint32_t *)buffer32->line[svga->displine + y_add])[(x << 1) + 1 + offset + x_add] = svga_color_transform(fg);
((uint32_t *)buffer32->line[svga->displine + y_add])[(x << 1) + offset + x_add] = ((uint32_t *)buffer32->line[svga->displine + y_add])[(x << 1) + 1 + offset + x_add] = fg;
}
}
}
@@ -813,16 +739,16 @@ void svga_render_24bpp_highres(svga_t *svga)
for (x = 0; x <= svga->hdisp; x += 4)
{
uint32_t dat = *(uint32_t *)(&svga->vram[svga->ma & svga->vram_display_mask]);
p[x] = svga_color_transform(dat & 0xffffff);
p[x] = dat & 0xffffff;
dat = *(uint32_t *)(&svga->vram[(svga->ma + 3) & svga->vram_display_mask]);
p[x + 1] = svga_color_transform(dat & 0xffffff);
p[x + 1] = dat & 0xffffff;
dat = *(uint32_t *)(&svga->vram[(svga->ma + 6) & svga->vram_display_mask]);
p[x + 2] = svga_color_transform(dat & 0xffffff);
p[x + 2] = dat & 0xffffff;
dat = *(uint32_t *)(&svga->vram[(svga->ma + 9) & svga->vram_display_mask]);
p[x + 3] = svga_color_transform(dat & 0xffffff);
p[x + 3] = dat & 0xffffff;
svga->ma += 12;
}
@@ -851,7 +777,7 @@ void svga_render_32bpp_lowres(svga_t *svga)
fg = svga->vram[svga->ma] | (svga->vram[svga->ma + 1] << 8) | (svga->vram[svga->ma + 2] << 16);
svga->ma += 4;
svga->ma &= svga->vram_display_mask;
((uint32_t *)buffer32->line[svga->displine + y_add])[(x << 1) + offset + x_add] = ((uint32_t *)buffer32->line[svga->displine + y_add])[(x << 1) + 1 + offset + x_add] = svga_color_transform(fg);
((uint32_t *)buffer32->line[svga->displine + y_add])[(x << 1) + offset + x_add] = ((uint32_t *)buffer32->line[svga->displine + y_add])[(x << 1) + 1 + offset + x_add] = fg;
}
}
}
@@ -876,7 +802,7 @@ void svga_render_32bpp_highres(svga_t *svga)
for (x = 0; x <= svga->hdisp; x++)
{
uint32_t dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 2)) & svga->vram_display_mask]);
p[x] = svga_color_transform(dat & 0xffffff);
p[x] = dat & 0xffffff;
}
svga->ma += 4;
svga->ma &= svga->vram_display_mask;
@@ -901,7 +827,7 @@ void svga_render_ABGR8888_highres(svga_t *svga)
for (x = 0; x <= svga->hdisp; x++)
{
uint32_t dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 2)) & svga->vram_display_mask]);
p[x] = svga_color_transform((dat & 0xff0000) >> 16) | (dat & 0x00ff00) | ((dat & 0x0000ff) << 16);
p[x] = ((dat & 0xff0000) >> 16) | (dat & 0x00ff00) | ((dat & 0x0000ff) << 16);
}
svga->ma += 4;
svga->ma &= svga->vram_display_mask;
@@ -926,7 +852,7 @@ void svga_render_RGBA8888_highres(svga_t *svga)
for (x = 0; x <= svga->hdisp; x++)
{
uint32_t dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 2)) & svga->vram_display_mask]);
p[x] = svga_color_transform(dat >> 8);
p[x] = dat >> 8;
}
svga->ma += 4;
svga->ma &= svga->vram_display_mask;

View File

@@ -40,7 +40,7 @@
* W = 3 bus clocks
* L = 4 bus clocks
*
* Version: @(#)video.c 1.0.22 2018/04/29
* Version: @(#)video.c 1.0.23 2018/05/25
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -106,15 +106,12 @@ int video_timing_write_b = 0,
int video_res_x = 0,
video_res_y = 0,
video_bpp = 0;
int video_timing[6][4] = {
{ VIDEO_ISA, 8, 16, 32 },
{ VIDEO_ISA, 6, 8, 16 },
{ VIDEO_ISA, 3, 3, 6 },
{ VIDEO_BUS, 4, 8, 16 },
{ VIDEO_BUS, 4, 5, 10 },
{ VIDEO_BUS, 3, 3, 4 }
};
static int video_force_resize;
int invert_display = 0;
int video_grayscale = 0;
int video_graytype = 0;
PALETTE cgapal = {
{0,0,0}, {0,42,0}, {42,0,0}, {42,21,0},
{0,0,0}, {0,42,42}, {42,0,42}, {42,42,42},
@@ -182,6 +179,67 @@ PALETTE cgapal_mono[6] = {
};
const uint32_t shade[5][256] =
{
{0}, // RGB Color (unused)
{0}, // RGB Grayscale (unused)
{ // Amber monitor
0x000000, 0x060000, 0x090000, 0x0d0000, 0x100000, 0x120100, 0x150100, 0x170100, 0x1a0100, 0x1c0100, 0x1e0200, 0x210200, 0x230200, 0x250300, 0x270300, 0x290300,
0x2b0400, 0x2d0400, 0x2f0400, 0x300500, 0x320500, 0x340500, 0x360600, 0x380600, 0x390700, 0x3b0700, 0x3d0700, 0x3f0800, 0x400800, 0x420900, 0x440900, 0x450a00,
0x470a00, 0x480b00, 0x4a0b00, 0x4c0c00, 0x4d0c00, 0x4f0d00, 0x500d00, 0x520e00, 0x530e00, 0x550f00, 0x560f00, 0x581000, 0x591000, 0x5b1100, 0x5c1200, 0x5e1200,
0x5f1300, 0x601300, 0x621400, 0x631500, 0x651500, 0x661600, 0x671600, 0x691700, 0x6a1800, 0x6c1800, 0x6d1900, 0x6e1a00, 0x701a00, 0x711b00, 0x721c00, 0x741c00,
0x751d00, 0x761e00, 0x781e00, 0x791f00, 0x7a2000, 0x7c2000, 0x7d2100, 0x7e2200, 0x7f2300, 0x812300, 0x822400, 0x832500, 0x842600, 0x862600, 0x872700, 0x882800,
0x8a2900, 0x8b2900, 0x8c2a00, 0x8d2b00, 0x8e2c00, 0x902c00, 0x912d00, 0x922e00, 0x932f00, 0x953000, 0x963000, 0x973100, 0x983200, 0x993300, 0x9b3400, 0x9c3400,
0x9d3500, 0x9e3600, 0x9f3700, 0xa03800, 0xa23900, 0xa33a00, 0xa43a00, 0xa53b00, 0xa63c00, 0xa73d00, 0xa93e00, 0xaa3f00, 0xab4000, 0xac4000, 0xad4100, 0xae4200,
0xaf4300, 0xb14400, 0xb24500, 0xb34600, 0xb44700, 0xb54800, 0xb64900, 0xb74a00, 0xb94a00, 0xba4b00, 0xbb4c00, 0xbc4d00, 0xbd4e00, 0xbe4f00, 0xbf5000, 0xc05100,
0xc15200, 0xc25300, 0xc45400, 0xc55500, 0xc65600, 0xc75700, 0xc85800, 0xc95900, 0xca5a00, 0xcb5b00, 0xcc5c00, 0xcd5d00, 0xce5e00, 0xcf5f00, 0xd06000, 0xd26101,
0xd36201, 0xd46301, 0xd56401, 0xd66501, 0xd76601, 0xd86701, 0xd96801, 0xda6901, 0xdb6a01, 0xdc6b01, 0xdd6c01, 0xde6d01, 0xdf6e01, 0xe06f01, 0xe17001, 0xe27201,
0xe37301, 0xe47401, 0xe57501, 0xe67602, 0xe77702, 0xe87802, 0xe97902, 0xeb7a02, 0xec7b02, 0xed7c02, 0xee7e02, 0xef7f02, 0xf08002, 0xf18103, 0xf28203, 0xf38303,
0xf48403, 0xf58503, 0xf68703, 0xf78803, 0xf88903, 0xf98a04, 0xfa8b04, 0xfb8c04, 0xfc8d04, 0xfd8f04, 0xfe9005, 0xff9105, 0xff9205, 0xff9305, 0xff9405, 0xff9606,
0xff9706, 0xff9806, 0xff9906, 0xff9a07, 0xff9b07, 0xff9d07, 0xff9e08, 0xff9f08, 0xffa008, 0xffa109, 0xffa309, 0xffa409, 0xffa50a, 0xffa60a, 0xffa80a, 0xffa90b,
0xffaa0b, 0xffab0c, 0xffac0c, 0xffae0d, 0xffaf0d, 0xffb00e, 0xffb10e, 0xffb30f, 0xffb40f, 0xffb510, 0xffb610, 0xffb811, 0xffb912, 0xffba12, 0xffbb13, 0xffbd14,
0xffbe14, 0xffbf15, 0xffc016, 0xffc217, 0xffc317, 0xffc418, 0xffc619, 0xffc71a, 0xffc81b, 0xffca1c, 0xffcb1d, 0xffcc1e, 0xffcd1f, 0xffcf20, 0xffd021, 0xffd122,
0xffd323, 0xffd424, 0xffd526, 0xffd727, 0xffd828, 0xffd92a, 0xffdb2b, 0xffdc2c, 0xffdd2e, 0xffdf2f, 0xffe031, 0xffe133, 0xffe334, 0xffe436, 0xffe538, 0xffe739
},
{ // Green monitor
0x000000, 0x000400, 0x000700, 0x000900, 0x000b00, 0x000d00, 0x000f00, 0x001100, 0x001300, 0x001500, 0x001600, 0x001800, 0x001a00, 0x001b00, 0x001d00, 0x001e00,
0x002000, 0x002100, 0x002300, 0x002400, 0x002601, 0x002701, 0x002901, 0x002a01, 0x002b01, 0x002d01, 0x002e01, 0x002f01, 0x003101, 0x003201, 0x003301, 0x003401,
0x003601, 0x003702, 0x003802, 0x003902, 0x003b02, 0x003c02, 0x003d02, 0x003e02, 0x004002, 0x004102, 0x004203, 0x004303, 0x004403, 0x004503, 0x004703, 0x004803,
0x004903, 0x004a03, 0x004b04, 0x004c04, 0x004d04, 0x004e04, 0x005004, 0x005104, 0x005205, 0x005305, 0x005405, 0x005505, 0x005605, 0x005705, 0x005806, 0x005906,
0x005a06, 0x005b06, 0x005d06, 0x005e07, 0x005f07, 0x006007, 0x006107, 0x006207, 0x006308, 0x006408, 0x006508, 0x006608, 0x006708, 0x006809, 0x006909, 0x006a09,
0x006b09, 0x016c0a, 0x016d0a, 0x016e0a, 0x016f0a, 0x01700b, 0x01710b, 0x01720b, 0x01730b, 0x01740c, 0x01750c, 0x01760c, 0x01770c, 0x01780d, 0x01790d, 0x017a0d,
0x017b0d, 0x017b0e, 0x017c0e, 0x017d0e, 0x017e0f, 0x017f0f, 0x01800f, 0x018110, 0x028210, 0x028310, 0x028410, 0x028511, 0x028611, 0x028711, 0x028812, 0x028912,
0x028a12, 0x028a13, 0x028b13, 0x028c13, 0x028d14, 0x028e14, 0x038f14, 0x039015, 0x039115, 0x039215, 0x039316, 0x039416, 0x039417, 0x039517, 0x039617, 0x039718,
0x049818, 0x049918, 0x049a19, 0x049b19, 0x049c19, 0x049c1a, 0x049d1a, 0x049e1b, 0x059f1b, 0x05a01b, 0x05a11c, 0x05a21c, 0x05a31c, 0x05a31d, 0x05a41d, 0x06a51e,
0x06a61e, 0x06a71f, 0x06a81f, 0x06a920, 0x06aa20, 0x07aa21, 0x07ab21, 0x07ac21, 0x07ad22, 0x07ae22, 0x08af23, 0x08b023, 0x08b024, 0x08b124, 0x08b225, 0x09b325,
0x09b426, 0x09b526, 0x09b527, 0x0ab627, 0x0ab728, 0x0ab828, 0x0ab929, 0x0bba29, 0x0bba2a, 0x0bbb2a, 0x0bbc2b, 0x0cbd2b, 0x0cbe2c, 0x0cbf2c, 0x0dbf2d, 0x0dc02d,
0x0dc12e, 0x0ec22e, 0x0ec32f, 0x0ec42f, 0x0fc430, 0x0fc530, 0x0fc631, 0x10c731, 0x10c832, 0x10c932, 0x11c933, 0x11ca33, 0x11cb34, 0x12cc35, 0x12cd35, 0x12cd36,
0x13ce36, 0x13cf37, 0x13d037, 0x14d138, 0x14d139, 0x14d239, 0x15d33a, 0x15d43a, 0x16d43b, 0x16d53b, 0x17d63c, 0x17d73d, 0x17d83d, 0x18d83e, 0x18d93e, 0x19da3f,
0x19db40, 0x1adc40, 0x1adc41, 0x1bdd41, 0x1bde42, 0x1cdf43, 0x1ce043, 0x1de044, 0x1ee145, 0x1ee245, 0x1fe346, 0x1fe446, 0x20e447, 0x20e548, 0x21e648, 0x22e749,
0x22e74a, 0x23e84a, 0x23e94b, 0x24ea4c, 0x25ea4c, 0x25eb4d, 0x26ec4e, 0x27ed4e, 0x27ee4f, 0x28ee50, 0x29ef50, 0x29f051, 0x2af152, 0x2bf153, 0x2cf253, 0x2cf354,
0x2df455, 0x2ef455, 0x2ff556, 0x2ff657, 0x30f758, 0x31f758, 0x32f859, 0x32f95a, 0x33fa5a, 0x34fa5b, 0x35fb5c, 0x36fc5d, 0x37fd5d, 0x38fd5e, 0x38fe5f, 0x39ff60
},
{ // White monitor
0x000000, 0x010102, 0x020203, 0x020304, 0x030406, 0x040507, 0x050608, 0x060709, 0x07080a, 0x08090c, 0x080a0d, 0x090b0e, 0x0a0c0f, 0x0b0d10, 0x0c0e11, 0x0d0f12,
0x0e1013, 0x0f1115, 0x101216, 0x111317, 0x121418, 0x121519, 0x13161a, 0x14171b, 0x15181c, 0x16191d, 0x171a1e, 0x181b1f, 0x191c20, 0x1a1d21, 0x1b1e22, 0x1c1f23,
0x1d2024, 0x1e2125, 0x1f2226, 0x202327, 0x212428, 0x222529, 0x22262b, 0x23272c, 0x24282d, 0x25292e, 0x262a2f, 0x272b30, 0x282c30, 0x292d31, 0x2a2e32, 0x2b2f33,
0x2c3034, 0x2d3035, 0x2e3136, 0x2f3237, 0x303338, 0x313439, 0x32353a, 0x33363b, 0x34373c, 0x35383d, 0x36393e, 0x373a3f, 0x383b40, 0x393c41, 0x3a3d42, 0x3b3e43,
0x3c3f44, 0x3d4045, 0x3e4146, 0x3f4247, 0x404348, 0x414449, 0x42454a, 0x43464b, 0x44474c, 0x45484d, 0x46494d, 0x474a4e, 0x484b4f, 0x484c50, 0x494d51, 0x4a4e52,
0x4b4f53, 0x4c5054, 0x4d5155, 0x4e5256, 0x4f5357, 0x505458, 0x515559, 0x52565a, 0x53575b, 0x54585b, 0x55595c, 0x565a5d, 0x575b5e, 0x585c5f, 0x595d60, 0x5a5e61,
0x5b5f62, 0x5c6063, 0x5d6164, 0x5e6265, 0x5f6366, 0x606466, 0x616567, 0x626668, 0x636769, 0x64686a, 0x65696b, 0x666a6c, 0x676b6d, 0x686c6e, 0x696d6f, 0x6a6e70,
0x6b6f70, 0x6c7071, 0x6d7172, 0x6f7273, 0x707374, 0x707475, 0x717576, 0x727677, 0x747778, 0x757879, 0x767979, 0x777a7a, 0x787b7b, 0x797c7c, 0x7a7d7d, 0x7b7e7e,
0x7c7f7f, 0x7d8080, 0x7e8181, 0x7f8281, 0x808382, 0x818483, 0x828584, 0x838685, 0x848786, 0x858887, 0x868988, 0x878a89, 0x888b89, 0x898c8a, 0x8a8d8b, 0x8b8e8c,
0x8c8f8d, 0x8d8f8e, 0x8e908f, 0x8f9190, 0x909290, 0x919391, 0x929492, 0x939593, 0x949694, 0x959795, 0x969896, 0x979997, 0x989a98, 0x999b98, 0x9a9c99, 0x9b9d9a,
0x9c9e9b, 0x9d9f9c, 0x9ea09d, 0x9fa19e, 0xa0a29f, 0xa1a39f, 0xa2a4a0, 0xa3a5a1, 0xa4a6a2, 0xa6a7a3, 0xa7a8a4, 0xa8a9a5, 0xa9aaa5, 0xaaaba6, 0xabaca7, 0xacada8,
0xadaea9, 0xaeafaa, 0xafb0ab, 0xb0b1ac, 0xb1b2ac, 0xb2b3ad, 0xb3b4ae, 0xb4b5af, 0xb5b6b0, 0xb6b7b1, 0xb7b8b2, 0xb8b9b2, 0xb9bab3, 0xbabbb4, 0xbbbcb5, 0xbcbdb6,
0xbdbeb7, 0xbebfb8, 0xbfc0b8, 0xc0c1b9, 0xc1c2ba, 0xc2c3bb, 0xc3c4bc, 0xc5c5bd, 0xc6c6be, 0xc7c7be, 0xc8c8bf, 0xc9c9c0, 0xcacac1, 0xcbcbc2, 0xccccc3, 0xcdcdc3,
0xcecec4, 0xcfcfc5, 0xd0d0c6, 0xd1d1c7, 0xd2d2c8, 0xd3d3c9, 0xd4d4c9, 0xd5d5ca, 0xd6d6cb, 0xd7d7cc, 0xd8d8cd, 0xd9d9ce, 0xdadacf, 0xdbdbcf, 0xdcdcd0, 0xdeddd1,
0xdfded2, 0xe0dfd3, 0xe1e0d4, 0xe2e1d4, 0xe3e2d5, 0xe4e3d6, 0xe5e4d7, 0xe6e5d8, 0xe7e6d9, 0xe8e7d9, 0xe9e8da, 0xeae9db, 0xebeadc, 0xecebdd, 0xedecde, 0xeeeddf,
0xefeedf, 0xf0efe0, 0xf1f0e1, 0xf2f1e2, 0xf3f2e3, 0xf4f3e3, 0xf6f3e4, 0xf7f4e5, 0xf8f5e6, 0xf9f6e7, 0xfaf7e8, 0xfbf8e9, 0xfcf9e9, 0xfdfaea, 0xfefbeb, 0xfffcec
}
};
static struct {
int x, y, y1, y2, w, h;
int busy;
@@ -361,94 +419,76 @@ video_update_timing(void)
video_timings_t *timing;
int new_gfxcard;
if (video_speed == -1) {
new_gfxcard = 0;
new_gfxcard = 0;
switch(romset) {
case ROM_IBMPCJR:
case ROM_TANDY:
case ROM_TANDY1000HX:
case ROM_TANDY1000SL2:
timing = &timing_dram;
break;
case ROM_PC1512:
timing = &timing_pc1512;
break;
case ROM_PC1640:
timing = &timing_pc1640;
break;
case ROM_PC200:
timing = &timing_pc200;
break;
case ROM_OLIM24:
timing = &timing_m24;
break;
case ROM_PC2086:
case ROM_PC3086:
timing = &timing_pvga1a;
break;
case ROM_T1000:
case ROM_T1200:
timing = &timing_t1000;
break;
case ROM_MEGAPC:
case ROM_MEGAPCDX:
timing = &timing_wd90c11;
break;
case ROM_IBMPS1_2011:
case ROM_IBMPS2_M30_286:
case ROM_IBMPS2_M50:
case ROM_IBMPS2_M55SX:
case ROM_IBMPS2_M80:
timing = &timing_vga;
break;
case ROM_IBMPS1_2121:
case ROM_IBMPS1_2133:
timing = &timing_ps1_svga;
break;
case ROM_T3100E:
timing = &timing_t3100e;
break;
case ROM_ENDEAVOR:
timing = &timing_endeavor;
break;
default:
new_gfxcard = video_old_to_new(gfxcard);
timing = video_card_gettiming(new_gfxcard);
break;
}
switch(romset) {
case ROM_IBMPCJR:
case ROM_TANDY:
case ROM_TANDY1000HX:
case ROM_TANDY1000SL2:
timing = &timing_dram;
break;
case ROM_PC1512:
timing = &timing_pc1512;
break;
case ROM_PC1640:
timing = &timing_pc1640;
break;
case ROM_PC200:
timing = &timing_pc200;
break;
case ROM_OLIM24:
timing = &timing_m24;
break;
case ROM_PC2086:
case ROM_PC3086:
timing = &timing_pvga1a;
break;
case ROM_T1000:
case ROM_T1200:
timing = &timing_t1000;
break;
case ROM_MEGAPC:
case ROM_MEGAPCDX:
timing = &timing_wd90c11;
break;
case ROM_IBMPS1_2011:
case ROM_IBMPS2_M30_286:
case ROM_IBMPS2_M50:
case ROM_IBMPS2_M55SX:
case ROM_IBMPS2_M80:
timing = &timing_vga;
break;
case ROM_IBMPS1_2121:
case ROM_IBMPS1_2133:
timing = &timing_ps1_svga;
break;
case ROM_T3100E:
timing = &timing_t3100e;
break;
case ROM_ENDEAVOR:
timing = &timing_endeavor;
break;
default:
new_gfxcard = video_old_to_new(gfxcard);
timing = video_card_gettiming(new_gfxcard);
break;
}
if (timing->type == VIDEO_ISA) {
video_timing_read_b = ISA_CYCLES(timing->read_b);
video_timing_read_w = ISA_CYCLES(timing->read_w);
video_timing_read_l = ISA_CYCLES(timing->read_l);
video_timing_write_b = ISA_CYCLES(timing->write_b);
video_timing_write_w = ISA_CYCLES(timing->write_w);
video_timing_write_l = ISA_CYCLES(timing->write_l);
} else {
video_timing_read_b = (int)(bus_timing * timing->read_b);
video_timing_read_w = (int)(bus_timing * timing->read_w);
video_timing_read_l = (int)(bus_timing * timing->read_l);
video_timing_write_b = (int)(bus_timing * timing->write_b);
video_timing_write_w = (int)(bus_timing * timing->write_w);
video_timing_write_l = (int)(bus_timing * timing->write_l);
}
} else {
if (video_timing[video_speed][0] == VIDEO_ISA) {
video_timing_read_b = ISA_CYCLES(video_timing[video_speed][1]);
video_timing_read_w = ISA_CYCLES(video_timing[video_speed][2]);
video_timing_read_l = ISA_CYCLES(video_timing[video_speed][3]);
video_timing_write_b = ISA_CYCLES(video_timing[video_speed][1]);
video_timing_write_w = ISA_CYCLES(video_timing[video_speed][2]);
video_timing_write_l = ISA_CYCLES(video_timing[video_speed][3]);
} else {
video_timing_read_b = (int)(bus_timing * video_timing[video_speed][1]);
video_timing_read_w = (int)(bus_timing * video_timing[video_speed][2]);
video_timing_read_l = (int)(bus_timing * video_timing[video_speed][3]);
video_timing_write_b = (int)(bus_timing * video_timing[video_speed][1]);
video_timing_write_w = (int)(bus_timing * video_timing[video_speed][2]);
video_timing_write_l = (int)(bus_timing * video_timing[video_speed][3]);
}
if (timing->type == VIDEO_ISA) {
video_timing_read_b = ISA_CYCLES(timing->read_b);
video_timing_read_w = ISA_CYCLES(timing->read_w);
video_timing_read_l = ISA_CYCLES(timing->read_l);
video_timing_write_b = ISA_CYCLES(timing->write_b);
video_timing_write_w = ISA_CYCLES(timing->write_w);
video_timing_write_l = ISA_CYCLES(timing->write_l);
} else {
video_timing_read_b = (int)(bus_timing * timing->read_b);
video_timing_read_w = (int)(bus_timing * timing->read_w);
video_timing_read_l = (int)(bus_timing * timing->read_l);
video_timing_write_b = (int)(bus_timing * timing->write_b);
video_timing_write_w = (int)(bus_timing * timing->write_w);
video_timing_write_l = (int)(bus_timing * timing->write_l);
}
if (cpu_16bitbus) {
@@ -790,3 +830,46 @@ loadfont(wchar_t *s, int format)
(void)fclose(f);
}
uint32_t
video_color_transform(uint32_t color)
{
uint8_t *clr8 = (uint8_t *) &color;
/* if (!video_grayscale && !invert_display)
return color; */
if (video_grayscale) {
if (video_graytype) {
if (video_graytype == 1)
color = ((54 * (uint32_t)clr8[2]) + (183 * (uint32_t)clr8[1]) + (18 * (uint32_t)clr8[0])) / 255;
else
color = ((uint32_t)clr8[2] + (uint32_t)clr8[1] + (uint32_t)clr8[0]) / 3;
} else
color = ((76 * (uint32_t)clr8[2]) + (150 * (uint32_t)clr8[1]) + (29 * (uint32_t)clr8[0])) / 255;
switch (video_grayscale) {
case 2: case 3: case 4:
color = (uint32_t) shade[video_grayscale][color];
break;
default:
clr8[3] = 0;
clr8[0] = color;
clr8[1] = clr8[2] = clr8[0];
break;
}
}
if (invert_display)
color ^= 0x00ffffff;
return color;
}
void
video_transform_copy(uint32_t *dst, uint32_t *src, int len)
{
int i;
for (i = 0; i < len; i++) {
*dst = video_color_transform(*src);
dst++;
src++;
}
}

View File

@@ -8,7 +8,7 @@
*
* Definitions for the video controller module.
*
* Version: @(#)video.h 1.0.27 2018/05/20
* Version: @(#)video.h 1.0.28 2018/05/25
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -194,7 +194,6 @@ extern int video_timing_read_b,
extern int video_timing_write_b,
video_timing_write_w,
video_timing_write_l;
extern int video_speed;
extern int video_res_x,
video_res_y,
video_bpp;
@@ -261,6 +260,9 @@ extern int get_actual_size_y(void);
extern void svga_dump_vram(void);
#endif
extern uint32_t video_color_transform(uint32_t color);
extern void video_transform_copy(uint32_t *dst, uint32_t *src, int len);
#ifdef __cplusplus
}
#endif

View File

@@ -8,7 +8,7 @@
*
* Implement the VNC remote renderer with LibVNCServer.
*
* Version: @(#)vnc.c 1.0.11 2018/04/29
* Version: @(#)vnc.c 1.0.12 2018/05/26
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Based on raw code by RichardG, <richardg867@gmail.com>
@@ -169,14 +169,18 @@ vnc_display(rfbClientPtr cl)
static void
vnc_blit(int x, int y, int y1, int y2, int w, int h)
{
uint32_t *p;
uint32_t *p, *q;
int yy;
for (yy=y1; yy<y2; yy++) {
p = (uint32_t *)&(((uint32_t *)rfb->frameBuffer)[yy*VNC_MAX_X]);
if ((y+yy) >= 0 && (y+yy) < VNC_MAX_Y)
memcpy(p, &(((uint32_t *)buffer32->line[y+yy])[x]), w*4);
if ((y+yy) >= 0 && (y+yy) < VNC_MAX_Y) {
if (video_grayscale || invert_display)
video_transform_copy(p, &(((uint32_t *)buffer32->line[y+yy])[x]), w);
else
memcpy(p, &(((uint32_t *)buffer32->line[y+yy])[x]), w*4);
}
}
video_blit_complete();

View File

@@ -8,7 +8,7 @@
*
* Application resource script for Windows.
*
* Version: @(#)86Box.rc 1.0.36 2018/05/01
* Version: @(#)86Box.rc 1.0.37 2018/05/25
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -34,7 +34,7 @@
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#pragma code_page(65001)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
@@ -66,11 +66,9 @@ BEGIN
BEGIN
MENUITEM "&DirectDraw", IDM_VID_DDRAW
MENUITEM "Direct&3D 9", IDM_VID_D3D
MENUITEM "&SDL", IDM_VID_SDL
#ifdef USE_VNC
MENUITEM "&VNC", IDM_VID_VNC
#endif
#ifdef USE_RDP
MENUITEM "&RDP", IDM_VID_RDP
#endif
END
MENUITEM SEPARATOR
@@ -325,7 +323,7 @@ BEGIN
#endif
END
DLG_CFG_VIDEO DIALOG DISCARDABLE 97, 0, 267, 63
DLG_CFG_VIDEO DIALOG DISCARDABLE 97, 0, 267, 45
STYLE DS_CONTROL | WS_CHILD
FONT 9, "Segoe UI"
BEGIN
@@ -333,12 +331,9 @@ BEGIN
COMBOBOX IDC_COMBO_VIDEO,71,7,140,120,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Configure",IDC_CONFIGURE_VID,214,7,46,12
COMBOBOX IDC_COMBO_VIDEO_SPEED,71,25,189,120,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
LTEXT "Video speed:",IDT_1708,7,26,58,10
CONTROL "Voodoo Graphics",IDC_CHECK_VOODOO,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,45,199,10
PUSHBUTTON "Configure",IDC_BUTTON_VOODOO,214,44,46,12
BS_AUTOCHECKBOX | WS_TABSTOP,7,27,199,10
PUSHBUTTON "Configure",IDC_BUTTON_VOODOO,214,26,46,12
END
DLG_CFG_INPUT DIALOG DISCARDABLE 97, 0, 267, 65
@@ -476,12 +471,9 @@ BEGIN
COMBOBOX IDC_COMBO_HD_CHANNEL,170,117,90,12,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
LTEXT "Channel:",IDT_1722,131,119,38,8
COMBOBOX IDC_COMBO_HD_ID,170,117,22,12,CBS_DROPDOWNLIST |
COMBOBOX IDC_COMBO_HD_ID,170,117,90,12,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
LTEXT "ID:",IDT_1723,131,119,38,8
COMBOBOX IDC_COMBO_HD_LUN,239,117,22,12,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
LTEXT "LUN:",IDT_1724,200,119,38,8
COMBOBOX IDC_COMBO_HD_CHANNEL_IDE,170,117,90,12,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
END
@@ -513,12 +505,9 @@ BEGIN
COMBOBOX IDC_COMBO_HD_CHANNEL,134,71,77,12,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
LTEXT "Channel:",IDT_1722,99,73,34,8
COMBOBOX IDC_COMBO_HD_ID,133,71,26,12,CBS_DROPDOWNLIST |
COMBOBOX IDC_COMBO_HD_ID,134,71,77,12,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
LTEXT "ID:",IDT_1723,117,73,15,8
COMBOBOX IDC_COMBO_HD_LUN,185,71,26,12,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
LTEXT "LUN:",IDT_1724,168,73,15,8
LTEXT "ID:",IDT_1723,99,73,34,8
COMBOBOX IDC_COMBO_HD_CHANNEL_IDE,134,71,77,12,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
LTEXT "Progress:",IDT_1752,7,7,204,9
@@ -554,15 +543,12 @@ BEGIN
COMBOBOX IDC_COMBO_CD_BUS,33,85,90,12,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
LTEXT "Bus:",IDT_1740,7,87,24,8
COMBOBOX IDC_COMBO_CD_ID,170,85,22,12,CBS_DROPDOWNLIST |
COMBOBOX IDC_COMBO_CD_ID,170,85,90,12,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
LTEXT "ID:",IDT_1741,131,87,38,8
COMBOBOX IDC_COMBO_CD_LUN,239,85,22,12,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
LTEXT "LUN:",IDT_1742,200,87,38,8
COMBOBOX IDC_COMBO_CD_CHANNEL_IDE,170,85,90,12,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
LTEXT "Channel:",IDT_1743,131,87,38,8
LTEXT "Channel:",IDT_1742,131,87,38,8
COMBOBOX IDC_COMBO_CD_SPEED,33,105,90,12,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
LTEXT "Speed:",IDT_1758,7,107,24,8
@@ -570,20 +556,17 @@ BEGIN
LVS_SHOWSELALWAYS | LVS_SINGLESEL | WS_BORDER |
WS_TABSTOP,7,137,253,60
LTEXT "ZIP drives:",IDT_1759,7,127,50,8
COMBOBOX IDC_COMBO_ZIP_BUS,73,204,90,12,CBS_DROPDOWNLIST |
COMBOBOX IDC_COMBO_ZIP_BUS,23,204,90,12,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
LTEXT "Bus:",IDT_1753,57,206,14,8
COMBOBOX IDC_COMBO_ZIP_ID,190,204,22,12,CBS_DROPDOWNLIST |
LTEXT "Bus:",IDT_1753,7,206,14,8
COMBOBOX IDC_COMBO_ZIP_ID,139,204,61,12,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
LTEXT "ID:",IDT_1754,171,206,18,8
COMBOBOX IDC_COMBO_ZIP_LUN,239,204,22,12,CBS_DROPDOWNLIST |
LTEXT "ID:",IDT_1754,120,206,28,8
COMBOBOX IDC_COMBO_ZIP_CHANNEL_IDE,149,204,61,12,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
LTEXT "LUN:",IDT_1755,220,206,18,8
COMBOBOX IDC_COMBO_ZIP_CHANNEL_IDE,200,204,60,12,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
LTEXT "Channel:",IDT_1756,171,206,28,8
LTEXT "Channel:",IDT_1755,120,206,28,8
CONTROL "ZIP 250",IDC_CHECK250,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,204,44,10
BS_AUTOCHECKBOX | WS_TABSTOP,218,204,44,10
END
@@ -603,42 +586,42 @@ END
// remains consistent on all systems.
#ifdef RELEASE_BUILD
/* Icon by Devcore - https://commons.wikimedia.org/wiki/File:Icon_PC_256x256.png */
100 ICON DISCARDABLE "win/icons/86Box-RB.ico"
10 ICON DISCARDABLE "win/icons/86Box-RB.ico"
#else
/* Icon by Devcore - https://commons.wikimedia.org/wiki/File:Icon_PC2_256x256.png */
100 ICON DISCARDABLE "win/icons/86Box.ico"
10 ICON DISCARDABLE "win/icons/86Box.ico"
#endif
128 ICON DISCARDABLE "win/icons/floppy_525.ico"
129 ICON DISCARDABLE "win/icons/floppy_525_active.ico"
144 ICON DISCARDABLE "win/icons/floppy_35.ico"
145 ICON DISCARDABLE "win/icons/floppy_35_active.ico"
160 ICON DISCARDABLE "win/icons/cdrom.ico"
161 ICON DISCARDABLE "win/icons/cdrom_active.ico"
176 ICON DISCARDABLE "win/icons/zip.ico"
177 ICON DISCARDABLE "win/icons/zip_active.ico"
192 ICON DISCARDABLE "win/icons/hard_disk.ico"
193 ICON DISCARDABLE "win/icons/hard_disk_active.ico"
208 ICON DISCARDABLE "win/icons/network.ico"
209 ICON DISCARDABLE "win/icons/network_active.ico"
256 ICON DISCARDABLE "win/icons/machine.ico"
257 ICON DISCARDABLE "win/icons/display.ico"
258 ICON DISCARDABLE "win/icons/input_devices.ico"
259 ICON DISCARDABLE "win/icons/sound.ico"
261 ICON DISCARDABLE "win/icons/ports.ico"
262 ICON DISCARDABLE "win/icons/other_peripherals.ico"
264 ICON DISCARDABLE "win/icons/floppy_drives.ico"
265 ICON DISCARDABLE "win/icons/other_removable_devices.ico"
384 ICON DISCARDABLE "win/icons/floppy_525_empty.ico"
385 ICON DISCARDABLE "win/icons/floppy_525_empty_active.ico"
400 ICON DISCARDABLE "win/icons/floppy_35_empty.ico"
401 ICON DISCARDABLE "win/icons/floppy_35_empty_active.ico"
416 ICON DISCARDABLE "win/icons/cdrom_empty.ico"
417 ICON DISCARDABLE "win/icons/cdrom_empty_active.ico"
432 ICON DISCARDABLE "win/icons/zip_empty.ico"
433 ICON DISCARDABLE "win/icons/zip_empty_active.ico"
512 ICON DISCARDABLE "win/icons/floppy_disabled.ico"
514 ICON DISCARDABLE "win/icons/cdrom_disabled.ico"
515 ICON DISCARDABLE "win/icons/zip_disabled.ico"
16 ICON DISCARDABLE "win/icons/floppy_525.ico"
17 ICON DISCARDABLE "win/icons/floppy_525_active.ico"
24 ICON DISCARDABLE "win/icons/floppy_35.ico"
25 ICON DISCARDABLE "win/icons/floppy_35_active.ico"
32 ICON DISCARDABLE "win/icons/cdrom.ico"
33 ICON DISCARDABLE "win/icons/cdrom_active.ico"
48 ICON DISCARDABLE "win/icons/zip.ico"
49 ICON DISCARDABLE "win/icons/zip_active.ico"
64 ICON DISCARDABLE "win/icons/hard_disk.ico"
65 ICON DISCARDABLE "win/icons/hard_disk_active.ico"
80 ICON DISCARDABLE "win/icons/network.ico"
81 ICON DISCARDABLE "win/icons/network_active.ico"
144 ICON DISCARDABLE "win/icons/floppy_525_empty.ico"
145 ICON DISCARDABLE "win/icons/floppy_525_empty_active.ico"
152 ICON DISCARDABLE "win/icons/floppy_35_empty.ico"
153 ICON DISCARDABLE "win/icons/floppy_35_empty_active.ico"
160 ICON DISCARDABLE "win/icons/cdrom_empty.ico"
161 ICON DISCARDABLE "win/icons/cdrom_empty_active.ico"
176 ICON DISCARDABLE "win/icons/zip_empty.ico"
177 ICON DISCARDABLE "win/icons/zip_empty_active.ico"
240 ICON DISCARDABLE "win/icons/machine.ico"
241 ICON DISCARDABLE "win/icons/display.ico"
242 ICON DISCARDABLE "win/icons/input_devices.ico"
243 ICON DISCARDABLE "win/icons/sound.ico"
244 ICON DISCARDABLE "win/icons/ports.ico"
245 ICON DISCARDABLE "win/icons/other_peripherals.ico"
246 ICON DISCARDABLE "win/icons/floppy_drives.ico"
247 ICON DISCARDABLE "win/icons/other_removable_devices.ico"
248 ICON DISCARDABLE "win/icons/floppy_disabled.ico"
249 ICON DISCARDABLE "win/icons/cdrom_disabled.ico"
250 ICON DISCARDABLE "win/icons/zip_disabled.ico"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
@@ -720,7 +703,7 @@ BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 260
TOPMARGIN, 7
BOTTOMMARGIN, 56
BOTTOMMARGIN, 38
END
DLG_CFG_INPUT, DIALOG
@@ -801,17 +784,17 @@ BEGIN
IDS_2049 "86Box Error"
IDS_2050 "86Box Fatal Error"
IDS_2051 "This will reset 86Box.\nAre you sure you want to save the settings?"
IDS_2052 "DirectDraw Screenshot Error"
IDS_2053 "Invalid number of sectors (valid values are between 1 and 63)"
IDS_2054 "Invalid number of heads (valid values are between 1 and 16)"
IDS_2055 "Invalid number of cylinders (valid values are between 1 and 266305)"
IDS_2052 "Use CTRL+ALT+PAGE DOWN to return to windowed mode"
IDS_2053 "Speed"
IDS_2054 "ZIP %03i %i (%s): %ls"
IDS_2055 "ZIP images (*.IM?;*.ZDI)\0*.IM?;*.ZDI\0"
IDS_2056 "No usable ROM images found!"
IDS_2057 "(empty)"
IDS_2058 "(host drive %c:)"
IDS_2058 "ZIP images (*.IM?;*.ZDI)\0*.IM?;*.ZDI\0All files (*.*)\0*.*\0"
IDS_2059 "Turbo"
IDS_2060 "On"
IDS_2061 "Off"
IDS_2062 "86Box was unable to find any ROMs.\nAt least one ROM set is required to use 86Box."
IDS_2062 "All images (*.86F;*.DSK;*.FLP;*.IM?;*.*FD?)\0*.86F;*.DSK;*.FLP;*.IM?;*.*FD?\0Basic sector images (*.DSK;*.FLP;*.IM?;*.*FD?)\0*.DSK;*.FLP;*.IM?;*.IMG;*.*FD?\0Surface images (*.86F)\0*.86F\0"
IDS_2063 "Configured ROM set not available.\nDefaulting to an available ROM set."
END
@@ -829,7 +812,7 @@ BEGIN
IDS_2073 "Floppy drives"
IDS_2074 "Other removable devices"
IDS_2075 "CD-ROM images (*.ISO;*.CUE)\0*.ISO;*.CUE\0All files (*.*)\0*.*\0"
IDS_2076 "Host CD/DVD Drive (%c:)"
IDS_2076 "Surface images (*.86F)\0*.86F\0"
IDS_2077 "Click to capture mouse"
IDS_2078 "Press F8+F12 to release mouse"
IDS_2079 "Press F8+F12 or middle button to release mouse"
@@ -837,141 +820,67 @@ END
STRINGTABLE DISCARDABLE
BEGIN
IDS_2080 "Drive"
IDS_2081 "Location"
IDS_2080 "E&xport to 86F..."
IDS_2081 "Unable to initialize FluidSynth, make sure you have the following libraries\nin your 86Box folder:\n\nlibfluidsynth.dll\nlibglib-2.0-0.dll\nlibiconv-2.dll\nlibintl-8.dll\nlibpcre-1.dll"
IDS_2082 "Bus"
IDS_2083 "File"
IDS_2084 "C"
IDS_2085 "H"
IDS_2086 "S"
IDS_2087 "MB"
IDS_2088 "Unable to create bitmap file: %s"
IDS_2089 "Enabled"
IDS_2090 "Mute"
IDS_2091 "Type"
IDS_2092 "Bus"
IDS_2093 "DMA"
IDS_2088 "Check BPB"
IDS_2089 "&Image..."
IDS_2090 "&Reload previous image"
IDS_2091 "E&mpty"
IDS_2092 "&Mute"
IDS_2093 "E&ject"
IDS_2094 "KB"
IDS_2095 "Neither DirectDraw nor Direct3D available !"
IDS_2096 "&New image..."
IDS_2097 "&Existing image..."
IDS_2098 "Existing image (&Write-protected)..."
IDS_2099 "Default"
IDS_2100 "%i Wait state(s)"
IDS_2101 "Type"
IDS_2102 "PCap failed to set up because it may not be initialized"
IDS_2103 "No PCap devices found"
IDS_2104 "Invalid PCap device"
IDS_2105 "Standard 2-button joystick(s)"
IDS_2106 "Standard 4-button joystick"
IDS_2107 "Standard 6-button joystick"
IDS_2108 "Standard 8-button joystick"
IDS_2109 "CH Flightstick Pro"
IDS_2110 "Microsoft SideWinder Pad"
IDS_2111 "Thrustmaster Flight Control System"
IDS_2112 "None"
IDS_2113 "Unable to load Keyboard Accelerators!"
IDS_2114 "Unable to register Raw Input!"
IDS_2115 "%u"
IDS_2116 "%u MB (CHS: %i, %i, %i)"
IDS_2117 "Floppy %i (%s): %ls"
IDS_2118 "All images (*.0??;*.1??;*.??0;*.86F;*.BIN;*.CQ?;*.DDI;*.DSK;*.FLP;*.HDM;*.IM?;*.JSON;*.TD0;*.*FD?;*.XDF)\0*.0??;*.1??;*.??0;*.86F;*.BIN;*.CQ?;*.DDI;*.DSK;*.FLP;*.HDM;*.IM?;*.JSON;*.TD0;*.*FD?;*.XDF\0Advanced sector images (*.IMD;*.JSON;*.TD0)\0*.IMD;*.JSON;*.TD0\0Basic sector images (*.0??;*.1??;*.??0;*.BIN;*.CQ?;*.DDI;*.DSK;*.FLP;*.HDM;*.IM?;*.XDF;*.*FD?)\0*.0??;*.1??;*.??0;*.BIN;*.CQ?;*.DDI;*.DSK;*.FLP;*.HDM;*.IM?;*.XDF;*.*FD?\0Flux images (*.FDI)\0*.FDI\0Surface images (*.86F)\0*.86F\0All files (*.*)\0*.*\0"
END
STRINGTABLE DISCARDABLE
BEGIN
IDS_2096 "Slave"
IDS_2097 "SCSI (ID %s, LUN %s)"
IDS_2098 "Adapter Type"
IDS_2099 "Base Address"
IDS_2100 "IRQ"
IDS_2101 "8-bit DMA"
IDS_2102 "16-bit DMA"
IDS_2103 "BIOS"
IDS_2104 "Network Type"
IDS_2105 "Surround Module"
IDS_2106 "MPU-401 Base Address"
IDS_2107 "Use CTRL+ALT+PAGE DOWN to return to windowed mode"
IDS_2108 "On-board RAM"
IDS_2109 "Memory Size"
IDS_2110 "Display Type"
IDS_2111 "RGB"
END
STRINGTABLE DISCARDABLE
BEGIN
IDS_2112 "Composite"
IDS_2113 "Composite Type"
IDS_2114 "Old"
IDS_2115 "New"
IDS_2116 "RGB Type"
IDS_2117 "Color"
IDS_2118 "Monochrome (Green)"
IDS_2119 "Monochrome (Amber)"
IDS_2120 "Monochrome (Gray)"
IDS_2121 "Color (no brown)"
IDS_2122 "Monochrome (Default)"
IDS_2123 "Snow Emulation"
IDS_2124 "Bilinear Filtering"
IDS_2125 "Dithering"
IDS_2126 "Framebuffer Memory Size"
IDS_2127 "Texture Memory Size"
END
STRINGTABLE DISCARDABLE
BEGIN
IDS_2128 "Screen Filter"
IDS_2129 "Render Threads"
IDS_2130 "Recompiler"
IDS_2131 "Default"
IDS_2132 "%i Wait state(s)"
IDS_2133 "8-bit"
IDS_2134 "Slow 16-bit"
IDS_2135 "Fast 16-bit"
IDS_2136 "Slow VLB/PCI"
IDS_2137 "Mid VLB/PCI"
IDS_2138 "Fast VLB/PCI"
END
STRINGTABLE DISCARDABLE
BEGIN
IDS_2139 "PCap failed to set up because it may not be initialized"
IDS_2140 "No PCap devices found"
IDS_2141 "Invalid PCap device"
IDS_2142 "&Notify disk change"
IDS_2143 "Type"
IDS_2144 "Standard 2-button joystick(s)"
IDS_2145 "Standard 4-button joystick"
IDS_2146 "Standard 6-button joystick"
IDS_2147 "Standard 8-button joystick"
IDS_2148 "CH Flightstick Pro"
IDS_2149 "Microsoft SideWinder Pad"
IDS_2150 "Thrustmaster Flight Control System"
IDS_2151 "Disabled"
IDS_2152 "None"
IDS_2153 "Unable to load Keyboard Accelerators!"
IDS_2154 "Unable to register Raw Input!"
IDS_2155 "IRQ %i"
IDS_2156 "%u"
IDS_2157 "%u MB (CHS: %i, %i, %i)"
IDS_2158 "Floppy %i (%s): %ls"
IDS_2159 "All images (*.0??;*.1??;*.??0;*.86F;*.BIN;*.CQ?;*.DDI;*.DSK;*.FLP;*.HDM;*.IM?;*.JSON;*.TD0;*.*FD?;*.XDF)\0*.0??;*.1??;*.??0;*.86F;*.BIN;*.CQ?;*.DDI;*.DSK;*.FLP;*.HDM;*.IM?;*.JSON;*.TD0;*.*FD?;*.XDF\0Advanced sector images (*.IMD;*.JSON;*.TD0)\0*.IMD;*.JSON;*.TD0\0Basic sector images (*.0??;*.1??;*.??0;*.BIN;*.CQ?;*.DDI;*.DSK;*.FLP;*.HDM;*.IM?;*.XDF;*.*FD?)\0*.0??;*.1??;*.??0;*.BIN;*.CQ?;*.DDI;*.DSK;*.FLP;*.HDM;*.IM?;*.XDF;*.*FD?\0Flux images (*.FDI)\0*.FDI\0Surface images (*.86F)\0*.86F\0All files (*.*)\0*.*\0"
IDS_2160 "Configuration files (*.CFG)\0*.CFG\0All files (*.*)\0*.*\0"
IDS_2161 "&New image..."
IDS_2162 "&Existing image..."
IDS_2163 "Existing image (&Write-protected)..."
IDS_2164 "E&ject"
IDS_2165 "&Mute"
IDS_2166 "E&mpty"
IDS_2167 "&Reload previous image"
IDS_2168 "&Image..."
IDS_2169 "Image (&Write-protected)..."
IDS_2170 "Check BPB"
IDS_2171 "Unable to initialize FluidSynth, make sure you have the following libraries\nin your 86Box folder:\n\nlibfluidsynth.dll\nlibglib-2.0-0.dll\nlibiconv-2.dll\nlibintl-8.dll\nlibpcre-1.dll"
IDS_2172 "E&xport to 86F..."
IDS_2173 "Surface images (*.86F)\0*.86F\0"
IDS_2174 "All images (*.86F;*.DSK;*.FLP;*.IM?;*.*FD?)\0*.86F;*.DSK;*.FLP;*.IM?;*.*FD?\0Basic sector images (*.DSK;*.FLP;*.IM?;*.*FD?)\0*.DSK;*.FLP;*.IM?;*.IMG;*.*FD?\0Surface images (*.86F)\0*.86F\0"
IDS_2175 "ZIP images (*.IM?;*.ZDI)\0*.IM?;*.ZDI\0All files (*.*)\0*.*\0"
IDS_2176 "ZIP images (*.IM?;*.ZDI)\0*.IM?;*.ZDI\0"
IDS_2177 "ZIP %03i %i (%s): %ls"
IDS_2178 "Speed"
IDS_4096 "Hard disk (%s)"
IDS_4097 "%01i:%01i"
IDS_4098 "%i"
IDS_4099 "Disabled"
IDS_4099 "MFM/RLL or ESDI CD-ROM drives never existed"
IDS_4100 "Custom..."
IDS_4101 "Custom (large)..."
IDS_4102 "Add New Hard Disk"
IDS_4103 "Add Existing Hard Disk"
IDS_4104 "Attempting to create a HDI image larger than 4 GB"
IDS_4105 "Attempting to create a spuriously large hard disk image"
IDS_4105 "Attempting to create a hard disk image beyond the 28-bit LBA limit"
IDS_4106 "Hard disk images (*.HD?;*.IM?;*.VHD)\0*.HD?;*.IM?;*.VHD\0All files (*.*)\0*.*\0"
IDS_4107 "Unable to open the file for read"
IDS_4108 "Unable to open the file for write"
IDS_4109 "HDI or HDX image with a sector size that is not 512 are not supported"
IDS_4109 "HDI or HDX images with a sector size that is not 512 are not supported"
IDS_4110 "USB is not yet supported"
IDS_4111 "This image exists and will be overwritten.\nAre you sure you want to use it?"
IDS_4112 "Please enter a valid file name"
IDS_4113 "Remember to partition and format the new drive"
IDS_4114 "MFM/RLL or ESDI CD-ROM drives never existed"
IDS_4352 "MFM/RLL"
IDS_4353 "XTA"
@@ -983,23 +892,17 @@ BEGIN
IDS_4609 "XTA (%01i:%01i)"
IDS_4610 "ESDI (%01i:%01i)"
IDS_4611 "IDE (%01i:%01i)"
IDS_4612 "SCSI (%02i:%02i)"
IDS_4612 "SCSI (ID %02i)"
IDS_5120 "CD-ROM %i (%s): %s"
IDS_5376 "Disabled"
IDS_5377 "<Reserved>"
IDS_5378 "<Reserved>"
IDS_5379 "<Reserved>"
IDS_5380 "ATAPI"
IDS_5381 "SCSI"
IDS_5632 "Disabled"
IDS_5633 "<Reserved>"
IDS_5634 "<Reserved>"
IDS_5635 "<Reserved>"
IDS_5636 "ATAPI (%01i:%01i)"
IDS_5637 "SCSI (%02i:%02i)"
IDS_5637 "SCSI (ID %02i)"
IDS_5888 "160 kB"
IDS_5889 "180 kB"
@@ -1047,7 +950,7 @@ VS_VERSION_INFO VERSIONINFO
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BLOCK "0409fde9"
BEGIN
VALUE "Comments", "\0"
VALUE "CompanyName", "IRC #SoftHistory\0"

View File

@@ -8,7 +8,7 @@
#
# Makefile for Win32 (MinGW32) environment.
#
# Version: @(#)Makefile.mingw 1.0.117 2018/05/21
# Version: @(#)Makefile.mingw 1.0.118 2018/05/26
#
# Authors: Miran Grca, <mgrca8@gmail.com>
# Fred N. van Kempen, <decwiz@yahoo.com>
@@ -291,7 +291,7 @@ ifneq ($(WX), n)
UIOBJ := wx_main.o wx_ui.o wx_stbar.o wx_render.o
else
UIOBJ := win_ui.o win_stbar.o \
win_ddraw.o win_d3d.o \
win_ddraw.o win_d3d.o win_sdl.o \
win_dialog.o win_about.o \
win_settings.o win_devconf.o win_snd_gain.o \
win_new_floppy.o win_jsconf.o
@@ -489,7 +489,8 @@ NETOBJ := network.o \
bootp.o ip_icmp.o misc.o socket.o tcp_timer.o cksum.o \
ip_input.o queue.o tcp_input.o debug.o ip_output.o \
sbuf.o tcp_output.o udp.o if.o mbuf.o slirp.o tcp_subr.o \
net_ne2000.o
net_dp8390.o \
net_3c503.o net_ne2000.o
SNDOBJ := sound.o \
openal.o \

View File

@@ -8,7 +8,7 @@
*
* Windows resource defines.
*
* Version: @(#)resource.h 1.0.24 2018/04/26
* Version: @(#)resource.h 1.0.25 2018/05/25
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -48,7 +48,6 @@
#define IDT_1705 1705 /* MB == IDC_TEXT_MB */
#define IDT_1706 1706 /* Memory: */
#define IDT_1707 1707 /* Video: */
#define IDT_1708 1708 /* Video speed: */
#define IDT_1709 1709 /* Mouse: */
#define IDT_1710 1710 /* Joystick: */
#define IDT_1711 1711 /* Sound card: */
@@ -121,9 +120,8 @@
#define IDC_VIDEO 1030 /* video config */
#define IDC_COMBO_VIDEO 1031
#define IDC_COMBO_VIDEO_SPEED 1032
#define IDC_CHECK_VOODOO 1033
#define IDC_BUTTON_VOODOO 1034
#define IDC_CHECK_VOODOO 1032
#define IDC_BUTTON_VOODOO 1033
#define IDC_INPUT 1050 /* input config */
#define IDC_COMBO_MOUSE 1051
@@ -245,8 +243,8 @@
#define IDM_VID_REMEMBER 40041
#define IDM_VID_DDRAW 40050
#define IDM_VID_D3D 40051
#define IDM_VID_VNC 40052
#define IDM_VID_RDP 40053
#define IDM_VID_SDL 40052
#define IDM_VID_VNC 40053
#define IDM_VID_SCALE_1X 40054
#define IDM_VID_SCALE_2X 40055
#define IDM_VID_SCALE_3X 40056

View File

@@ -8,7 +8,7 @@
*
* Platform main support module for Windows.
*
* Version: @(#)win.c 1.0.48 2018/04/29
* Version: @(#)win.c 1.0.49 2018/05/25
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -41,15 +41,9 @@
#ifdef USE_VNC
# include "../vnc.h"
#endif
#ifdef USE_RDP
# include "../rdp.h"
#endif
#ifdef USE_WX
# include "../wx/wx_ui.h"
#else
# include "win_ddraw.h"
# include "win_d3d.h"
#endif
# include "win_sdl.h"
#include "win.h"
@@ -87,43 +81,25 @@ static struct {
void (*close)(void);
void (*resize)(int x, int y);
int (*pause)(void);
} vid_apis[2][4] = {
} vid_apis[2][RENDERERS_NUM] = {
{
#ifdef USE_WX
{ "WxWidgets", 1, wx_init, wx_close, NULL, wx_pause },
{ "WxWidgets", 1, wx_init, wx_close, NULL, wx_pause },
#else
{ "DDraw", 1, (int(*)(void*))ddraw_init, ddraw_close, NULL, ddraw_pause },
{ "D3D", 1, (int(*)(void*))d3d_init, d3d_close, d3d_resize, d3d_pause },
#endif
#ifdef USE_VNC
{ "VNC", 0, vnc_init, vnc_close, vnc_resize, vnc_pause },
{ "SDL", 1, (int(*)(void*))sdl_init, sdl_close, NULL, sdl_pause },
{ "VNC", 0, vnc_init, vnc_close, vnc_resize, vnc_pause }
#else
{ NULL, 0, NULL, NULL, NULL, NULL },
#endif
#ifdef USE_RDP
{ "RDP", 0, rdp_init, rdp_close, rdp_resize, rdp_pause }
#else
{ NULL, 0, NULL, NULL, NULL, NULL }
{ "SDL", 1, (int(*)(void*))sdl_init, sdl_close, NULL, sdl_pause }
#endif
},
{
#ifdef USE_WX
{ "WxWidgets", 1, wx_init, wx_close, NULL, wx_pause },
{ "WxWidgets", 1, wx_init, wx_close, NULL, wx_pause },
#else
{ "DDraw", 1, (int(*)(void*))ddraw_init_fs, ddraw_close, NULL, ddraw_pause },
{ "D3D", 1, (int(*)(void*))d3d_init_fs, d3d_close, NULL, d3d_pause },
#endif
#ifdef USE_VNC
{ "VNC", 0, vnc_init, vnc_close, vnc_resize, vnc_pause },
{ "SDL", 1, (int(*)(void*))sdl_init_fs, sdl_close, NULL, sdl_pause },
{ "VNC", 0, vnc_init, vnc_close, vnc_resize, vnc_pause }
#else
{ NULL, 0, NULL, NULL, NULL, NULL },
#endif
#ifdef USE_RDP
{ "RDP", 0, rdp_init, rdp_close, rdp_resize, rdp_pause }
#else
{ NULL, 0, NULL, NULL, NULL, NULL }
{ "SDL", 1, (int(*)(void*))sdl_init_fs, sdl_close, sdl_resize, sdl_pause }
#endif
},
};
@@ -180,11 +156,15 @@ LoadCommonStrings(void)
for (i=0; i<STR_NUM_5120; i++)
LoadString(hinstance, 5120+i, lpRCstr5120[i].str, 512);
for (i=0; i<STR_NUM_5376; i++)
LoadString(hinstance, 5376+i, lpRCstr5376[i].str, 512);
for (i=0; i<STR_NUM_5376; i++) {
if ((i == 0) || (i > 3))
LoadString(hinstance, 5376+i, lpRCstr5376[i].str, 512);
}
for (i=0; i<STR_NUM_5632; i++)
LoadString(hinstance, 5632+i, lpRCstr5632[i].str, 512);
for (i=0; i<STR_NUM_5632; i++) {
if ((i == 0) || (i > 3))
LoadString(hinstance, 5632+i, lpRCstr5632[i].str, 512);
}
for (i=0; i<STR_NUM_5888; i++)
LoadString(hinstance, 5888+i, lpRCstr5888[i].str, 512);
@@ -250,7 +230,6 @@ plat_get_string(int i)
}
#ifndef USE_WX
/* Create a console if we don't already have one. */
static void
CreateConsole(int init)
@@ -405,7 +384,6 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow)
return(i);
}
#endif /*USE_WX*/
/*
@@ -607,7 +585,7 @@ plat_vidapi(char *name)
if (!strcasecmp(name, "default") || !strcasecmp(name, "system")) return(0);
for (i=0; i<4; i++) {
for (i = 0; i < RENDERERS_NUM; i++) {
if (vid_apis[0][i].name &&
!strcasecmp(vid_apis[0][i].name, name)) return(i);
}
@@ -635,16 +613,15 @@ plat_vidapi_name(int api)
name = "d3d";
break;
#ifdef USE_VNC
case 2:
name = "sdl";
break;
#ifdef USE_VNC
case 3:
name = "vnc";
break;
#endif
#ifdef USE_RDP
case 3:
name = "rdp";
break;
#endif
}
@@ -663,25 +640,15 @@ plat_setvid(int api)
/* Close the (old) API. */
vid_apis[0][vid_api].close();
//#ifdef USE_WX
// ui_check_menu_item(IDM_View_WX+vid_api, 0);
//#endif
vid_api = api;
#ifndef USE_WX
if (vid_apis[0][vid_api].local)
ShowWindow(hwndRender, SW_SHOW);
else
ShowWindow(hwndRender, SW_HIDE);
#endif
/* Initialize the (new) API. */
#ifdef USE_WX
// ui_check_menu_item(IDM_View_WX+vid_api, 1);
i = vid_apis[0][vid_api].init(NULL);
#else
i = vid_apis[0][vid_api].init((void *)hwndRender);
#endif
endblit();
if (! i) return(0);
@@ -726,7 +693,7 @@ plat_setfullscreen(int on)
if (on && video_fullscreen_first) {
video_fullscreen_first = 0;
ui_msgbox(MBX_INFO, (wchar_t *)IDS_2107);
ui_msgbox(MBX_INFO, (wchar_t *)IDS_2052);
}
/* OK, claim the video. */
@@ -741,10 +708,6 @@ plat_setfullscreen(int on)
hw = (video_fullscreen) ? &hwndMain : &hwndRender;
vid_apis[video_fullscreen][vid_api].init((void *) *hw);
#ifdef USE_WX
wx_set_fullscreen(on);
#endif
win_mouse_init();
/* Release video and make it redraw the screen. */
@@ -765,7 +728,7 @@ take_screenshot(void)
time_t now;
win_log("Screenshot: video API is: %i\n", vid_api);
if ((vid_api < 0) || (vid_api > 1)) return;
if ((vid_api < 0) || (vid_api > 2)) return;
memset(fn, 0, sizeof(fn));
memset(path, 0, sizeof(path));
@@ -784,12 +747,6 @@ take_screenshot(void)
wcscat(path, fn);
switch(vid_api) {
#ifdef USE_WX
case 0:
case 1:
wx_screenshot(path);
break;
#else
case 0: /* ddraw */
ddraw_take_screenshot(path);
break;
@@ -797,10 +754,13 @@ take_screenshot(void)
case 1: /* d3d9 */
d3d_take_screenshot(path);
break;
#endif
case 2: /* sdl */
sdl_take_screenshot(path);
break;
#ifdef USE_VNC
case 2: /* vnc */
case 3: /* vnc */
vnc_take_screenshot(path);
break;
#endif

View File

@@ -8,7 +8,7 @@
*
* Platform support defintions for Win32.
*
* Version: @(#)win.h 1.0.17 2018/04/26
* Version: @(#)win.h 1.0.18 2018/05/26
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -41,6 +41,7 @@
#define SUB_CLASS_NAME L"86BoxSubWnd"
#define SB_CLASS_NAME L"86BoxStatusBar"
#define SB_MENU_NAME L"StatusBarMenu"
#define FS_CLASS_NAME L"86BoxFullScreen"
/* Application-specific window messages. */
#define WM_RESETD3D WM_USER
@@ -50,13 +51,19 @@
#define WM_PAUSE 0x8890
#define WM_SENDHWND 0x8891
#ifdef USE_VNC
#define RENDERERS_NUM 4
#else
#define RENDERERS_NUM 3
#endif
extern HINSTANCE hinstance;
extern HWND hwndMain,
hwndRender;
extern HANDLE ghMutex;
extern LCID lang_id;
extern HICON hIcon[512];
extern HICON hIcon[256];
// extern int status_is_open;
@@ -111,6 +118,7 @@ extern int hard_disk_was_added(void);
/* Platform UI support functions. */
extern int ui_init(int nCmdShow);
extern void plat_set_input(HWND h);
/* Functions in win_about.c: */

View File

@@ -8,7 +8,7 @@
*
* Handle the About dialog.
*
* Version: @(#)win_about.c 1.0.6 2018/03/28
* Version: @(#)win_about.c 1.0.7 2018/06/02
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -45,7 +45,7 @@ AboutDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
case WM_INITDIALOG:
plat_pause(1);
h = GetDlgItem(hdlg, IDC_ABOUT_ICON);
ih = LoadImage(hinstance,(PCTSTR)100,IMAGE_ICON,64,64,0);
ih = LoadImage(hinstance,(PCTSTR)10,IMAGE_ICON,64,64,0);
SendMessage(h, STM_SETIMAGE, (WPARAM)IMAGE_ICON,
(LPARAM)ih);
break;

View File

@@ -8,7 +8,7 @@
*
* Handle the platform-side of CDROM drives.
*
* Version: @(#)win_cdrom.c 1.0.7 2018/03/26
* Version: @(#)win_cdrom.c 1.0.8 2018/06/02
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -29,9 +29,9 @@
#include <wchar.h>
#include "../config.h"
#include "../disk/hdd.h"
#include "../disk/zip.h"
#include "../scsi/scsi.h"
#include "../cdrom/cdrom.h"
#include "../disk/zip.h"
#include "../cdrom/cdrom_image.h"
#include "../cdrom/cdrom_null.h"
#include "../scsi/scsi_disk.h"
@@ -121,10 +121,10 @@ cdrom_reload(uint8_t id)
void
zip_eject(uint8_t id)
{
zip_close(id);
zip_disk_close(zip[id]);
if (zip_drives[id].bus_type) {
/* Signal disk change to the emulated machine. */
zip_insert(id);
zip_insert(zip[id]);
}
ui_sb_update_icon_state(SB_ZIP | id, 1);
@@ -138,7 +138,7 @@ zip_eject(uint8_t id)
void
zip_reload(uint8_t id)
{
zip_disk_reload(id);
zip_disk_reload(zip[id]);
if (wcslen(zip_drives[id].image_path) == 0) {
ui_sb_enable_menu_item(SB_ZIP|id, IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_GRAYED);
ui_sb_update_icon_state(SB_ZIP|id, 1);

View File

@@ -8,7 +8,7 @@
*
* Rendering module for Microsoft Direct3D 9.
*
* Version: @(#)win_d3d.cpp 1.0.10 2018/01/15
* Version: @(#)win_d3d.cpp 1.0.11 2018/05/26
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -183,8 +183,14 @@ d3d_blit_fs(int x, int y, int y1, int y2, int w, int h)
hr = d3dTexture->LockRect(0, &dr, &lock_rect, 0);
if (hr == D3D_OK) {
for (yy = y1; yy < y2; yy++)
if (buffer32) memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4);
for (yy = y1; yy < y2; yy++) {
if (buffer32) {
if (video_grayscale || invert_display)
video_transform_copy((uint32_t *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w);
else
memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4);
}
}
video_blit_complete();
d3dTexture->UnlockRect(0);
@@ -288,9 +294,14 @@ d3d_blit(int x, int y, int y1, int y2, int w, int h)
hr = d3dTexture->LockRect(0, &dr, &r, 0);
if (hr == D3D_OK) {
for (yy = y1; yy < y2; yy++) {
if (buffer32)
if ((y + yy) >= 0 && (y + yy) < buffer32->h)
memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4);
if (buffer32) {
if ((y + yy) >= 0 && (y + yy) < buffer32->h) {
if (video_grayscale || invert_display)
video_transform_copy((uint32_t *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w);
else
memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4);
}
}
}
video_blit_complete();

View File

@@ -11,7 +11,7 @@
* NOTES: This code should be re-merged into a single init() with a
* 'fullscreen' argument, indicating FS mode is requested.
*
* Version: @(#)win_ddraw.cpp 1.0.8 2018/04/29
* Version: @(#)win_ddraw.cpp 1.0.9 2018/05/26
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -104,6 +104,10 @@ bgra_to_rgb(png_bytep *b_rgb, uint8_t *bgra, int width, int height)
{
int i, j;
uint8_t *r, *b;
uint32_t *rgb = (uint32_t *) bgra;
if (video_grayscale || invert_display)
*bgra = video_color_transform(*bgra);
for (i = 0; i < height; i++) {
for (j = 0; j < width; j++) {
@@ -237,7 +241,7 @@ SavePNG(wchar_t *szFilename, HBITMAP hBitmap)
if (pBuf2) free(pBuf2);
if (pBuf) free(pBuf);
if (pBuf) free(pBuf);
if (fp) fclose(fp);
}
@@ -374,8 +378,14 @@ ddraw_blit_fs(int x, int y, int y1, int y2, int w, int h)
return;
}
for (yy = y1; yy < y2; yy++)
if (buffer32) memcpy((void *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch)), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4);
for (yy = y1; yy < y2; yy++) {
if (buffer32) {
if (video_grayscale || invert_display)
video_transform_copy((uint32_t *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch)), &(((uint32_t *)buffer32->line[y + yy])[x]), w);
else
memcpy((void *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch)), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4);
}
}
video_blit_complete();
lpdds_back->Unlock(NULL);
@@ -418,6 +428,7 @@ ddraw_blit(int x, int y, int y1, int y2, int w, int h)
POINT po;
HRESULT hr;
int yy;
uint32_t *p, *q;
if (lpdds_back == NULL) {
video_blit_complete();
@@ -447,10 +458,16 @@ ddraw_blit(int x, int y, int y1, int y2, int w, int h)
}
for (yy = y1; yy < y2; yy++) {
if (buffer32)
if ((y + yy) >= 0 && (y + yy) < buffer32->h)
memcpy((uint32_t *) &(((uint8_t *) ddsd.lpSurface)[yy * ddsd.lPitch]), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4);
if (buffer32) {
if ((y + yy) >= 0 && (y + yy) < buffer32->h) {
if (video_grayscale || invert_display)
video_transform_copy((uint32_t *) &(((uint8_t *) ddsd.lpSurface)[yy * ddsd.lPitch]), &(((uint32_t *)buffer32->line[y + yy])[x]), w);
else
memcpy((uint32_t *) &(((uint8_t *) ddsd.lpSurface)[yy * ddsd.lPitch]), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4);
}
}
}
video_blit_complete();
lpdds_back->Unlock(NULL);

View File

@@ -8,7 +8,7 @@
*
* Handle the New Floppy Image dialog.
*
* Version: @(#)win_new_floppy.c 1.0.7 2018/05/14
* Version: @(#)win_new_floppy.c 1.0.8 2018/05/25
*
* Authors: Miran Grca, <mgrca8@gmail.com>
*
@@ -29,6 +29,7 @@
#include "../plat.h"
#include "../random.h"
#include "../ui.h"
#include "../scsi/scsi.h"
#include "../disk/zip.h"
#include "win.h"
@@ -624,7 +625,7 @@ NewFloppyDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
return TRUE;
case IDC_CFILE:
if (!file_dlg_w(hdlg, plat_get_string(is_zip ? IDS_2176 : IDS_2174), L"", 1)) {
if (!file_dlg_w(hdlg, plat_get_string(is_zip ? IDS_2055 : IDS_2062), L"", 1)) {
if (!wcschr(wopenfilestring, L'.')) {
if (wcslen(wopenfilestring) && (wcslen(wopenfilestring) <= 256)) {
twcs = &wopenfilestring[wcslen(wopenfilestring)];

625
src/win/win_sdl.c Normal file
View File

@@ -0,0 +1,625 @@
/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
*
* This file is part of the 86Box distribution.
*
* Rendering module for libSDL2
*
* NOTE: Given all the problems reported with FULLSCREEN use of SDL,
* we will not use that, but, instead, use a new window which
* coverrs the entire desktop.
*
* Version: @(#)win_sdl.c 1.0.0 2018/05/26
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Michael Drüing, <michael@drueing.de>
*
* Copyright 2018 Fred N. van Kempen.
* Copyright 2018 Michael Drüing.
*
* 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.
*/
#define UNICODE
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <SDL2/SDL.h>
#define PNG_DEBUG 0
#include <png.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include "../86box.h"
#include "../device.h"
#include "../plat.h"
#include "../plat_dynld.h"
#include "../video/video.h"
#include "win.h"
#include "win_sdl.h"
#define PATH_SDL_DLL "sdl2.dll"
static void *sdl_handle = NULL; /* handle to libSDL2 DLL */
static SDL_Window *sdl_win = NULL;
static SDL_Renderer *sdl_render = NULL;
static SDL_Texture *sdl_tex = NULL;
static HWND sdl_parent_hwnd = NULL;
static HWND sdl_hwnd = NULL;
static int sdl_w, sdl_h;
static int sdl_fs;
static int cur_w, cur_h;
static png_structp png_ptr;
static png_infop info_ptr;
/* Pointers to the real functions. */
static void (*sdl_GetVersion)(SDL_version *ver);
static char *const (*sdl_GetError)(void);
static int (*sdl_Init)(Uint32 flags);
static void (*sdl_Quit)(void);
static SDL_Window *(*sdl_CreateWindowFrom)(const void *data);
static void (*sdl_DestroyWindow)(SDL_Window *window);
static SDL_Renderer *(*sdl_CreateRenderer)(SDL_Window *window,
int index, Uint32 flags);
static void (*sdl_DestroyRenderer)(SDL_Renderer *renderer);
static SDL_Texture *(*sdl_CreateTexture)(SDL_Renderer *renderer,
Uint32 format, int access,
int w, int h);
static void (*sdl_DestroyTexture)(SDL_Texture *texture);
static int (*sdl_LockTexture)(SDL_Texture *texture,
const SDL_Rect *rect,
void **pixels, int *pitch);
static void (*sdl_UnlockTexture)(SDL_Texture *texture);
static int (*sdl_RenderCopy)(SDL_Renderer *renderer,
SDL_Texture *texture,
const SDL_Rect *srcrect,
const SDL_Rect *dstrect);
static void (*sdl_RenderPresent)(SDL_Renderer *renderer);
static void (*sdl_GetWindowSize)(SDL_Window* window,
int* w,
int* h);
static int (*sdl_RenderReadPixels)(SDL_Renderer* renderer,
const SDL_Rect* rect,
Uint32 format,
void* pixels,
int pitch);
static SDL_bool (*sdl_SetHint)(const char* name,
const char* value);
static dllimp_t sdl_imports[] = {
{ "SDL_GetVersion", &sdl_GetVersion },
{ "SDL_GetError", &sdl_GetError },
{ "SDL_Init", &sdl_Init },
{ "SDL_Quit", &sdl_Quit },
{ "SDL_CreateWindowFrom", &sdl_CreateWindowFrom },
{ "SDL_DestroyWindow", &sdl_DestroyWindow },
{ "SDL_CreateRenderer", &sdl_CreateRenderer },
{ "SDL_DestroyRenderer", &sdl_DestroyRenderer },
{ "SDL_CreateTexture", &sdl_CreateTexture },
{ "SDL_DestroyTexture", &sdl_DestroyTexture },
{ "SDL_LockTexture", &sdl_LockTexture },
{ "SDL_UnlockTexture", &sdl_UnlockTexture },
{ "SDL_RenderCopy", &sdl_RenderCopy },
{ "SDL_RenderPresent", &sdl_RenderPresent },
{ "SDL_GetWindowSize", &sdl_GetWindowSize },
{ "SDL_RenderReadPixels", &sdl_RenderReadPixels },
{ "SDL_SetHint", &sdl_SetHint },
{ NULL, NULL }
};
#ifdef ENABLE_SDL_LOG
int sdl_do_log = ENABLE_SDL_LOG;
#endif
static void
sdl_log(const char *fmt, ...)
{
#ifdef ENABLE_SDL_LOG
va_list ap;
if (sdl_do_log) {
va_start(ap, fmt);
pclog_ex(fmt, ap);
va_end(ap);
}
#endif
}
static void
sdl_stretch(int *w, int *h, int *x, int *y)
{
double dw, dh, dx, dy, temp, temp2, ratio_w, ratio_h, gsr, hsr;
switch (video_fullscreen_scale) {
case FULLSCR_SCALE_FULL:
*w = sdl_w;
*h = sdl_h;
*x = 0;
*y = 0;
break;
case FULLSCR_SCALE_43:
dw = (double) sdl_w;
dh = (double) sdl_h;
temp = (dh / 3.0) * 4.0;
dx = (dw - temp) / 2.0;
dw = temp;
*w = (int) dw;
*h = (int) dh;
*x = (int) dx;
*y = 0;
break;
case FULLSCR_SCALE_SQ:
dw = (double) sdl_w;
dh = (double) sdl_h;
temp = ((double) *w);
temp2 = ((double) *h);
dx = (dw / 2.0) - ((dh * temp) / (temp2 * 2.0));
dy = 0.0;
if (dx < 0.0) {
dx = 0.0;
dy = (dw / 2.0) - ((dh * temp2) / (temp * 2.0));
}
dw -= (dx * 2.0);
dh -= (dy * 2.0);
*w = (int) dw;
*h = (int) dh;
*x = (int) dx;
*y = (int) dy;
break;
case FULLSCR_SCALE_INT:
dw = (double) sdl_w;
dh = (double) sdl_h;
temp = ((double) *w);
temp2 = ((double) *h);
ratio_w = dw / ((double) *w);
ratio_h = dh / ((double) *h);
if (ratio_h < ratio_w)
ratio_w = ratio_h;
dx = (dw / 2.0) - ((temp * ratio_w) / 2.0);
dy = (dh / 2.0) - ((temp2 * ratio_h) / 2.0);
dw -= (dx * 2.0);
dh -= (dy * 2.0);
*w = (int) dw;
*h = (int) dh;
*x = (int) dx;
*y = (int) dy;
break;
case FULLSCR_SCALE_KEEPRATIO:
dw = (double) sdl_w;
dh = (double) sdl_h;
hsr = dw / dh;
gsr = ((double) *w) / ((double) *h);
if (gsr <= hsr) {
temp = dh * gsr;
dx = (dw - temp) / 2.0;
dw = temp;
*w = (int) dw;
*h = (int) dh;
*x = (int) dx;
*y = 0;
} else {
temp = dw / gsr;
dy = (dh - temp) / 2.0;
dh = temp;
*w = (int) dw;
*h = (int) dh;
*x = 0;
*y = (int) dy;
}
break;
}
}
static void
sdl_blit(int x, int y, int y1, int y2, int w, int h)
{
SDL_Rect r_src;
void *pixeldata;
int pitch;
int yy, ret;
if (y1 == y2) {
video_blit_complete();
return;
}
if (buffer32 == NULL) {
video_blit_complete();
return;
}
/*
* TODO:
* SDL_UpdateTexture() might be better here, as it is
* (reportedly) slightly faster.
*/
sdl_LockTexture(sdl_tex, 0, &pixeldata, &pitch);
for (yy = y1; yy < y2; yy++) {
if ((y + yy) >= 0 && (y + yy) < buffer32->h) {
if (video_grayscale || invert_display)
video_transform_copy((uint32_t *) &(((uint8_t *)pixeldata)[yy * pitch]), &(((uint32_t *)buffer32->line[y + yy])[x]), w);
else
memcpy((uint32_t *) &(((uint8_t *)pixeldata)[yy * pitch]), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4);
}
}
video_blit_complete();
sdl_UnlockTexture(sdl_tex);
if (sdl_fs) {
pclog("sdl_blit(%i, %i, %i, %i, %i, %i) (%i, %i)\n", x, y, y1, y2, w, h, unscaled_size_x, efscrnsz_y);
if (w == unscaled_size_x)
sdl_resize(w, h);
pclog("(%08X, %08X, %08X)\n", sdl_win, sdl_render, sdl_tex);
}
r_src.x = 0;
r_src.y = 0;
r_src.w = w;
r_src.h = h;
ret = sdl_RenderCopy(sdl_render, sdl_tex, &r_src, 0);
if (ret)
sdl_log("SDL: unable to copy texture to renderer (%s)\n", sdl_GetError());
sdl_RenderPresent(sdl_render);
}
void
sdl_close(void)
{
/* Unregister our renderer! */
video_setblit(NULL);
if (sdl_tex != NULL) {
sdl_DestroyTexture(sdl_tex);
sdl_tex = NULL;
}
if (sdl_render != NULL) {
sdl_DestroyRenderer(sdl_render);
sdl_render = NULL;
}
if (sdl_win != NULL) {
sdl_DestroyWindow(sdl_win);
sdl_win = NULL;
}
if (sdl_hwnd != NULL) {
plat_set_input(hwndMain);
ShowWindow(hwndRender, TRUE);
SetFocus(hwndMain);
DestroyWindow(sdl_hwnd);
sdl_hwnd = NULL;
}
if (sdl_parent_hwnd != NULL) {
DestroyWindow(sdl_parent_hwnd);
sdl_parent_hwnd = NULL;
}
/* Quit and unload the DLL if possible. */
if (sdl_handle != NULL) {
sdl_Quit();
dynld_close(sdl_handle);
sdl_handle = NULL;
}
}
static int old_capture = 0;
static int
sdl_init_common(int fs)
{
wchar_t temp[128];
SDL_version ver;
int w, h, x, y;
RECT rect;
sdl_log("SDL: init (fs=%d)\n", fs);
cgapal_rebuild();
/* Try loading the DLL. */
sdl_handle = dynld_module(PATH_SDL_DLL, sdl_imports);
if (sdl_handle == NULL) {
sdl_log("SDL: unable to load '%s', SDL not available.\n", PATH_SDL_DLL);
return(0);
}
/* Get and log the version of the DLL we are using. */
sdl_GetVersion(&ver);
sdl_log("SDL: version %d.%d.%d\n", ver.major, ver.minor, ver.patch);
/* Initialize the SDL system. */
if (sdl_Init(SDL_INIT_VIDEO) < 0) {
sdl_log("SDL: initialization failed (%s)\n", sdl_GetError());
return(0);
}
if (fs) {
/* Get the size of the (current) desktop. */
sdl_w = GetSystemMetrics(SM_CXSCREEN);
sdl_h = GetSystemMetrics(SM_CYSCREEN);
/* Create the desktop-covering window. */
_swprintf(temp, L"%s v%s", EMU_NAME_W, EMU_VERSION_W);
sdl_parent_hwnd = CreateWindow(SUB_CLASS_NAME,
temp,
WS_POPUP,
0, 0, sdl_w, sdl_h,
HWND_DESKTOP,
NULL,
hinstance,
NULL);
SetWindowPos(sdl_parent_hwnd, HWND_TOPMOST,
0, 0, sdl_w, sdl_h, SWP_SHOWWINDOW);
/* Create the actual rendering window. */
_swprintf(temp, L"%s v%s", EMU_NAME_W, EMU_VERSION_W);
sdl_hwnd = CreateWindow(SUB_CLASS_NAME,
temp,
WS_POPUP,
0, 0, sdl_w, sdl_h,
sdl_parent_hwnd,
NULL,
hinstance,
NULL);
sdl_log("SDL: FS %dx%d window at %08lx\n", sdl_w, sdl_h, sdl_hwnd);
/* Redirect RawInput to this new window. */
plat_set_input(sdl_hwnd);
SetFocus(sdl_hwnd);
/* Show the window, make it topmost, and give it focus. */
w = unscaled_size_x;
h = efscrnsz_y;
sdl_stretch(&w, &h, &x, &y);
SetWindowPos(sdl_hwnd, sdl_parent_hwnd,
x, y, w, h, SWP_SHOWWINDOW);
/* Now create the SDL window from that. */
sdl_win = sdl_CreateWindowFrom((void *)sdl_hwnd);
old_capture = mouse_capture;
GetWindowRect(sdl_hwnd, &rect);
ClipCursor(&rect);
mouse_capture = 1;
} else {
/* Create the SDL window from the render window. */
sdl_win = sdl_CreateWindowFrom((void *)hwndRender);
mouse_capture = old_capture;
if (mouse_capture) {
GetWindowRect(hwndRender, &rect);
ClipCursor(&rect);
}
}
if (sdl_win == NULL) {
sdl_log("SDL: unable to CreateWindowFrom (%s)\n", sdl_GetError());
sdl_close();
return(0);
}
/*
* TODO:
* SDL_RENDERER_SOFTWARE, because SDL tries to do funky stuff
* otherwise (it turns off Win7 Aero and it looks like it's
* trying to switch to fullscreen even though the window is
* not a fullscreen window?)
*/
sdl_render = sdl_CreateRenderer(sdl_win, -1, SDL_RENDERER_SOFTWARE);
if (sdl_render == NULL) {
sdl_log("SDL: unable to create renderer (%s)\n", sdl_GetError());
sdl_close();
return(0);
}
/*
* TODO:
* Actually the source is (apparently) XRGB8888, but the alpha
* channel seems to be set to 255 everywhere, so ARGB8888 works
* just as well.
*/
sdl_tex = sdl_CreateTexture(sdl_render, SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING, 2048, 2048);
if (sdl_tex == NULL) {
sdl_log("SDL: unable to create texture (%s)\n", sdl_GetError());
sdl_close();
return(0);
}
/* Make sure we get a clean exit. */
atexit(sdl_close);
/* Register our renderer! */
video_setblit(sdl_blit);
sdl_fs = fs;
return(1);
}
int
sdl_init(HWND h)
{
return sdl_init_common(0);
}
int
sdl_init_fs(HWND h)
{
return sdl_init_common(1);
}
void
sdl_take_screenshot(const wchar_t *fn)
{
int i, res, x, y, width = 0, height = 0;
unsigned char* rgba = NULL;
png_bytep *b_rgb = NULL;
FILE *fp = NULL;
sdl_GetWindowSize(sdl_win, &width, &height);
/* create file */
fp = plat_fopen((wchar_t *) fn, (wchar_t *) L"wb");
if (!fp) {
sdl_log("[sdl_take_screenshot] File %ls could not be opened for writing", fn);
return;
}
/* initialize stuff */
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_ptr) {
sdl_log("[sdl_take_screenshot] png_create_write_struct failed");
fclose(fp);
return;
}
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) {
sdl_log("[sdl_take_screenshot] png_create_info_struct failed");
fclose(fp);
return;
}
png_init_io(png_ptr, fp);
png_set_IHDR(png_ptr, info_ptr, width, height,
8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
if ((rgba = (unsigned char *)malloc(width * height * 4)) == NULL) {
sdl_log("[sdl_take_screenshot] Unable to Allocate RGBA Bitmap Memory");
fclose(fp);
return;
}
res = sdl_RenderReadPixels(sdl_render, NULL, SDL_PIXELFORMAT_ABGR8888, rgba, width * 4);
if (res) {
sdl_log("[sdl_take_screenshot] Error reading render pixels\n");
fclose(fp);
return;
}
if ((b_rgb = (png_bytep *) malloc(sizeof(png_bytep) * height)) == NULL) {
sdl_log("[sdl_take_screenshot] Unable to Allocate RGB Bitmap Memory");
free(rgba);
fclose(fp);
return;
}
for (y = 0; y < height; ++y) {
b_rgb[y] = (png_byte *) malloc(png_get_rowbytes(png_ptr, info_ptr));
for (x = 0; x < width; ++x) {
b_rgb[y][(x) * 3 + 0] = rgba[(y * width + x) * 4 + 0];
b_rgb[y][(x) * 3 + 1] = rgba[(y * width + x) * 4 + 1];
b_rgb[y][(x) * 3 + 2] = rgba[(y * width + x) * 4 + 2];
}
}
png_write_info(png_ptr, info_ptr);
png_write_image(png_ptr, b_rgb);
png_write_end(png_ptr, NULL);
/* cleanup heap allocation */
for (i = 0; i < height; i++)
if (b_rgb[i]) free(b_rgb[i]);
if (b_rgb) free(b_rgb);
if (rgba) free(rgba);
if (fp) fclose(fp);
}
int
sdl_pause(void)
{
return(0);
}
void
sdl_resize(int x, int y)
{
int ww, wh, wx, wy;
if ((x == cur_w) && (y == cur_h))
return;
pclog("sdl_resize(%i, %i)\n", x, y);
ww = x;
wh = y;
sdl_stretch(&ww, &wh, &wx, &wy);
MoveWindow(sdl_hwnd, wx, wy, ww, wh, TRUE);
cur_w = x;
cur_h = y;
}

62
src/win/win_sdl.h Normal file
View File

@@ -0,0 +1,62 @@
/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
*
* This file is part of the 86Box distribution.
*
* Definitions for the libSDL2 rendering module.
*
* Version: @(#)win_sdl.h 1.0.0 2018/05/26
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Michael Drüing, <michael@drueing.de>
*
* Copyright 2018 Fred N. van Kempen.
* Copyright 2018 Michael Drüing.
*
* 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 WIN_SDL_H
# define WIN_SDL_H
extern void sdl_close(void);
extern int sdl_init(HWND h);
extern int sdl_init_fs(HWND h);
extern int sdl_pause(void);
extern void sdl_resize(int x, int y);
extern void sdl_take_screenshot(const wchar_t *fn);
#endif /*WIN_SDL_H*/

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,7 @@
*
* Implement the application's Status Bar.
*
* Version: @(#)win_stbar.c 1.0.17 2018/03/26
* Version: @(#)win_stbar.c 1.0.18 2018/05/25
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -35,10 +35,10 @@
#include "../machine/machine.h"
#include "../disk/hdd.h"
#include "../disk/hdc.h"
#include "../disk/zip.h"
#include "../floppy/fdd.h"
#include "../scsi/scsi.h"
#include "../cdrom/cdrom.h"
#include "../disk/zip.h"
#include "../cdrom/cdrom_image.h"
#include "../cdrom/cdrom_null.h"
#include "../scsi/scsi_disk.h"
@@ -64,7 +64,7 @@ static HMENU menuSBAR;
static WCHAR **sbTips;
static int *iStatusWidths;
static int *sb_part_meanings;
static int *sb_part_icons;
static uint8_t *sb_part_icons;
static int sb_parts = 0;
static int sb_ready = 0;
static uint8_t sb_map[256];
@@ -74,7 +74,7 @@ static uint8_t sb_map[256];
intptr_t
fdd_type_to_icon(int type)
{
int ret = 512;
int ret = 248;
switch(type) {
case 0:
@@ -82,12 +82,12 @@ fdd_type_to_icon(int type)
case 1: case 2: case 3: case 4:
case 5: case 6:
ret = 128;
ret = 16;
break;
case 7: case 8: case 9: case 10:
case 11: case 12: case 13:
ret = 144;
ret = 24;
break;
default:
@@ -118,18 +118,18 @@ static void
StatusBarCreateFloppySubmenu(HMENU m, int id)
{
AppendMenu(m, MF_STRING, IDM_FLOPPY_IMAGE_NEW | id,
plat_get_string(IDS_2161));
plat_get_string(IDS_2096));
AppendMenu(m, MF_SEPARATOR, 0, 0);
AppendMenu(m, MF_STRING, IDM_FLOPPY_IMAGE_EXISTING | id,
plat_get_string(IDS_2162));
plat_get_string(IDS_2097));
AppendMenu(m, MF_STRING, IDM_FLOPPY_IMAGE_EXISTING_WP | id,
plat_get_string(IDS_2163));
plat_get_string(IDS_2098));
AppendMenu(m, MF_SEPARATOR, 0, 0);
AppendMenu(m, MF_STRING, IDM_FLOPPY_EXPORT_TO_86F | id,
plat_get_string(IDS_2172));
plat_get_string(IDS_2080));
AppendMenu(m, MF_SEPARATOR, 0, 0);
AppendMenu(m, MF_STRING, IDM_FLOPPY_EJECT | id,
plat_get_string(IDS_2164));
plat_get_string(IDS_2093));
if (floppyfns[id][0] == 0x0000) {
EnableMenuItem(m, IDM_FLOPPY_EJECT | id, MF_BYCOMMAND | MF_GRAYED);
@@ -142,15 +142,15 @@ static void
StatusBarCreateCdromSubmenu(HMENU m, int id)
{
AppendMenu(m, MF_STRING, IDM_CDROM_MUTE | id,
plat_get_string(IDS_2165));
plat_get_string(IDS_2092));
AppendMenu(m, MF_SEPARATOR, 0, 0);
AppendMenu(m, MF_STRING, IDM_CDROM_EMPTY | id,
plat_get_string(IDS_2166));
plat_get_string(IDS_2091));
AppendMenu(m, MF_STRING, IDM_CDROM_RELOAD | id,
plat_get_string(IDS_2167));
plat_get_string(IDS_2090));
AppendMenu(m, MF_SEPARATOR, 0, 0);
AppendMenu(m, MF_STRING, IDM_CDROM_IMAGE | id,
plat_get_string(IDS_2168));
plat_get_string(IDS_2089));
if (! cdrom_drives[id].sound_on)
CheckMenuItem(m, IDM_CDROM_MUTE | id, MF_CHECKED);
@@ -168,17 +168,17 @@ static void
StatusBarCreateZIPSubmenu(HMENU m, int id)
{
AppendMenu(m, MF_STRING, IDM_ZIP_IMAGE_NEW | id,
plat_get_string(IDS_2161));
plat_get_string(IDS_2096));
AppendMenu(m, MF_SEPARATOR, 0, 0);
AppendMenu(m, MF_STRING, IDM_ZIP_IMAGE_EXISTING | id,
plat_get_string(IDS_2162));
plat_get_string(IDS_2097));
AppendMenu(m, MF_STRING, IDM_ZIP_IMAGE_EXISTING_WP | id,
plat_get_string(IDS_2163));
plat_get_string(IDS_2098));
AppendMenu(m, MF_SEPARATOR, 0, 0);
AppendMenu(m, MF_STRING, IDM_ZIP_EJECT | id,
plat_get_string(IDS_2164));
plat_get_string(IDS_2093));
AppendMenu(m, MF_STRING, IDM_ZIP_RELOAD | id,
plat_get_string(IDS_2167));
plat_get_string(IDS_2090));
if (zip_drives[id].image_path[0] == 0x0000) {
EnableMenuItem(m, IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_GRAYED);
@@ -206,7 +206,7 @@ ui_sb_update_icon(int tag, int active)
found = sb_map[tag];
if (found != 0xff) {
sb_part_icons[found] &= ~1;
sb_part_icons[found] |= active;
sb_part_icons[found] |= (uint8_t) active;
SendMessage(hwndSBAR, SB_SETICON, found,
(LPARAM)hIcon[sb_part_icons[found]]);
@@ -225,8 +225,8 @@ ui_sb_update_icon_state(int tag, int state)
found = sb_map[tag];
if (found != 0xff) {
sb_part_icons[found] &= ~256;
sb_part_icons[found] |= (state ? 256 : 0);
sb_part_icons[found] &= ~128;
sb_part_icons[found] |= (state ? 128 : 0);
SendMessage(hwndSBAR, SB_SETICON, found,
(LPARAM)hIcon[sb_part_icons[found]]);
@@ -245,10 +245,10 @@ StatusBarCreateFloppyTip(int part)
mbstowcs(wtext, fdd_getname(fdd_get_type(drive)),
strlen(fdd_getname(fdd_get_type(drive))) + 1);
if (wcslen(floppyfns[drive]) == 0) {
_swprintf(tempTip, plat_get_string(IDS_2158),
_swprintf(tempTip, plat_get_string(IDS_2117),
drive+1, wtext, plat_get_string(IDS_2057));
} else {
_swprintf(tempTip, plat_get_string(IDS_2158),
_swprintf(tempTip, plat_get_string(IDS_2117),
drive+1, wtext, floppyfns[drive]);
}
@@ -305,10 +305,10 @@ StatusBarCreateZIPTip(int part)
int type = zip_drives[drive].is_250 ? 250 : 100;
if (wcslen(zip_drives[drive].image_path) == 0) {
_swprintf(tempTip, plat_get_string(IDS_2177),
_swprintf(tempTip, plat_get_string(IDS_2054),
type, drive+1, szText, plat_get_string(IDS_2057));
} else {
_swprintf(tempTip, plat_get_string(IDS_2177),
_swprintf(tempTip, plat_get_string(IDS_2054),
type, drive+1, szText, zip_drives[drive].image_path);
}
@@ -561,8 +561,8 @@ ui_sb_update_panes(void)
memset(iStatusWidths, 0, sb_parts * sizeof(int));
sb_part_meanings = (int *)malloc(sb_parts * sizeof(int));
memset(sb_part_meanings, 0, sb_parts * sizeof(int));
sb_part_icons = (int *)malloc(sb_parts * sizeof(int));
memset(sb_part_icons, 0, sb_parts * sizeof(int));
sb_part_icons = (uint8_t *)malloc(sb_parts * sizeof(uint8_t));
memset(sb_part_icons, 0, sb_parts * sizeof(uint8_t));
sb_menu_handles = (HMENU *)malloc(sb_parts * sizeof(HMENU));
memset(sb_menu_handles, 0, sb_parts * sizeof(HMENU));
sbTips = (WCHAR **)malloc(sb_parts * sizeof(WCHAR *));
@@ -670,21 +670,21 @@ ui_sb_update_panes(void)
for (i=0; i<sb_parts; i++) {
switch (sb_part_meanings[i] & 0xf0) {
case SB_FLOPPY: /* Floppy */
sb_part_icons[i] = (wcslen(floppyfns[sb_part_meanings[i] & 0xf]) == 0) ? 256 : 0;
sb_part_icons[i] = (wcslen(floppyfns[sb_part_meanings[i] & 0xf]) == 0) ? 128 : 0;
sb_part_icons[i] |= fdd_type_to_icon(fdd_get_type(sb_part_meanings[i] & 0xf));
sb_menu_handles[i] = StatusBarCreatePopupMenu(i);
StatusBarCreateFloppySubmenu(sb_menu_handles[i], sb_part_meanings[i] & 0xf);
EnableMenuItem(sb_menu_handles[i], IDM_FLOPPY_EJECT | (sb_part_meanings[i] & 0xf), MF_BYCOMMAND | ((sb_part_icons[i] & 256) ? MF_GRAYED : MF_ENABLED));
EnableMenuItem(sb_menu_handles[i], IDM_FLOPPY_EJECT | (sb_part_meanings[i] & 0xf), MF_BYCOMMAND | ((sb_part_icons[i] & 128) ? MF_GRAYED : MF_ENABLED));
StatusBarCreateFloppyTip(i);
break;
case SB_CDROM: /* CD-ROM */
id = sb_part_meanings[i] & 0xf;
if (cdrom_drives[id].host_drive == 200)
sb_part_icons[i] = (wcslen(cdrom_image[id].image_path) == 0) ? 256 : 0;
sb_part_icons[i] = (wcslen(cdrom_image[id].image_path) == 0) ? 128 : 0;
else
sb_part_icons[i] = 256;
sb_part_icons[i] |= 160;
sb_part_icons[i] = 128;
sb_part_icons[i] |= 32;
sb_menu_handles[i] = StatusBarCreatePopupMenu(i);
StatusBarCreateCdromSubmenu(sb_menu_handles[i], sb_part_meanings[i] & 0xf);
EnableMenuItem(sb_menu_handles[i], IDM_CDROM_RELOAD | (sb_part_meanings[i] & 0xf), MF_BYCOMMAND | MF_GRAYED);
@@ -692,36 +692,36 @@ ui_sb_update_panes(void)
break;
case SB_ZIP: /* Iomega ZIP */
sb_part_icons[i] = (wcslen(zip_drives[sb_part_meanings[i] & 0xf].image_path) == 0) ? 256 : 0;
sb_part_icons[i] |= 176;
sb_part_icons[i] = (wcslen(zip_drives[sb_part_meanings[i] & 0xf].image_path) == 0) ? 128 : 0;
sb_part_icons[i] |= 48;
sb_menu_handles[i] = StatusBarCreatePopupMenu(i);
StatusBarCreateZIPSubmenu(sb_menu_handles[i], sb_part_meanings[i] & 0xf);
EnableMenuItem(sb_menu_handles[i], IDM_ZIP_EJECT | (sb_part_meanings[i] & 0xf), MF_BYCOMMAND | ((sb_part_icons[i] & 256) ? MF_GRAYED : MF_ENABLED));
EnableMenuItem(sb_menu_handles[i], IDM_ZIP_EJECT | (sb_part_meanings[i] & 0xf), MF_BYCOMMAND | ((sb_part_icons[i] & 128) ? MF_GRAYED : MF_ENABLED));
StatusBarCreateZIPTip(i);
break;
case SB_HDD: /* Hard disk */
sb_part_icons[i] = 192;
sb_part_icons[i] = 64;
StatusBarCreateDiskTip(i);
break;
case SB_NETWORK: /* Network */
sb_part_icons[i] = 208;
sb_part_icons[i] = 80;
StatusBarCreateNetworkTip(i);
break;
case SB_SOUND: /* Sound */
sb_part_icons[i] = 259;
sb_part_icons[i] = 243;
StatusBarCreateSoundTip(i);
break;
case SB_TEXT: /* Status text */
SendMessage(hwndSBAR, SB_SETTEXT, i | SBT_NOBORDERS, (LPARAM)L"");
sb_part_icons[i] = -1;
sb_part_icons[i] = 255;
break;
}
if (sb_part_icons[i] != -1) {
if (sb_part_icons[i] != 255) {
SendMessage(hwndSBAR, SB_SETTEXT, i | SBT_NOBORDERS, (LPARAM)L"");
SendMessage(hwndSBAR, SB_SETICON, i, (LPARAM)hIcon[sb_part_icons[i]]);
SendMessage(hwndSBAR, SB_SETTIPTEXT, i, (LPARAM)sbTips[i]);
@@ -764,10 +764,10 @@ ui_sb_mount_floppy_img(uint8_t id, int part, uint8_t wp, wchar_t *file_name)
void
ui_sb_mount_zip_img(uint8_t id, int part, uint8_t wp, wchar_t *file_name)
{
zip_close(id);
zip_disk_close(zip[id]);
zip_drives[id].ui_writeprot = wp;
zip_load(id, file_name);
zip_insert(id);
zip_load(zip[id], file_name);
zip_insert(zip[id]);
ui_sb_update_icon_state(SB_ZIP | id, wcslen(zip_drives[id].image_path) ? 0 : 1);
EnableMenuItem(sb_menu_handles[part], IDM_ZIP_EJECT | id, MF_BYCOMMAND | (wcslen(zip_drives[id].image_path) ? MF_ENABLED : MF_GRAYED));
EnableMenuItem(sb_menu_handles[part], IDM_ZIP_RELOAD | id, MF_BYCOMMAND | (wcslen(zip_drives[id].image_path) ? MF_GRAYED : MF_ENABLED));
@@ -812,7 +812,7 @@ StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
if ((part == 0xff) || (sb_menu_handles == NULL))
break;
ret = file_dlg_w_st(hwnd, IDS_2159, floppyfns[id], 0);
ret = file_dlg_w_st(hwnd, IDS_2118, floppyfns[id], 0);
if (! ret)
ui_sb_mount_floppy_img(id, part, (item_id == IDM_FLOPPY_IMAGE_EXISTING_WP) ? 1 : 0, wopenfilestring);
break;
@@ -837,7 +837,7 @@ StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
if ((part == 0xff) || (sb_menu_handles == NULL))
break;
ret = file_dlg_w_st(hwnd, IDS_2173, floppyfns[id], 1);
ret = file_dlg_w_st(hwnd, IDS_2076, floppyfns[id], 1);
if (! ret) {
plat_pause(1);
ret = d86f_export(id, wopenfilestring);
@@ -916,7 +916,7 @@ StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
if ((part == 0xff) || (sb_menu_handles == NULL))
break;
ret = file_dlg_w_st(hwnd, IDS_2175, zip_drives[id].image_path, 0);
ret = file_dlg_w_st(hwnd, IDS_2058, zip_drives[id].image_path, 0);
if (! ret)
ui_sb_mount_zip_img(id, part, (item_id == IDM_ZIP_IMAGE_EXISTING_WP) ? 1 : 0, wopenfilestring);
break;
@@ -971,31 +971,31 @@ StatusBarCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst)
{
RECT rectDialog;
int dw, dh;
uintptr_t i;
uint8_t i;
/* Load our icons into the cache for faster access. */
for (i = 128; i < 130; i++)
hIcon[i] = LoadIconEx((PCTSTR) i);
for (i = 16; i < 18; i++)
hIcon[i] = LoadIconEx((PCTSTR) (uintptr_t) i);
for (i = 24; i < 26; i++)
hIcon[i] = LoadIconEx((PCTSTR) (uintptr_t) i);
for (i = 32; i < 34; i++)
hIcon[i] = LoadIconEx((PCTSTR) (uintptr_t) i);
for (i = 48; i < 50; i++)
hIcon[i] = LoadIconEx((PCTSTR) (uintptr_t) i);
for (i = 64; i < 66; i++)
hIcon[i] = LoadIconEx((PCTSTR) (uintptr_t) i);
for (i = 80; i < 82; i++)
hIcon[i] = LoadIconEx((PCTSTR) (uintptr_t) i);
for (i = 144; i < 146; i++)
hIcon[i] = LoadIconEx((PCTSTR) i);
hIcon[i] = LoadIconEx((PCTSTR) (uintptr_t) i);
for (i = 152; i < 154; i++)
hIcon[i] = LoadIconEx((PCTSTR) (uintptr_t) i);
for (i = 160; i < 162; i++)
hIcon[i] = LoadIconEx((PCTSTR) i);
hIcon[i] = LoadIconEx((PCTSTR) (uintptr_t) i);
for (i = 176; i < 178; i++)
hIcon[i] = LoadIconEx((PCTSTR) i);
for (i = 192; i < 194; i++)
hIcon[i] = LoadIconEx((PCTSTR) i);
for (i = 208; i < 210; i++)
hIcon[i] = LoadIconEx((PCTSTR) i);
for (i = 259; i < 260; i++)
hIcon[i] = LoadIconEx((PCTSTR) i);
for (i = 384; i < 386; i++)
hIcon[i] = LoadIconEx((PCTSTR) i);
for (i = 400; i < 402; i++)
hIcon[i] = LoadIconEx((PCTSTR) i);
for (i = 416; i < 418; i++)
hIcon[i] = LoadIconEx((PCTSTR) i);
for (i = 432; i < 434; i++)
hIcon[i] = LoadIconEx((PCTSTR) i);
hIcon[i] = LoadIconEx((PCTSTR) (uintptr_t) i);
for (i = 243; i < 244; i++)
hIcon[i] = LoadIconEx((PCTSTR) (uintptr_t) i);
GetWindowRect(hwndParent, &rectDialog);
dw = rectDialog.right - rectDialog.left;
@@ -1037,8 +1037,8 @@ StatusBarCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst)
memset(iStatusWidths, 0, sb_parts * sizeof(int));
sb_part_meanings = (int *)malloc(sb_parts * sizeof(int));
memset(sb_part_meanings, 0, sb_parts * sizeof(int));
sb_part_icons = (int *)malloc(sb_parts * sizeof(int));
memset(sb_part_icons, 0, sb_parts * sizeof(int));
sb_part_icons = (uint8_t *)malloc(sb_parts * sizeof(uint8_t));
memset(sb_part_icons, 0, sb_parts * sizeof(uint8_t));
sb_menu_handles = (HMENU *)malloc(sb_parts * sizeof(HMENU));
memset(sb_menu_handles, 0, sb_parts * sizeof(HMENU));
sbTips = (WCHAR **)malloc(sb_parts * sizeof(WCHAR *));
@@ -1046,7 +1046,7 @@ StatusBarCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst)
sb_parts = 0;
iStatusWidths[sb_parts] = -1;
sb_part_meanings[sb_parts] = SB_TEXT;
sb_part_icons[sb_parts] = -1;
sb_part_icons[sb_parts] = 255;
sb_parts++;
SendMessage(hwndSBAR, SB_SETPARTS, (WPARAM)sb_parts, (LPARAM)iStatusWidths);
SendMessage(hwndSBAR, SB_SETTEXT, 0 | SBT_NOBORDERS,

View File

@@ -8,7 +8,7 @@
*
* user Interface module for WinAPI on Windows.
*
* Version: @(#)win_ui.c 1.0.27 2018/05/01
* Version: @(#)win_ui.c 1.0.28 2018/05/25
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -48,7 +48,7 @@
HWND hwndMain, /* application main window */
hwndRender; /* machine render window */
HMENU menuMain; /* application main menu */
HICON hIcon[512]; /* icon data loaded from resources */
HICON hIcon[256]; /* icon data loaded from resources */
RECT oldclip; /* mouse rect */
int infocus = 1;
int rctrl_is_lalt = 0;
@@ -59,7 +59,6 @@ WCHAR wopenfilestring[260];
/* Local data. */
static wchar_t wTitle[512];
static RAWINPUTDEVICE device;
static HHOOK hKeyboardHook;
static int hook_enabled = 0;
static int save_window_pos = 0;
@@ -149,9 +148,7 @@ ResetAllMenus(void)
CheckMenuItem(menuMain, IDM_VID_RESIZE, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_DDRAW+0, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_DDRAW+1, MF_UNCHECKED);
#ifdef USE_VNC
CheckMenuItem(menuMain, IDM_VID_DDRAW+2, MF_UNCHECKED);
#endif
#ifdef USE_VNC
CheckMenuItem(menuMain, IDM_VID_DDRAW+3, MF_UNCHECKED);
#endif
@@ -382,11 +379,9 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case IDM_VID_DDRAW:
case IDM_VID_D3D:
case IDM_VID_SDL:
#ifdef USE_VNC
case IDM_VID_VNC:
#endif
#ifdef USE_RDP
case IDM_VID_RDP:
#endif
CheckMenuItem(hmenu, IDM_VID_DDRAW+vid_api, MF_UNCHECKED);
plat_setvid(LOWORD(wParam) - IDM_VID_DDRAW);
@@ -529,63 +524,9 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
svga_dump_vram();
break;
#endif
#if 0
case IDM_CONFIG_LOAD:
plat_pause(1);
if (!file_dlg_st(hwnd, IDS_2160, "", 0) &&
(ui_msgbox(MBX_QUESTION, (wchar_t *)IDS_2051) == IDYES)) {
pc_reload(wopenfilestring);
ResetAllMenus();
}
plat_pause(0);
break;
case IDM_CONFIG_SAVE:
plat_pause(1);
if (! file_dlg_st(hwnd, IDS_2160, "", 1)) {
config_write(wopenfilestring);
}
plat_pause(0);
break;
#endif
}
return(0);
case WM_INPUT:
keyboard_handle(lParam, infocus);
break;
case WM_SETFOCUS:
infocus = 1;
if (! hook_enabled) {
hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL,
LowLevelKeyboardProc,
GetModuleHandle(NULL),
0);
hook_enabled = 1;
}
break;
case WM_KILLFOCUS:
infocus = 0;
plat_mouse_capture(0);
if (hook_enabled) {
UnhookWindowsHookEx(hKeyboardHook);
hook_enabled = 0;
}
break;
case WM_LBUTTONUP:
if (! video_fullscreen)
plat_mouse_capture(1);
break;
case WM_MBUTTONUP:
if (mouse_get_buttons() < 3)
plat_mouse_capture(0);
break;
case WM_ENTERMENULOOP:
break;
@@ -703,6 +644,26 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
default:
return(DefWindowProc(hwnd, message, wParam, lParam));
case WM_SETFOCUS:
infocus = 1;
if (! hook_enabled) {
hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL,
LowLevelKeyboardProc,
GetModuleHandle(NULL),
0);
hook_enabled = 1;
}
break;
case WM_KILLFOCUS:
infocus = 0;
plat_mouse_capture(0);
if (hook_enabled) {
UnhookWindowsHookEx(hKeyboardHook);
hook_enabled = 0;
}
break;
}
return(0);
@@ -721,6 +682,7 @@ ui_init(int nCmdShow)
{
WCHAR title[200];
WNDCLASSEX wincl; /* buffer for main window's class */
RAWINPUTDEVICE ridev; /* RawInput device */
MSG messages; /* received-messages buffer */
HWND hwnd; /* handle for our window */
HACCEL haccel; /* handle to accelerator table */
@@ -746,8 +708,8 @@ ui_init(int nCmdShow)
wincl.lpfnWndProc = MainWindowProcedure;
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof(WNDCLASSEX);
wincl.hIcon = LoadIcon(hinstance, (LPCTSTR)100);
wincl.hIconSm = LoadIcon(hinstance, (LPCTSTR)100);
wincl.hIcon = LoadIcon(hinstance, (LPCTSTR)10);
wincl.hIconSm = LoadIcon(hinstance, (LPCTSTR)10);
wincl.hCursor = NULL;
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
@@ -800,30 +762,34 @@ ui_init(int nCmdShow)
/* Make the window visible on the screen. */
ShowWindow(hwnd, nCmdShow);
/* Load the accelerator table */
haccel = LoadAccelerators(hinstance, ACCEL_NAME);
if (haccel == NULL) {
/* Initialize the RawInput (keyboard) module. */
memset(&ridev, 0x00, sizeof(ridev));
ridev.usUsagePage = 0x01;
ridev.usUsage = 0x06;
ridev.dwFlags = RIDEV_NOHOTKEYS;
ridev.hwndTarget = NULL; /* current focus window */
if (! RegisterRawInputDevices(&ridev, 1, sizeof(ridev))) {
MessageBox(hwndMain,
plat_get_string(IDS_2153),
plat_get_string(IDS_2050),
MB_OK | MB_ICONERROR);
return(3);
}
/* Initialize the input (keyboard, mouse, game) module. */
device.usUsagePage = 0x01;
device.usUsage = 0x06;
device.dwFlags = RIDEV_NOHOTKEYS;
device.hwndTarget = hwnd;
if (! RegisterRawInputDevices(&device, 1, sizeof(device))) {
MessageBox(hwndMain,
plat_get_string(IDS_2154),
plat_get_string(IDS_2114),
plat_get_string(IDS_2050),
MB_OK | MB_ICONERROR);
return(4);
}
keyboard_getkeymap();
/* Set up the main window for RawInput. */
plat_set_input(hwndMain);
/* Load the accelerator table */
haccel = LoadAccelerators(hinstance, ACCEL_NAME);
if (haccel == NULL) {
MessageBox(hwndMain,
plat_get_string(IDS_2113),
plat_get_string(IDS_2050),
MB_OK | MB_ICONERROR);
return(3);
}
/* Initialize the mouse module. */
win_mouse_init();
@@ -1042,3 +1008,74 @@ plat_mouse_capture(int on)
mouse_capture = 0;
}
}
/* Catch WM_INPUT messages for 'current focus' window. */
static LONG_PTR input_orig_proc;
static HWND input_orig_hwnd = NULL;
#ifdef __amd64__
static LRESULT CALLBACK
#else
static BOOL CALLBACK
#endif
input_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) {
case WM_INPUT:
keyboard_handle(lParam, infocus);
break;
case WM_SETFOCUS:
infocus = 1;
if (! hook_enabled) {
hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL,
LowLevelKeyboardProc,
GetModuleHandle(NULL),
0);
hook_enabled = 1;
}
break;
case WM_KILLFOCUS:
infocus = 0;
plat_mouse_capture(0);
if (hook_enabled) {
UnhookWindowsHookEx(hKeyboardHook);
hook_enabled = 0;
}
break;
case WM_LBUTTONUP:
if (! video_fullscreen)
plat_mouse_capture(1);
break;
case WM_MBUTTONUP:
if (mouse_get_buttons() < 3)
plat_mouse_capture(0);
break;
default:
return(CallWindowProc((WNDPROC)input_orig_proc,
hwnd, message, wParam, lParam));
}
return(0);
}
/* Set up a handler for the 'currently active' window. */
void
plat_set_input(HWND h)
{
/* If needed, rest the old one first. */
if (input_orig_hwnd != NULL) {
SetWindowLongPtr(input_orig_hwnd, GWL_WNDPROC,
(LONG_PTR)input_orig_proc);
}
/* Redirect the window procedure so we can catch WM_INPUT. */
input_orig_proc = GetWindowLongPtr(h, GWLP_WNDPROC);
input_orig_hwnd = h;
SetWindowLongPtr(h, GWL_WNDPROC, (LONG_PTR)&input_proc);
}