Even more cleanups. Also renamed hdd/ to disk/ as that makes more sense. Machines with an Internal HDC (usually IDE) can now also select an alternative one instead.

This commit is contained in:
waltje
2017-10-02 02:15:35 -04:00
parent f6620a45d0
commit 63c532d940
39 changed files with 942 additions and 976 deletions

View File

@@ -96,7 +96,7 @@ endif
# Nothing should need changing from here on.. #
#########################################################################
VPATH := $(EXPATH) . cpu \
cdrom floppy game hdd machine \
cdrom disk floppy game machine \
sound \
sound/munt sound/munt/c_interface sound/munt/sha1 \
sound/munt/srchelper \

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.8 2017/09/30
* Version: @(#)cdrom.c 1.0.8 2017/10/01
*
* Author: Miran Grca, <mgrca8@gmail.com>
* Copyright 2016,2017 Miran Grca.
@@ -27,8 +27,8 @@
#include "../piix.h"
#include "../scsi/scsi.h"
#include "../nvr.h"
#include "../hdd/hdc.h"
#include "../hdd/hdc_ide.h"
#include "../disk/hdc.h"
#include "../disk/hdc_ide.h"
#include "../win/plat_iodev.h"
#include "cdrom.h"

View File

@@ -34,14 +34,14 @@
#include "device.h"
#include "lpt.h"
#include "nvr.h"
#include "game/gameport.h"
#include "cdrom/cdrom.h"
#include "disk/hdd.h"
#include "disk/hdc.h"
#include "disk/hdc_ide.h"
#include "floppy/floppy.h"
#include "floppy/fdc.h"
#include "floppy/fdd.h"
#include "hdd/hdd.h"
#include "hdd/hdc.h"
#include "hdd/hdc_ide.h"
#include "game/gameport.h"
#include "machine/machine.h"
#include "mouse.h"
#include "network/network.h"

View File

@@ -9,7 +9,7 @@
* Implementation of the generic device interface to handle
* all devices attached to the emulator.
*
* Version: @(#)device.c 1.0.4 2017/09/24
* Version: @(#)device.c 1.0.4 2017/10/01
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -49,7 +49,6 @@ void device_add(device_t *d)
while (devices[c] != NULL && c < 256)
c++;
if (c >= DEVICE_MAX)
fatal("device_add : too many devices\n");

View File

@@ -8,7 +8,7 @@
*
* Common code to handle all sorts of disk controllers.
*
* Version: @(#)hdc.c 1.0.2 2017/09/30
* Version: @(#)hdc.c 1.0.2 2017/10/01
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -26,7 +26,7 @@
#include "hdc.h"
char hdc_name[16];
char hdc_name[16]; /* configured HDC name */
int hdc_current;
@@ -121,6 +121,36 @@ static struct {
};
/* Initialize the 'hdc_current' value based on configured HDC name. */
void
hdc_init(char *name)
{
int c;
pclog("HDC: initializing..\n");
for (c=0; controllers[c].device; c++) {
if (! strcmp(name, controllers[c].internal_name)) {
hdc_current = c;
break;
}
}
}
/* Reset the HDC, whichever one that is. */
void
hdc_reset(void)
{
pclog("HDC: reset(current=%d, internal=%d)\n",
hdc_current, (machines[machine].flags & MACHINE_HAS_HDC)?1:0);
/* If we have a valid controller, add its device. */
if (hdc_current > 1)
device_add(controllers[hdc_current].device);
}
char *
hdc_get_name(int hdc)
{
@@ -154,34 +184,3 @@ hdc_current_is_mfm(void)
{
return(controllers[hdc_current].is_mfm);
}
void
hdc_init(void)
{
pclog("HDC: initializing..\n");
hdc_current = 0;
}
void
hdc_reset(char *name)
{
int c;
pclog("HDC: reset(name='%s', internal=%d)\n", name,
(machines[machine].flags & MACHINE_HAS_HDC)?1:0);
for (c=0; controllers[c].device; c++) {
if (! strcmp(name, controllers[c].internal_name)) {
hdc_current = c;
if (strcmp(name, "none") && strcmp(name, "internal")) {
device_add(controllers[c].device);
return;
}
}
}
}

View File

@@ -8,7 +8,7 @@
*
* Definitions for the common disk controller handler.
*
* Version: @(#)hdc.h 1.0.3 2017/09/30
* Version: @(#)hdc.h 1.0.3 2017/10/01
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -44,8 +44,8 @@ extern device_t xtide_ps2_device; /* xtide_ps2 */
extern device_t xtide_at_ps2_device; /* xtide_at_ps2 */
extern void hdc_init(void);
extern void hdc_reset(char *name);
extern void hdc_init(char *name);
extern void hdc_reset(void);
extern char *hdc_get_name(int hdc);
extern char *hdc_get_internal_name(int hdc);

View File

@@ -632,7 +632,7 @@ void ide_reset(void)
idecallback[2]=idecallback[3]=0;
idecallback[4]=0;
pclog("IDE: start loading disks...\n");
pclog("IDE: loading disks...\n");
c = 0;
for (d = 0; d < HDD_NUM; d++)
{
@@ -649,7 +649,7 @@ void ide_reset(void)
if (++c >= (IDE_NUM+XTIDE_NUM)) break;
}
}
pclog("IDE: done loading, %d disks.\n", c);
pclog("IDE: done, loaded %d disks.\n", c);
for (d = 0; d < IDE_NUM; d++)
{
@@ -2309,8 +2309,6 @@ void ide_init_first(void)
{
int d;
pclog("IDE: initializing...\n");
memset(ide_drives, 0x00, sizeof(ide_drives));
for (d = 0; d < (IDE_NUM+XTIDE_NUM); d++)
{

View File

@@ -21,7 +21,7 @@
* already on their way out, the newer IDE standard based on the
* PC/AT controller and 16b design became the IDE we now know.
*
* Version: @(#)xtide.c 1.0.5 2017/09/29
* Version: @(#)xtide.c 1.0.6 2017/10/10
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -44,10 +44,10 @@
#include "hdc_ide.h"
#define XT_ROM_PATH L"roms/hdd/xtide/ide_xt.bin"
#define AT_ROM_PATH L"roms/hdd/xtide/ide_at.bin"
#define PS2_ROM_PATH L"roms/hdd/xtide/SIDE1V12.BIN"
#define PS2AT_ROM_PATH L"roms/hdd/xtide/ide_at_1_1_5.bin"
#define ROM_PATH_XT L"roms/hdd/xtide/ide_xt.bin"
#define ROM_PATH_AT L"roms/hdd/xtide/ide_at.bin"
#define ROM_PATH_PS2 L"roms/hdd/xtide/SIDE1V12.BIN"
#define ROM_PATH_PS2AT L"roms/hdd/xtide/ide_at_1_1_5.bin"
typedef struct {
@@ -91,13 +91,13 @@ static uint8_t
xtide_read(uint16_t port, void *priv)
{
xtide_t *xtide = (xtide_t *)priv;
uint16_t tempw;
uint16_t tempw = 0xffff;
switch (port & 0xf) {
case 0x0:
tempw = readidew(4);
xtide->data_high = tempw >> 8;
return(tempw & 0xff);
break;
case 0x1:
case 0x2:
@@ -106,17 +106,22 @@ xtide_read(uint16_t port, void *priv)
case 0x5:
case 0x6:
case 0x7:
return(readide(4, (port & 0xf) | 0x1f0));
tempw = readide(4, (port & 0xf) | 0x1f0);
break;
case 0x8:
return(xtide->data_high);
tempw = xtide->data_high;
break;
case 0xe:
return(readide(4, 0x3f6));
tempw = readide(4, 0x3f6);
break;
default:
return(0xff);
break;
}
return(tempw & 0xff);
}
@@ -127,7 +132,7 @@ xtide_init(void)
memset(xtide, 0x00, sizeof(xtide_t));
rom_init(&xtide->bios_rom, XT_ROM_PATH,
rom_init(&xtide->bios_rom, ROM_PATH_XT,
0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL);
ide_xtide_init();
@@ -143,7 +148,7 @@ xtide_init(void)
static int
xtide_available(void)
{
return(rom_present(XT_ROM_PATH));
return(rom_present(ROM_PATH_XT));
}
@@ -154,7 +159,7 @@ xtide_at_init(void)
memset(xtide, 0x00, sizeof(xtide_t));
rom_init(&xtide->bios_rom, AT_ROM_PATH,
rom_init(&xtide->bios_rom, ROM_PATH_AT,
0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL);
ide_init();
@@ -166,7 +171,7 @@ xtide_at_init(void)
static int
xtide_at_available(void)
{
return(rom_present(AT_ROM_PATH));
return(rom_present(ROM_PATH_AT));
}
@@ -177,7 +182,7 @@ xtide_ps2_init(void)
memset(xtide, 0x00, sizeof(xtide_t));
rom_init(&xtide->bios_rom, PS2_ROM_PATH,
rom_init(&xtide->bios_rom, ROM_PATH_PS2,
0xc8000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL);
ide_xtide_init();
@@ -193,7 +198,7 @@ xtide_ps2_init(void)
static int
xtide_ps2_available(void)
{
return(rom_present(PS2_ROM_PATH));
return(rom_present(ROM_PATH_PS2));
}
@@ -204,7 +209,7 @@ xtide_at_ps2_init(void)
memset(xtide, 0x00, sizeof(xtide_t));
rom_init(&xtide->bios_rom, PS2AT_ROM_PATH,
rom_init(&xtide->bios_rom, ROM_PATH_PS2AT,
0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL);
ide_init();
@@ -216,7 +221,7 @@ xtide_at_ps2_init(void)
static int
xtide_at_ps2_available(void)
{
return(rom_present(PS2AT_ROM_PATH));
return(rom_present(ROM_PATH_PS2AT));
}

View File

@@ -10,7 +10,7 @@
*
* !!!NOTE!!! The goal is to GET RID of this file. Do NOT add stuff !!
*
* Version: @(#)ibm.h 1.0.6 2017/09/29
* Version: @(#)ibm.h 1.0.7 2017/10/01
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -526,10 +526,6 @@ extern uint64_t timer_freq;
extern int infocus;
extern void onesec(void);
extern void resetpc_cad(void);
extern void ctrl_alt_esc(void);
extern int dump_on_exit;
extern int start_in_fullscreen;
@@ -589,8 +585,24 @@ extern int scale;
/* Function prototypes. */
extern void pclog(const char *format, ...);
extern void pclog_w(const wchar_t *format, ...);
extern void fatal(const char *format, ...);
extern void pc_init_modules(void);
extern void pc_init(int argc, wchar_t *argv[]);
extern void pc_close(void);
extern void resetpchard_close(void);
extern void resetpchard_init(void);
extern void pc_reset_hard(void);
extern void pc_full_speed(void);
extern void pc_speed_changed(void);
extern void pc_send_cad(void);
extern void pc_send_cae(void);
extern void pc_run(void);
extern void onesec(void);
extern int checkio(int port);
extern void closepc(void);
extern void codegen_block_end(void);
extern void codegen_reset(void);
extern void cpu_set_edx(void);
@@ -602,12 +614,9 @@ extern void execx86(int cycs);
extern void flushmmucache(void);
extern void flushmmucache_cr3(void);
extern int idivl(int32_t val);
extern void initmodules(void);
extern void initpc(int argc, wchar_t *argv[]);
extern void loadcscall(uint16_t seg);
extern void loadcsjmp(uint16_t seg, uint32_t oxpc);
extern void mmu_invalidate(uint32_t addr);
extern void pclog(const char *format, ...);
extern void pmodeint(int num, int soft);
extern void pmoderetf(int is32, uint16_t off);
extern void pmodeiret(int is32);
@@ -615,14 +624,9 @@ extern void port_92_clear_reset(void);
extern uint8_t readdacfifo(void);
extern void refreshread(void);
extern void resetmcr(void);
extern void resetpchard_close(void);
extern void resetpchard_init(void);
extern void resetpchard(void);
extern void resetreadlookup(void);
extern void resetx86(void);
extern void runpc(void);
extern void softresetx86(void);
extern void speedchanged(void);
extern void x86_int_sw(int num);
extern int x86_int_sw_rm(int num);
extern void x86gpf(char *s, uint16_t error);
@@ -633,10 +637,6 @@ extern void x87_dumpregs(void);
extern void x87_reset(void);
/* Platform functions. */
extern void pclog(const char *format, ...);
extern void pclog_w(const wchar_t *format, ...);
extern void fatal(const char *format, ...);
extern void update_status_bar_icon(int tag, int active);
extern void update_status_bar_icon_state(int tag, int state);
extern void status_settextw(wchar_t *wstr);

View File

@@ -120,11 +120,13 @@ void io_removehandler(uint16_t base, int size,
}
}
#if 0
uint8_t cgamode,cgastat=0,cgacol;
int hsync;
uint8_t lpt2dat;
int sw9;
int t237=0;
#endif
uint8_t inb(uint16_t port)
{
uint8_t temp = 0xff;

View File

@@ -13,8 +13,8 @@
#include "../game/gameport.h"
#include "../keyboard_at.h"
#include "../lpt.h"
#include "../hdd/hdc.h"
#include "../hdd/hdc_ide.h"
#include "../disk/hdc.h"
#include "../disk/hdc_ide.h"
#include "machine_common.h"
#include "machine_at.h"

View File

@@ -10,8 +10,8 @@
#include "../io.h"
#include "../mem.h"
#include "../device.h"
#include "../hdd/hdc.h"
#include "../hdd/hdc_ide.h"
#include "../disk/hdc.h"
#include "../disk/hdc_ide.h"
#include "machine_at.h"
#include "machine_at_ali1429.h"

View File

@@ -24,11 +24,11 @@
#include "../device.h"
#include "../lpt.h"
#include "../serial.h"
#include "../disk/hdc.h"
#include "../disk/hdc_ide.h"
#include "../floppy/floppy.h"
#include "../floppy/fdc.h"
#include "../floppy/fdd.h"
#include "../hdd/hdc.h"
#include "../hdd/hdc_ide.h"
#include "machine_at.h"
#include "machine_at_sis_85c471.h"

View File

@@ -19,11 +19,11 @@
#include "../lpt.h"
#include "../serial.h"
#include "../keyboard_at.h"
#include "../disk/hdc.h"
#include "../disk/hdc_ide.h"
#include "../floppy/floppy.h"
#include "../floppy/fdd.h"
#include "../floppy/fdc.h"
#include "../hdd/hdc.h"
#include "../hdd/hdc_ide.h"
#include "../sound/snd_ps1.h"
#include "machine_common.h"
#include "machine_ps1.h"

611
src/pc.c
View File

@@ -33,7 +33,13 @@
#include "dma.h"
#include "random.h"
#include "device.h"
#include "game/gameport.h"
#include "cdrom/cdrom.h"
#include "cdrom/cdrom_image.h"
#include "cdrom/cdrom_ioctl.h"
#include "cdrom/cdrom_null.h"
#include "disk/hdd.h"
#include "disk/hdc.h"
#include "disk/hdc_ide.h"
#include "floppy/floppy.h"
#include "floppy/floppy_86f.h"
#include "floppy/floppy_fdi.h"
@@ -42,13 +48,7 @@
#include "floppy/floppy_td0.h"
#include "floppy/fdc.h"
#include "floppy/fdd.h"
#include "cdrom/cdrom.h"
#include "cdrom/cdrom_image.h"
#include "cdrom/cdrom_ioctl.h"
#include "cdrom/cdrom_null.h"
#include "hdd/hdd.h"
#include "hdd/hdc.h"
#include "hdd/hdc_ide.h"
#include "game/gameport.h"
#include "keyboard.h"
#include "keyboard_at.h"
#include "lpt.h"
@@ -92,32 +92,32 @@ wchar_t cfg_path[1024];
wchar_t nvr_path[1024];
int window_w, window_h, window_x, window_y, window_remember;
int dump_on_exit = 0;
int start_in_fullscreen = 0;
int CPUID;
int vid_resize, vid_api;
int cycles_lost = 0;
int clockrate;
int insc=0;
float mips,flops;
extern int mmuflush;
extern int readlnum,writelnum;
void fullspeed();
int framecount,fps;
int output;
int atfullspeed;
int infocus;
int cycles_lost = 0;
int clockrate;
int insc = 0;
float mips, flops;
int framecount, fps;
int win_title_update = 0;
int updatestatus = 0;
int pollmouse_delay = 2;
int mousecapture;
int suppress_overscan = 0;
int cpuspeed2;
void pclog(const char *format, ...)
extern int mmuflush;
extern int readlnum,writelnum;
/* Log something to the logfile or stdout. */
void
pclog(const char *format, ...)
{
#ifndef RELEASE_BUILD
va_list ap;
@@ -128,7 +128,10 @@ void pclog(const char *format, ...)
#endif
}
void pclog_w(const wchar_t *format, ...)
/* Log something to the logfile or stdout. */
void
pclog_w(const wchar_t *format, ...)
{
#ifndef RELEASE_BUILD
va_list ap;
@@ -139,156 +142,64 @@ void pclog_w(const wchar_t *format, ...)
#endif
}
#ifndef __unix
#ifndef _LIBC
# define __builtin_expect(expr, val) (expr)
#endif
#undef memmem
/* Return the first occurrence of NEEDLE in HAYSTACK. */
void *memmem (const void *haystack, size_t haystack_len, const void *needle, size_t needle_len)
{
const char *begin;
const char *const last_possible = (const char *) haystack + haystack_len - needle_len;
if (needle_len == 0)
/* The first occurrence of the empty string is deemed to occur at
the beginning of the string. */
return (void *) haystack;
/* Sanity check, otherwise the loop might search through the whole
memory. */
if (__builtin_expect (haystack_len < needle_len, 0))
return NULL;
for (begin = (const char *) haystack; begin <= last_possible; ++begin)
if (begin[0] == ((const char *) needle)[0] && !memcmp ((const void *) &begin[1], (const void *) ((const char *) needle + 1), needle_len - 1))
return (void *) begin;
return NULL;
}
#endif
void fatal(const char *format, ...)
/* Log a fatal error, and display a UI message before exiting. */
void
fatal(const char *format, ...)
{
char msg[1024];
#ifndef __unix
char *newline;
#endif
va_list ap;
char *sp;
va_start(ap, format);
vsprintf(msg, format, ap);
printf(msg);
va_end(ap);
fflush(stdout);
savenvr();
config_save();
#ifndef __unix
newline = memmem(msg, strlen(msg), "\n", strlen("\n"));
if (newline != NULL)
{
*newline = 0;
}
plat_msgbox_fatal(msg);
#endif
dumppic();
dumpregs(1);
/* Make sure the message does not have a trailing newline. */
if ((sp = strchr(msg, '\n')) != NULL) *sp = '\0';
#ifndef __unix
plat_msgbox_fatal(msg);
#endif
fflush(stdout);
exit(-1);
}
uint8_t cgastat;
int pollmouse_delay = 2;
void pollmouse(void)
static void
usage(void)
{
int x, y, z;
pollmouse_delay--;
if (pollmouse_delay) return;
pollmouse_delay = 2;
mouse_poll_host();
mouse_get_mickeys(&x, &y, &z);
mouse_poll(x, y, z, mouse_buttons);
printf("Command line options:\n\n");
printf("--config file.cfg - use given file as initial configuration\n");
printf("--dump - always dump memory on exit\n");
printf("--fullscreen - start in fullscreen mode\n");
printf("--vmpath pathname - set 'path' to be root for vm\n");
exit(-1);
/*NOTREACHED*/
}
/*PC1512 languages -
7=English
6=German
5=French
4=Spanish
3=Danish
2=Swedish
1=Italian
3,2,1 all cause the self test to fail for some reason
/*
* Perform initial startup of the PC.
*
* This is the platform-indepenent part of the startup,
* where we check commandline arguments and loading a
* configuration file.
*/
int cpuspeed2;
int clocks[3][12][4]=
{
{
{4772728,13920,59660,5965}, /*4.77MHz*/
{8000000,23333,110000,0}, /*8MHz*/
{10000000,29166,137500,0}, /*10MHz*/
{12000000,35000,165000,0}, /*12MHz*/
{16000000,46666,220000,0}, /*16MHz*/
},
{
{8000000,23333,110000,0}, /*8MHz*/
{12000000,35000,165000,0}, /*12MHz*/
{16000000,46666,220000,0}, /*16MHz*/
{20000000,58333,275000,0}, /*20MHz*/
{25000000,72916,343751,0}, /*25MHz*/
},
{
{16000000, 46666,220000,0}, /*16MHz*/
{20000000, 58333,275000,0}, /*20MHz*/
{25000000, 72916,343751,0}, /*25MHz*/
{33000000, 96000,454000,0}, /*33MHz*/
{40000000,116666,550000,0}, /*40MHz*/
{50000000, 72916*2,343751*2,0}, /*50MHz*/
{33000000*2, 96000*2,454000*2,0}, /*66MHz*/
{75000000, 72916*3,343751*3,0}, /*75MHz*/
{80000000,116666*2,550000*2,0}, /*80MHz*/
{100000000, 72916*4,343751*4,0}, /*100MHz*/
{120000000,116666*3,550000*3,0}, /*120MHz*/
{133000000, 96000*4,454000*4,0}, /*133MHz*/
}
};
int updatestatus;
int win_title_update=0;
void onesec(void)
{
fps=framecount;
framecount=0;
win_title_update=1;
}
void pc_reset(void)
{
cpu_set();
resetx86();
dma_reset();
fdc_reset();
pic_reset();
serial_reset();
if (AT)
setpitclock(machines[machine].cpu[cpu_manufacturer].cpus[cpu].rspeed);
else
setpitclock(14318184.0);
}
#undef printf
void initpc(int argc, wchar_t *argv[])
void
pc_init(int argc, wchar_t *argv[])
{
wchar_t *config_file = NULL;
wchar_t *p;
@@ -313,38 +224,23 @@ void initpc(int argc, wchar_t *argv[])
*/
_wgetcwd(cfg_path, sizeof(cfg_path)-1);
for (c = 1; c < argc; c++)
{
if (!_wcsicmp(argv[c], L"--help"))
{
for (c=1; c<argc; c++) {
if (! _wcsicmp(argv[c], L"--help")) {
usage:
printf("Command line options :\n\n");
printf("--config file.cfg - use given config file as initial configuration\n");
printf("--dump - always dump memory on exit\n");
printf("--fullscreen - start in fullscreen mode\n");
printf("--vmpath pathname - set 'path' to be root for vm\n");
exit(-1);
}
else if (!_wcsicmp(argv[c], L"--config") ||
!_wcsicmp(argv[c], L"-C"))
{
if ((c+1) == argc)
break;
config_file = argv[c+1];
c++;
}
else if (!_wcsicmp(argv[c], L"--dump") ||
!_wcsicmp(argv[c], L"-D"))
{
usage();
/*NOTRECHED*/
} else if (!_wcsicmp(argv[c], L"--config") ||
!_wcsicmp(argv[c], L"-C")) {
if ((c+1) == argc) break;
config_file = argv[++c];
} else if (!_wcsicmp(argv[c], L"--dump") ||
!_wcsicmp(argv[c], L"-D")) {
dump_on_exit = 1;
}
else if (!_wcsicmp(argv[c], L"--fullscreen") ||
!_wcsicmp(argv[c], L"-F"))
{
} else if (!_wcsicmp(argv[c], L"--fullscreen") ||
!_wcsicmp(argv[c], L"-F")) {
start_in_fullscreen = 1;
}
else if (!_wcsicmp(argv[c], L"--test"))
{
} else if (!_wcsicmp(argv[c], L"--test")) {
/* some (undocumented) test function here.. */
#ifdef WALTJE
dir = opendirw(exe_path);
@@ -363,14 +259,12 @@ usage:
/* .. and then exit. */
exit(0);
}
else if (!_wcsicmp(argv[c], L"--vmpath") ||
!_wcsicmp(argv[c], L"-P"))
{
if ((c+1) == argc)
break;
wcscpy(cfg_path, argv[c+1]);
c++;
/*NOTREACHED*/
} else if (!_wcsicmp(argv[c], L"--vmpath") ||
!_wcsicmp(argv[c], L"-P")) {
if ((c+1) == argc) break;
wcscpy(cfg_path, argv[++c]);
}
/* Uhm... out of options here.. */
@@ -396,34 +290,74 @@ usage:
if ((config_file[1] == L':') || /* drive letter present */
(config_file[0] == L'\\')) /* backslash, root dir */
append_filename_w(config_file_default,
NULL, /* empty */
config_file, 511);
NULL, config_file, 511);
else
append_filename_w(config_file_default,
cfg_path,
config_file, 511);
cfg_path, config_file, 511);
config_file = NULL;
} else {
append_filename_w(config_file_default, cfg_path, CONFIG_FILE_W, 511);
}
/*
* This is weird, but we need to clear that global
* data before we actually use it, and the config
* file reader will add data to those areas.. --FvK
* We are about to read the configuration file, which MAY
* put data into global variables (the hard- and floppy
* disks are an example) so we have to initialize those
* modules before we load the config..
*/
hdd_init();
hdc_init();
config_load(config_file);
}
void initmodules(void)
void
pc_full_speed(void)
{
cpuspeed2 = cpuspeed;
if (! atfullspeed) {
pclog("Set fullspeed - %i %i %i\n", is386, AT, cpuspeed2);
if (AT)
setpitclock(machines[machine].cpu[cpu_manufacturer].cpus[cpu].rspeed);
else
setpitclock(14318184.0);
}
atfullspeed = 1;
nvr_recalc();
}
void
pc_speed_changed(void)
{
if (AT)
setpitclock(machines[machine].cpu[cpu_manufacturer].cpus[cpu].rspeed);
else
setpitclock(14318184.0);
nvr_recalc();
}
/* Initialize modules, ran once, after pc_init. */
void
pc_init_modules(void)
{
int i;
/* Initialize modules. */
cpuspeed2 = (AT) ? 2 : 1;
atfullspeed = 0;
codegen_init();
random_init();
mem_init();
rom_load_bios(romset);
mem_add_bios();
mouse_init();
#ifdef WALTJE
serial_init();
@@ -432,42 +366,32 @@ void initmodules(void)
video_init();
ide_init_first();
mem_init();
rom_load_bios(romset);
mem_add_bios();
cpuspeed2=(AT)?2:1;
atfullspeed=0;
codegen_init();
device_init();
timer_reset();
for (i = 0; i < CDROM_NUM; i++)
{
if (cdrom_drives[i].bus_type)
{
for (i=0; i<CDROM_NUM; i++) {
if (cdrom_drives[i].bus_type) {
SCSIReset(cdrom_drives[i].scsi_device_id, cdrom_drives[i].scsi_device_lun);
}
if (cdrom_drives[i].host_drive == 200)
{
if (cdrom_drives[i].host_drive == 200) {
image_open(i, cdrom_image[i].image_path);
}
else if ((cdrom_drives[i].host_drive >= 'A') && (cdrom_drives[i].host_drive <= 'Z'))
} else
if ((cdrom_drives[i].host_drive>='A') && (cdrom_drives[i].host_drive <= 'Z'))
{
ioctl_open(i, cdrom_drives[i].host_drive);
}
else
{
} else {
cdrom_null_open(i, cdrom_drives[i].host_drive);
}
}
sound_reset();
#if 1
/* This should be in floppy.c and fdc.c --FvK */
fdc_init();
floppy_init();
fdi_init();
img_init();
@@ -479,49 +403,64 @@ void initmodules(void)
floppy_load(1, floppyfns[1]);
floppy_load(2, floppyfns[2]);
floppy_load(3, floppyfns[3]);
#endif
loadnvr();
sound_init();
hdc_init(hdc_name);
ide_reset();
scsi_card_init();
fullspeed();
shadowbios=0;
pc_full_speed();
for (i = 0; i < CDROM_NUM; i++)
{
if (cdrom_drives[i].host_drive == 200)
{
for (i=0; i<CDROM_NUM; i++) {
if (cdrom_drives[i].host_drive == 200) {
image_reset(i);
}
else if ((cdrom_drives[i].host_drive >= 'A') && (cdrom_drives[i].host_drive <= 'Z'))
{
else if ((cdrom_drives[i].host_drive >= 'A') && (cdrom_drives[i].host_drive <= 'Z')) {
ioctl_reset(i);
}
}
shadowbios = 0;
}
void resetpc(void)
void
pc_reset(void)
{
pc_reset();
shadowbios=0;
cpu_set();
resetx86();
dma_reset();
fdc_reset();
pic_reset();
serial_reset();
if (AT)
setpitclock(machines[machine].cpu[cpu_manufacturer].cpus[cpu].rspeed);
else
setpitclock(14318184.0);
shadowbios = 0;
}
void pc_keyboard_send(uint8_t val)
void
pc_keyboard_send(uint8_t val)
{
if (AT)
{
keyboard_at_adddata_keyboard_raw(val);
}
else
{
keyboard_send(val);
}
}
void resetpc_cad(void)
void
pc_send_cad(void)
{
pc_keyboard_send(29); /* Ctrl key pressed */
pc_keyboard_send(56); /* Alt key pressed */
@@ -532,7 +471,8 @@ void resetpc_cad(void)
}
void ctrl_alt_esc(void)
void
pc_send_cae(void)
{
pc_keyboard_send(29); /* Ctrl key pressed */
pc_keyboard_send(56); /* Alt key pressed */
@@ -542,9 +482,9 @@ void ctrl_alt_esc(void)
pc_keyboard_send(129); /* Esc key released */
}
int suppress_overscan = 0;
void resetpchard_close(void)
void
resetpchard_close(void)
{
suppress_overscan = 0;
@@ -555,9 +495,11 @@ void resetpchard_close(void)
closeal();
}
void resetpchard_init(void)
void
resetpchard_init(void)
{
int i = 0;
int i;
sound_realloc_buffers();
@@ -573,7 +515,6 @@ void resetpchard_init(void)
fdc_init();
floppy_reset();
hdc_reset(hdc_name);
#ifndef WALTJE
serial_init();
#endif
@@ -582,6 +523,8 @@ void resetpchard_init(void)
speaker_init();
lpt1_device_init();
hdc_reset();
ide_ter_disable();
ide_qua_disable();
if (ide_enable[2])
@@ -604,7 +547,9 @@ void resetpchard_init(void)
device_add(&ssi2001_device);
if (voodoo_enabled)
device_add(&voodoo_device);
pc_reset();
mouse_emu_init();
loadnvr();
@@ -615,10 +560,8 @@ void resetpchard_init(void)
cpu_cache_int_enabled = cpu_cache_ext_enabled = 0;
for (i = 0; i < CDROM_NUM; i++)
{
if (cdrom_drives[i].host_drive == 200)
{
for (i=0; i<CDROM_NUM; i++) {
if (cdrom_drives[i].host_drive == 200) {
image_reset(i);
}
else if ((cdrom_drives[i].host_drive >= 'A') && (cdrom_drives[i].host_drive <= 'Z'))
@@ -630,66 +573,114 @@ void resetpchard_init(void)
sound_cd_thread_reset();
}
void resetpchard(void)
void
pc_reset_hard(void)
{
resetpchard_close();
resetpchard_init();
}
void
pc_close(void)
{
int i;
for (i=0; i<CDROM_NUM; i++)
cdrom_drives[i].handler->exit(i);
dumppic();
for (i=0; i<FDD_NUM; i++)
floppy_close(i);
dumpregs(0);
video_close();
lpt1_device_close();
device_close_all();
midi_close();
network_close();
}
/*
* Run the actual configured PC.
*/
int framecountx=0;
int sndcount=0;
int sreadlnum,swritelnum,segareads,segawrites, scycles_lost;
int serial_fifo_read, serial_fifo_write;
int emu_fps = 0;
static wchar_t wmachine[2048];
static wchar_t wcpu[2048];
void runpc(void)
static void
pollmouse(void)
{
int x, y, z;
if (--pollmouse_delay) return;
pollmouse_delay = 2;
mouse_poll_host();
mouse_get_mickeys(&x, &y, &z);
mouse_poll(x, y, z, mouse_buttons);
}
void
pc_run(void)
{
wchar_t s[200];
int done=0;
int done = 0;
startblit();
clockrate = machines[machine].cpu[cpu_manufacturer].cpus[cpu].rspeed;
if (is386)
{
if (is386) {
if (cpu_use_dynarec)
exec386_dynarec(machines[machine].cpu[cpu_manufacturer].cpus[cpu].rspeed / 100);
else
exec386(machines[machine].cpu[cpu_manufacturer].cpus[cpu].rspeed / 100);
}
else if (AT)
{
} else if (AT) {
exec386(machines[machine].cpu[cpu_manufacturer].cpus[cpu].rspeed / 100);
}
else
{
} else {
execx86(machines[machine].cpu[cpu_manufacturer].cpus[cpu].rspeed / 100);
}
keyboard_process();
pollmouse();
if (joystick_type != 7) joystick_poll();
if (joystick_type != 7)
joystick_poll();
endblit();
framecountx++;
framecount++;
if (framecountx>=100)
{
framecountx=0;
mips=(float)insc/1000000.0f;
insc=0;
flops=(float)fpucount/1000000.0f;
fpucount=0;
sreadlnum=readlnum;
swritelnum=writelnum;
segareads=egareads;
segawrites=egawrites;
if (framecountx >= 100) {
framecountx = 0;
mips = (float)insc/1000000.0f;
insc = 0;
flops = (float)fpucount/1000000.0f;
fpucount = 0;
sreadlnum = readlnum;
swritelnum = writelnum;
segareads = egareads;
segawrites = egawrites;
scycles_lost = cycles_lost;
cpu_recomp_blocks_latched = cpu_recomp_blocks;
@@ -714,65 +705,37 @@ void runpc(void)
cpu_reps = 0;
cpu_notreps = 0;
updatestatus=1;
readlnum=writelnum=0;
egareads=egawrites=0;
updatestatus = 1;
readlnum = writelnum = 0;
egareads = egawrites = 0;
cycles_lost = 0;
mmuflush=0;
mmuflush = 0;
emu_fps = frames;
frames = 0;
}
if (win_title_update)
{
win_title_update=0;
mbstowcs(wmachine, machine_getname(), strlen(machine_getname()) + 1);
mbstowcs(wcpu, machines[machine].cpu[cpu_manufacturer].cpus[cpu].name, strlen(machines[machine].cpu[cpu_manufacturer].cpus[cpu].name) + 1);
_swprintf(s, L"%s v%s - %i%% - %s - %s - %s", EMU_NAME_W, EMU_VERSION_W, fps, wmachine, wcpu, (!mousecapture) ? plat_get_string_from_id(IDS_2077) : ((mouse_get_type(mouse_type) & MOUSE_TYPE_3BUTTON) ? plat_get_string_from_id(IDS_2078) : plat_get_string_from_id(IDS_2079)));
if (win_title_update) {
mbstowcs(wmachine, machine_getname(), strlen(machine_getname())+1);
mbstowcs(wcpu, machines[machine].cpu[cpu_manufacturer].cpus[cpu].name,
strlen(machines[machine].cpu[cpu_manufacturer].cpus[cpu].name)+1);
_swprintf(s, L"%s v%s - %i%% - %s - %s - %s",
EMU_NAME_W, EMU_VERSION_W,
fps, wmachine, wcpu,
(!mousecapture) ? plat_get_string_from_id(IDS_2077)
: ((mouse_get_type(mouse_type) & MOUSE_TYPE_3BUTTON) ? plat_get_string_from_id(IDS_2078) : plat_get_string_from_id(IDS_2079)));
set_window_title(s);
win_title_update = 0;
}
done++;
}
void fullspeed(void)
{
cpuspeed2=cpuspeed;
if (!atfullspeed)
{
printf("Set fullspeed - %i %i %i\n",is386,AT,cpuspeed2);
if (AT)
setpitclock(machines[machine].cpu[cpu_manufacturer].cpus[cpu].rspeed);
else
setpitclock(14318184.0);
}
atfullspeed=1;
nvr_recalc();
}
void speedchanged(void)
void
onesec(void)
{
if (AT)
setpitclock(machines[machine].cpu[cpu_manufacturer].cpus[cpu].rspeed);
else
setpitclock(14318184.0);
nvr_recalc();
}
void closepc(void)
{
int i = 0;
for (i = 0; i < CDROM_NUM; i++)
{
cdrom_drives[i].handler->exit(i);
}
dumppic();
for (i = 0; i < FDD_NUM; i++)
{
floppy_close(i);
}
dumpregs(0);
video_close();
lpt1_device_close();
device_close_all();
midi_close();
network_close();
fps = framecount;
framecount = 0;
win_title_update = 1;
}

View File

@@ -10,11 +10,11 @@
#include "device.h"
#include "pci.h"
#include "keyboard_at.h"
#include "cdrom/cdrom.h"
#include "disk/hdc.h"
#include "disk/hdc_ide.h"
#include "floppy/floppy.h"
#include "floppy/fdc.h"
#include "hdd/hdc.h"
#include "hdd/hdc_ide.h"
#include "cdrom/cdrom.h"
static uint64_t pci_irq_hold[16];

View File

@@ -12,7 +12,7 @@
* word 0 - base address
* word 1 - bits 1 - 15 = byte count, bit 31 = end of transfer
*
* Version: @(#)piix.c 1.0.4 2017/09/30
* Version: @(#)piix.c 1.0.5 2017/10/01
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -30,8 +30,8 @@
#include "keyboard_at.h"
#include "mem.h"
#include "pci.h"
#include "hdd/hdc.h"
#include "hdd/hdc_ide.h"
#include "disk/hdc.h"
#include "disk/hdc_ide.h"
#include "piix.h"
@@ -612,7 +612,9 @@ void piix_bus_master_set_irq(int channel)
piix_busmaster[channel & 0x0F].status |= (channel >> 4);
}
/* static int reset_reg = 0;
#if 0
static int reset_reg = 0;
static uint8_t rc_read(uint16_t port, void *priv)
{
@@ -625,7 +627,7 @@ static void rc_write(uint16_t port, uint8_t val, void *priv)
{
if (reset_reg & 2)
{
resetpchard();
pc_reset_hard();
}
else
{
@@ -637,12 +639,13 @@ static void rc_write(uint16_t port, uint8_t val, void *priv)
{
piix_reset();
}
resetide();
ide_reset();
softresetx86();
}
}
reset_reg = val;
} */
}
#endif
void piix_reset(void)
{

View File

@@ -8,7 +8,7 @@
*
* Handling of the SCSI controllers.
*
* Version: @(#)scsi.c 1.0.6 2017/09/30
* Version: @(#)scsi.c 1.0.6 2017/10/01
*
* Authors: TheCollector1995, <mariogplayer@gmail.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -26,7 +26,7 @@
#include "../timer.h"
#include "../device.h"
#include "../cdrom/cdrom.h"
#include "../hdd/hdc.h"
#include "../disk/hdc.h"
#include "scsi.h"
#include "scsi_aha154x.h"
#include "scsi_buslogic.h"

View File

@@ -8,7 +8,7 @@
*
* The generic SCSI device command handler.
*
* Version: @(#)scsi_device.c 1.0.4 2017/09/29
* Version: @(#)scsi_device.c 1.0.4 2017/10/01
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -21,7 +21,7 @@
#include <wchar.h>
#include "../ibm.h"
#include "../cdrom/cdrom.h"
#include "../hdd/hdd.h"
#include "../disk/hdd.h"
#include "scsi.h"
#include "scsi_disk.h"

View File

@@ -6,7 +6,7 @@
*
* Emulation of SCSI fixed and removable disks.
*
* Version: @(#)scsi_disk.c 1.0.9 2017/09/30
* Version: @(#)scsi_disk.c 1.0.9 2017/10/01
*
* Author: Miran Grca, <mgrca8@gmail.com>
* Copyright 2017 Miran Grca.
@@ -23,9 +23,9 @@
#include "../device.h"
#include "../piix.h"
#include "../cdrom/cdrom.h"
#include "../hdd/hdd.h"
#include "../hdd/hdc.h"
#include "../hdd/hdc_ide.h"
#include "../disk/hdd.h"
#include "../disk/hdc.h"
#include "../disk/hdc_ide.h"
#include "../win/plat_iodev.h"
#include "scsi.h"
#include "scsi_disk.h"

View File

@@ -24,11 +24,11 @@
#include "device.h"
#include "lpt.h"
#include "serial.h"
#include "disk/hdc.h"
#include "disk/hdc_ide.h"
#include "floppy/floppy.h"
#include "floppy/fdc.h"
#include "floppy/fdd.h"
#include "hdd/hdc.h"
#include "hdd/hdc_ide.h"
#include "sio.h"

View File

@@ -22,11 +22,11 @@
#include "device.h"
#include "lpt.h"
#include "serial.h"
#include "disk/hdc.h"
#include "disk/hdc_ide.h"
#include "floppy/floppy.h"
#include "floppy/fdc.h"
#include "floppy/fdd.h"
#include "hdd/hdc.h"
#include "hdd/hdc_ide.h"
#include "sio.h"

View File

@@ -22,11 +22,11 @@
#include "device.h"
#include "lpt.h"
#include "serial.h"
#include "disk/hdc.h"
#include "disk/hdc_ide.h"
#include "floppy/floppy.h"
#include "floppy/fdc.h"
#include "floppy/fdd.h"
#include "hdd/hdc.h"
#include "hdd/hdc_ide.h"
#include "sio.h"

View File

@@ -22,11 +22,11 @@
#include "device.h"
#include "lpt.h"
#include "serial.h"
#include "disk/hdc.h"
#include "disk/hdc_ide.h"
#include "floppy/floppy.h"
#include "floppy/fdc.h"
#include "floppy/fdd.h"
#include "hdd/hdc.h"
#include "hdd/hdc_ide.h"
#include "sio.h"

View File

@@ -8,7 +8,7 @@
*
* Windows resource script.
*
* Version: @(#)86Box.rc 1.0.12 2017/10/01
* Version: @(#)86Box.rc 1.0.13 2017/10/01
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -808,8 +808,10 @@ BEGIN
IDS_2150 "Thrustmaster Flight Control System"
IDS_2151 "Disabled"
IDS_2152 "None"
IDS_2153 "AT Fixed Disk Adapter"
IDS_2154 "Internal Controller"
#if UNUSED
IDS_2153
IDS_2154
#endif
IDS_2155 "IRQ %i"
IDS_2156 "%" PRIu64
IDS_2157 "%" PRIu64 " MB (CHS: %" PRIu64 ", %" PRIu64 ", %" PRIu64 ")"

View File

@@ -10,8 +10,9 @@
*
* NOTE: FIXME: Strings 2176 and 2193 are same.
* NOTE: FIXME: string 2095 not in use.
* NOTE: FIXME: strings 2152-2154 not in use.
*
* Version: @(#)resource.h 1.0.6 2017/09/23
* Version: @(#)resource.h 1.0.8 2017/10/01
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -308,8 +309,10 @@
#define IDS_2150 2150 // "Thrustmaster Flight Control System"
#define IDS_2151 2151 // "Disabled"
#define IDS_2152 2152 // "None"
#define IDS_2153 2153 // "AT Fixed Disk Adapter"
#define IDS_2154 2154 // "Internal IDE"
#if NOTUSED
#define IDS_2153 2153
#define IDS_2154 2154
#endif
#define IDS_2155 2155 // "IRQ %i"
#define IDS_2156 2156 // "MFM (%01i:%01i)"
#define IDS_2157 2157 // "IDE (PIO+DMA) (%01i:%01i)"

View File

@@ -43,11 +43,11 @@
#include "../cdrom/cdrom_ioctl.h"
#include "../cdrom/cdrom_image.h"
#include "../cdrom/cdrom_null.h"
#include "../disk/hdd.h"
#include "../disk/hdc.h"
#include "../disk/hdc_ide.h"
#include "../floppy/floppy.h"
#include "../floppy/fdd.h"
#include "../hdd/hdd.h"
#include "../hdd/hdc.h"
#include "../hdd/hdc_ide.h"
#include "../scsi/scsi.h"
#include "../scsi/scsi_disk.h"
#include "../network/network.h"
@@ -158,7 +158,6 @@ static int *sb_icon_flags;
static int *sb_part_meanings;
static int *sb_part_icons;
static WCHAR **sbTips;
static int sb_parts = 0;
static int sb_ready = 0;
@@ -334,7 +333,7 @@ void mainthread(LPVOID param)
{
start_time = timer_read();
drawits-=10; if (drawits>50) drawits=0;
runpc();
pc_run();
frames++;
if (frames >= 200 && nvr_dosave)
{
@@ -496,7 +495,7 @@ static void init_cdrom_host_drives(void)
}
HMENU create_popup_menu(int part)
static HMENU create_popup_menu(int part)
{
HMENU newHandle;
newHandle = CreatePopupMenu();
@@ -505,7 +504,7 @@ HMENU create_popup_menu(int part)
}
void create_floppy_submenu(HMENU m, int id)
static void create_floppy_submenu(HMENU m, int id)
{
AppendMenu(m, MF_STRING, IDM_FLOPPY_IMAGE_NEW | id, win_language_get_string_from_id(IDS_2161));
AppendMenu(m, MF_SEPARATOR, 0, 0);
@@ -515,7 +514,7 @@ void create_floppy_submenu(HMENU m, int id)
AppendMenu(m, MF_STRING, IDM_FLOPPY_EJECT | id, win_language_get_string_from_id(IDS_2164));
}
void create_cdrom_submenu(HMENU m, int id)
static void create_cdrom_submenu(HMENU m, int id)
{
int i = 0;
WCHAR s[64];
@@ -579,7 +578,7 @@ check_menu_items:
}
}
void create_removable_disk_submenu(HMENU m, int id)
static void create_removable_disk_submenu(HMENU m, int id)
{
AppendMenu(m, MF_STRING, IDM_RDISK_EJECT | id, win_language_get_string_from_id(IDS_2166));
AppendMenu(m, MF_STRING, IDM_RDISK_RELOAD | id, win_language_get_string_from_id(IDS_2167));
@@ -1621,79 +1620,81 @@ void reset_menus(void)
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)
{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
HWND hwnd; /* handle for our window */
MSG messages; /* received-messages buffer */
WNDCLASSEX wincl; /* buffer for main window's class */
HACCEL haccel; /* handle to accelerator table */
int c, d, bRet;
WCHAR emulator_title[200];
WCHAR title[200];
LARGE_INTEGER qpc_freq;
HACCEL haccel; /* Handle to accelerator table */
/* Process the command line for options. */
process_command_line();
memset(recv_key, 0, sizeof(recv_key));
process_command_line();
win_language_load_common_strings();
hinstance=hThisInstance;
/* The Window structure */
/* The Window structure. */
hinstance = hThisInstance;
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.lpfnWndProc = WindowProcedure; /* called by Windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
/* Use default icon and mouse-pointer. */
wincl.hIcon = LoadIcon(hinstance, (LPCTSTR) 100);
wincl.hIconSm = LoadIcon(hinstance, (LPCTSTR) 100);
wincl.hCursor = NULL;
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.lpszMenuName = NULL; /* no menu */
wincl.cbClsExtra = 0; /* no extra bytes after window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
/* Use Windows's default color as the background of the window. */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx(&wincl))
{
return 0;
/* Register the window class, and if it fails quit the program. */
if (! RegisterClassEx(&wincl)) {
return(0);
}
wincl.lpszClassName = szSubClassName;
wincl.lpfnWndProc = subWindowProcedure; /* This function is called by windows */
if (!RegisterClassEx(&wincl))
{
return 0;
wincl.lpfnWndProc = subWindowProcedure; /* called by Windows */
if (! RegisterClassEx(&wincl)) {
return(0);
}
menu = LoadMenu(hThisInstance, TEXT("MainMenu"));
_swprintf(emulator_title, L"%s v%s", EMU_NAME_W, EMU_VERSION_W);
_swprintf(title, L"%s v%s", EMU_NAME_W, EMU_VERSION_W);
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
emulator_title, /* Title Text */
(WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX)/* | DS_3DLOOK*/, /* default window */
0, /* no extended possibilites */
szClassName, /* class name */
title, /* Title Text */
#if 0
(WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX), /* default window */
#else
(WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX) | DS_3DLOOK,
#endif
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
640+(GetSystemMetrics(SM_CXFIXEDFRAME)*2), /* The programs width */
CW_USEDEFAULT, /* where window ends up on the screen */
640+(GetSystemMetrics(SM_CXFIXEDFRAME)*2), /* width */
480+(GetSystemMetrics(SM_CYFIXEDFRAME)*2)+GetSystemMetrics(SM_CYMENUSIZE)+GetSystemMetrics(SM_CYCAPTION)+1, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
menu, /* Menu */
HWND_DESKTOP, /* window is a child to desktop */
menu, /* menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
NULL /* no Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);
/* Make the window visible on the screen. */
ShowWindow(hwnd, nFunsterStil);
/* Load the accelerator table */
haccel = LoadAccelerators(hinstAcc, L"MainAccel");
if (haccel == NULL)
{
if (haccel == NULL) {
fatal("haccel is null\n");
}
@@ -1701,38 +1702,37 @@ int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpsz
device.usUsage = 0x06;
device.dwFlags = RIDEV_NOHOTKEYS;
device.hwndTarget = hwnd;
if (RegisterRawInputDevices(&device, 1, sizeof(device)))
{
if (RegisterRawInputDevices(&device, 1, sizeof(device))) {
pclog("Raw input registered!\n");
}
else
{
} else {
pclog("Raw input registration failed!\n");
}
get_registry_key_map();
ghwnd=hwnd;
ghwnd = hwnd;
hwndRender = CreateWindow(L"STATIC", NULL, WS_VISIBLE | WS_CHILD | SS_BITMAP, 0, 0, 1, 1, ghwnd, NULL, hinstance, NULL);
hwndRender = CreateWindow(L"STATIC", NULL,
WS_VISIBLE|WS_CHILD|SS_BITMAP,
0, 0, 1, 1, ghwnd, NULL, hinstance, NULL);
/* FIXME: Kotori, code below should be moved to pc.c, as its not Win specific. */
initpc(argc, argv);
/* Pre-initialize the system, this loads the config file. */
pc_init(argc, argv);
init_cdrom_host_drives();
network_init();
/* Now that we know our window sizes, adjust to that. */
hwndStatus = EmulatorStatusBar(hwnd, IDC_STATUS, hThisInstance);
OriginalStatusBarProcedure = GetWindowLongPtr(hwndStatus, GWLP_WNDPROC);
SetWindowLongPtr(hwndStatus, GWL_WNDPROC, (LONG_PTR) &StatusBarProcedure);
smenu = LoadMenu(hThisInstance, TEXT("StatusBarMenu"));
initmodules();
pc_init_modules();
if (vid_apis[0][vid_api].init(hwndRender) == 0)
{
@@ -1746,8 +1746,12 @@ int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpsz
}
}
if (vid_resize) SetWindowLongPtr(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW&~WS_MINIMIZEBOX)|WS_VISIBLE);
else SetWindowLongPtr(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW&~WS_SIZEBOX&~WS_THICKFRAME&~WS_MAXIMIZEBOX&~WS_MINIMIZEBOX)|WS_VISIBLE);
if (vid_resize)
SetWindowLongPtr(hwnd, GWL_STYLE,
(WS_OVERLAPPEDWINDOW&~WS_MINIMIZEBOX)|WS_VISIBLE);
else
SetWindowLongPtr(hwnd, GWL_STYLE,
(WS_OVERLAPPEDWINDOW&~WS_SIZEBOX&~WS_THICKFRAME&~WS_MAXIMIZEBOX&~WS_MINIMIZEBOX)|WS_VISIBLE);
reset_menus();
@@ -1771,7 +1775,16 @@ int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpsz
}
pclog("A total of %d ROM sets have been loaded.\n", d);
/* Load the ROMs for the selected machine. */
/*
* Load the ROMs for the selected machine.
*
* FIXME:
* We should not do that here. If something turns out
* to be wrong with the configuration (such as missing
* ROM images, we should just display a fatal message
* in the render window's center, let them click OK,
* and then exit so they can remedy the situation.
*/
if (! rom_load_bios(romset)) {
/* Whoops, ROMs not found. */
if (romset!=-1)
@@ -1787,17 +1800,14 @@ int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpsz
romset = c;
machine = machine_getmachine(romset);
config_save();
resetpchard();
pc_reset_hard();
break;
}
}
}
for (c = 0; c < GFX_MAX; c++)
{
gfx_present[c] = video_card_available(video_old_to_new(c));
}
if (!video_card_available(video_old_to_new(gfxcard)))
{
if (romset!=-1)
@@ -1810,14 +1820,17 @@ int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpsz
{
gfxcard = c;
config_save();
resetpchard();
pc_reset_hard();
break;
}
}
}
/* Load the selected machine's BIOS. */
rom_load_bios(romset);
resetpchard();
/* Perform a hard reset to start the machine. */
pc_reset_hard();
timeBeginPeriod(1);
@@ -1845,65 +1858,57 @@ int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpsz
endblit();
device_force_redraw();
}
if (window_remember)
{
MoveWindow(hwnd, window_x, window_y,
window_w,
window_h,
TRUE);
}
else
{
MoveWindow(hwndRender, 0, 0,
winsizex,
winsizey,
TRUE);
MoveWindow(hwndStatus, 0, winsizey + 6,
winsizex,
17,
TRUE);
if (window_remember) {
MoveWindow(hwnd, window_x, window_y, window_w, window_h, TRUE);
} else {
MoveWindow(hwndRender, 0, 0, winsizex, winsizey, TRUE);
MoveWindow(hwndStatus, 0, winsizey+6, winsizex, 17, TRUE);
}
/* Run the message loop. It will run until GetMessage() returns 0 */
while (!quited)
{
while (((bRet = GetMessage(&messages,NULL,0,0)) != 0) && !quited)
{
if (bRet == -1)
while (! quited)
{
bRet = GetMessage(&messages, NULL, 0, 0);
if ((bRet == 0) || quited) break;
if (bRet == -1) {
fatal("bRet is -1\n");
}
if (messages.message==WM_QUIT) quited=1;
if (!TranslateAccelerator(hwnd, haccel, &messages))
{
if (messages.message == WM_QUIT) {
quited = 1;
break;
}
if (! TranslateAccelerator(hwnd, haccel, &messages)) {
TranslateMessage(&messages);
DispatchMessage(&messages);
}
if (recv_key[0x58] && recv_key[0x42] && mousecapture)
{
if (recv_key[0x58] && recv_key[0x42] && mousecapture) {
ClipCursor(&oldclip);
ShowCursor(TRUE);
mousecapture=0;
mousecapture = 0;
}
if ((recv_key[0x1D] || recv_key[0x9D]) && (recv_key[0x38] || recv_key[0xB8]) && (recv_key[0x51] || recv_key[0xD1]) &&
video_fullscreen)
{
if ((recv_key[0x1D] || recv_key[0x9D]) &&
(recv_key[0x38] || recv_key[0xB8]) &&
(recv_key[0x51] || recv_key[0xD1]) && video_fullscreen) {
leave_fullscreen();
}
}
quited=1;
}
startblit();
Sleep(200);
TerminateThread(mainthreadh,0);
TerminateThread(mainthreadh, 0);
savenvr();
config_save();
closepc();
pc_close();
vid_apis[video_fullscreen][vid_api].close();
@@ -1917,9 +1922,10 @@ int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpsz
UnregisterClass(szSubClassName, hinstance);
UnregisterClass(szClassName, hinstance);
return messages.wParam;
return(messages.wParam);
}
HHOOK hKeyboardHook;
int hook_enabled = 0;
@@ -1935,29 +1941,43 @@ LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
p = (KBDLLHOOKSTRUCT*)lParam;
if (p->vkCode == VK_TAB && p->flags & LLKHF_ALTDOWN) return 1; /* disable alt-tab */
if (p->vkCode == VK_SPACE && p->flags & LLKHF_ALTDOWN) return 1; /* disable alt-tab */
if((p->vkCode == VK_LWIN) || (p->vkCode == VK_RWIN)) return 1; /* disable windows keys */
if (p->vkCode == VK_ESCAPE && p->flags & LLKHF_ALTDOWN) return 1; /* disable alt-escape */
bControlKeyDown = GetAsyncKeyState (VK_CONTROL) >> ((sizeof(SHORT) * 8) - 1); /* checks ctrl key pressed */
if (p->vkCode == VK_ESCAPE && bControlKeyDown) return 1; /* disable ctrl-escape */
/* disable alt-tab */
if (p->vkCode == VK_TAB && p->flags & LLKHF_ALTDOWN) return 1;
/* disable alt-space */
if (p->vkCode == VK_SPACE && p->flags & LLKHF_ALTDOWN) return 1;
/* disable alt-escape */
if (p->vkCode == VK_ESCAPE && p->flags & LLKHF_ALTDOWN) return 1;
/* disable windows keys */
if((p->vkCode == VK_LWIN) || (p->vkCode == VK_RWIN)) return 1;
/* checks ctrl key pressed */
bControlKeyDown = GetAsyncKeyState(VK_CONTROL)>>((sizeof(SHORT)*8)-1);
/* disable ctrl-escape */
if (p->vkCode == VK_ESCAPE && bControlKeyDown) return 1;
return CallNextHookEx( hKeyboardHook, nCode, wParam, lParam );
}
void cdrom_close(uint8_t id)
void
cdrom_close(uint8_t id)
{
switch (cdrom_drives[id].host_drive)
{
switch (cdrom_drives[id].host_drive) {
case 0:
null_close(id);
break;
default:
ioctl_close(id);
break;
case 200:
image_close(id);
break;
default:
ioctl_close(id);
break;
}
}
@@ -1994,23 +2014,27 @@ void about_open(HWND hwnd)
DialogBox(hinstance, (LPCTSTR)DLG_ABOUT, hwnd, about_dlgproc);
}
static void win_pc_reset(int hard)
static void
win_pc_reset(int hard)
{
pause=1;
pause = 1;
Sleep(100);
savenvr();
config_save();
if (hard)
{
resetpchard();
}
pc_reset_hard();
else
{
resetpc_cad();
}
pause=0;
pc_send_cad();
pause = 0;
}
void video_toggle_option(HMENU hmenu, int *val, int id)
{
startblit();
@@ -2022,6 +2046,7 @@ void video_toggle_option(HMENU hmenu, int *val, int id)
device_force_redraw();
}
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static wchar_t wOldTitle[512];
@@ -2054,11 +2079,11 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
break;
case IDM_ACTION_EXIT:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
PostQuitMessage(0);
break;
case IDM_ACTION_CTRL_ALT_ESC:
ctrl_alt_esc();
pc_send_cae();
break;
case IDM_ACTION_PAUSE:

View File

@@ -358,7 +358,7 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam
config_save();
resetpchard();
pc_reset_hard();
EndDialog(hdlg, 0);
return TRUE;

View File

@@ -8,7 +8,7 @@
*
* Windows IO device menu handler.
*
* Version: @(#)win_iodev.c 1.0.4 2017/09/29
* Version: @(#)win_iodev.c 1.0.4 2017/10/01
*
* Author: Miran Grca, <mgrca8@gmail.com>
* Copyright 2016,2017 Miran Grca.
@@ -36,7 +36,7 @@
#include "../cdrom/cdrom_image.h"
#include "../cdrom/cdrom_ioctl.h"
#include "../cdrom/cdrom_null.h"
#include "../hdd/hdd.h"
#include "../disk/hdd.h"
#include "../scsi/scsi_disk.h"
#include "plat_iodev.h"
#include "win.h"

View File

@@ -8,7 +8,7 @@
*
* Windows 86Box Settings dialog handler.
*
* Version: @(#)win_settings.c 1.0.16 2017/10/01
* Version: @(#)win_settings.c 1.0.17 2017/10/01
*
* Author: Miran Grca, <mgrca8@gmail.com>
* Copyright 2016,2017 Miran Grca.
@@ -36,11 +36,11 @@
#include "../lpt.h"
#include "../mouse.h"
#include "../cdrom/cdrom.h"
#include "../disk/hdd.h"
#include "../disk/hdc.h"
#include "../disk/hdc_ide.h"
#include "../floppy/floppy.h"
#include "../floppy/fdd.h"
#include "../hdd/hdd.h"
#include "../hdd/hdc.h"
#include "../hdd/hdc_ide.h"
#include "../scsi/scsi.h"
#include "../network/network.h"
#include "../sound/sound.h"
@@ -77,7 +77,7 @@ static char temp_lpt1_device_name[16];
static int temp_serial[2], temp_lpt;
/* Peripherals category */
static int temp_scsi_card, hdc_ignore, temp_ide_ter, temp_ide_ter_irq, temp_ide_qua, temp_ide_qua_irq;
static int temp_scsi_card, temp_ide_ter, temp_ide_ter_irq, temp_ide_qua, temp_ide_qua_irq;
static char temp_hdc_name[16];
static char *hdc_names[16];
static int temp_bugger;
@@ -332,6 +332,7 @@ static void win_settings_save(void)
/* Peripherals category */
scsi_card_current = temp_scsi_card;
strncpy(hdc_name, temp_hdc_name, sizeof(temp_hdc_name) - 1);
hdc_init(hdc_name);
ide_enable[2] = temp_ide_ter;
ide_irq[2] = temp_ide_ter_irq;
ide_enable[3] = temp_ide_qua;
@@ -365,7 +366,7 @@ static void win_settings_save(void)
config_save();
speedchanged();
pc_speed_changed();
if (joystick_type != 7) gameport_update_joystick_type();
}
@@ -1386,27 +1387,6 @@ static void recalc_hdc_list(HWND hdlg, int machine, int use_selected_hdc)
h = GetDlgItem(hdlg, IDC_COMBO_HDC);
#if 0
/*
* We do not ignore this entry, nor do we zap the selection
* list, as we might want to override the internal controller
* with an external one. --FvK
*/
if (machines[temp_machine].flags & MACHINE_HAS_HDC)
{
hdc_ignore = 1;
SendMessage(h, CB_RESETCONTENT, 0, 0);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) win_language_get_string_from_id(IDS_2154));
/* See above, don't disable it. */
EnableWindow(h, FALSE);
SendMessage(h, CB_SETCURSEL, 1, 0);
}
else
{
#endif
hdc_ignore = 0;
valid = 0;
if (use_selected_hdc)
@@ -1436,6 +1416,12 @@ static void recalc_hdc_list(HWND hdlg, int machine, int use_selected_hdc)
{
break;
}
if (c==1 && !(machines[temp_machine].flags&MACHINE_HAS_HDC))
{
/* Skip "Internal" if machine doesn't have one. */
c++;
continue;
}
if ((hdc_get_flags(c) & DEVICE_AT) && !(machines[machine].flags & MACHINE_AT))
{
c++;
@@ -1456,17 +1442,9 @@ static void recalc_hdc_list(HWND hdlg, int machine, int use_selected_hdc)
c++;
continue;
}
#if 0
if (c < 2)
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) win_language_get_string_from_id(2152 + c));
}
else
#endif
{
mbstowcs(lptsTemp, s, strlen(s) + 1);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp);
}
hdc_names[d] = hdc_get_internal_name(c);
if (!strcmp(old_name, hdc_names[d]))
{
@@ -1483,10 +1461,6 @@ static void recalc_hdc_list(HWND hdlg, int machine, int use_selected_hdc)
}
EnableWindow(h, TRUE);
#if 0
if (machines[temp_machine].flags & MACHINE_HAS_HDC)
}
#endif
free(lptsTemp);
}
@@ -1645,8 +1619,6 @@ static BOOL CALLBACK win_settings_peripherals_proc(HWND hdlg, UINT message, WPAR
return FALSE;
case WM_SAVESETTINGS:
if (hdc_ignore == 0)
{
h = GetDlgItem(hdlg, IDC_COMBO_HDC);
c = SendMessage(h, CB_GETCURSEL, 0, 0);
if (hdc_names[c])
@@ -1657,11 +1629,6 @@ static BOOL CALLBACK win_settings_peripherals_proc(HWND hdlg, UINT message, WPAR
{
strcpy(temp_hdc_name, "none");
}
}
else
{
strcpy(temp_hdc_name, "none");
}
h = GetDlgItem(hdlg, IDC_COMBO_SCSI);
temp_scsi_card = settings_list_to_scsi[SendMessage(h, CB_GETCURSEL, 0, 0)];