2017-05-30 03:38:38 +02:00
/*
2022-11-13 16:37:58 -05:00
* 86 Box 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 .
2017-05-30 03:38:38 +02:00
*
2022-11-13 16:37:58 -05:00
* This file is part of the 86 Box distribution .
2017-05-30 03:38:38 +02:00
*
2022-11-13 16:37:58 -05:00
* Main emulator module where most things are controlled .
2017-05-30 03:38:38 +02:00
*
2023-01-08 14:25:18 +01:00
* Authors : Sarah Walker , < https : //pcem-emulator.co.uk/>
2022-11-13 16:37:58 -05:00
* Miran Grca , < mgrca8 @ gmail . com >
* Fred N . van Kempen , < decwiz @ yahoo . com >
2024-11-30 15:26:06 -05:00
* Jasmine Iwanek , < jriwanek @ gmail . com >
2017-10-08 19:14:46 -04:00
*
2022-11-13 16:37:58 -05:00
* Copyright 2008 - 2020 Sarah Walker .
* Copyright 2016 - 2020 Miran Grca .
* Copyright 2017 - 2020 Fred N . van Kempen .
2022-12-20 19:25:51 -05:00
* Copyright 2021 Laci bá '
* Copyright 2021 dob205
2023-02-14 20:37:58 -05:00
* Copyright 2021 Andreas J . Reichel .
2024-11-30 15:26:06 -05:00
* Copyright 2021 - 2025 Jasmine Iwanek .
2017-05-30 03:38:38 +02:00
*/
2018-01-19 15:39:13 +01:00
# include <inttypes.h>
2018-05-21 19:04:05 +02:00
# include <stdarg.h>
2016-06-26 00:34:39 +02:00
# include <stdio.h>
2017-09-25 04:31:20 -04:00
# include <stdint.h>
2023-02-14 20:37:58 -05:00
# include <stdbool.h>
2016-06-26 00:34:39 +02:00
# include <stdlib.h>
2017-09-25 04:31:20 -04:00
# include <string.h>
2017-10-21 20:29:11 -04:00
# include <time.h>
2017-09-25 04:31:20 -04:00
# include <wchar.h>
2021-12-17 22:15:21 +02:00
# include <stdatomic.h>
2024-01-20 17:27:24 +01:00
# include <unistd.h>
2025-03-20 21:52:48 +06:00
# include <math.h>
2021-12-17 22:15:21 +02:00
2021-11-18 02:09:40 +06:00
# ifndef _WIN32
2022-09-18 17:11:43 -04:00
# include <pwd.h>
2021-11-18 02:09:40 +06:00
# endif
2021-09-03 19:23:50 +02:00
# ifdef __APPLE__
2022-09-18 17:11:43 -04:00
# include <string.h>
# include <dispatch / dispatch.h>
# ifdef __aarch64__
# include <pthread.h>
# endif
2021-09-03 19:23:50 +02:00
# endif
2020-02-29 19:12:23 +01:00
2017-12-10 02:53:10 -05:00
# define HAVE_STDARG_H
2020-03-29 14:24:42 +02:00
# include <86box/86box.h>
# include <86box/config.h>
# include <86box/mem.h>
2020-02-29 19:12:23 +01:00
# include "cpu.h"
Added the IBM 5161 ISA expansion for PC and XT;
Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port;
Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX);
Finished the 586MC1;
Added 8087 emulation;
Moved Cyrix 6x86'es to the Dev branch;
Sanitized/cleaned up memregs.c/h and intel.c/h;
Split the chipsets from machines and sanitized Port 92 emulation;
Added support for the 15bpp mode to the Compaq ATI 28800;
Moved the MR 386DX and 486 machines to the Dev branch;
Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00;
Ported the new timer code from PCem;
Cleaned up the CPU table of unused stuff and better optimized its structure;
Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch;
Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem;
Added the AHA-1540A and the BusTek BT-542B;
Moved the Sumo SCSI-AT to the Dev branch;
Minor IDE, FDC, and floppy drive code clean-ups;
Made NCR 5380/53C400-based cards' BIOS address configurable;
Got rid of the legacy romset variable;
Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit;
Added the Amstead PPC512 per PCem patch by John Elliott;
Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages);
Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing;
Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem;
Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit;
Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement;
Amstrad MegaPC does now works correctly with non-internal graphics card;
The SLiRP code no longer casts a packed struct type to a non-packed struct type;
The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present;
The S3 Virge on BeOS is no longer broken (was broken by build #1591);
OS/2 2.0 build 6.167 now sees key presses again;
Xi8088 now work on CGA again;
86F images converted from either the old or new variants of the HxC MFM format now work correctly;
Hardware interrupts with a vector of 0xFF are now handled correctly;
OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct;
Fixed VNC keyboard input bugs;
Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver;
Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly;
Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4;
Compaq Portable now works with all graphics cards;
Fixed various MDSI Genius bugs;
Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly;
Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355;
OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400.
Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391.
Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389.
Fixed a minor IDE timing bug, fixes #388.
Fixed Toshiba T1000 RAM issues, fixes #379.
Fixed EGA/(S)VGA overscan border handling, fixes #378;
Got rid of the now long useless IDE channel 2 auto-removal, fixes #370;
Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366;
Ported the Unicode CD image file name fix from VARCem, fixes #365;
Fixed high density floppy disks on the Xi8088, fixes #359;
Fixed some bugs in the Hercules emulation, fixes #346, fixes #358;
Fixed the SCSI hard disk mode sense pages, fixes #356;
Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349;
Fixed bugs in the serial mouse emulation, fixes #344;
Compiled 86Box binaries now include all the required .DLL's, fixes #341;
Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
# ifdef USE_DYNAREC
2022-09-18 17:11:43 -04:00
# include "codegen_public.h"
Added the IBM 5161 ISA expansion for PC and XT;
Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port;
Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX);
Finished the 586MC1;
Added 8087 emulation;
Moved Cyrix 6x86'es to the Dev branch;
Sanitized/cleaned up memregs.c/h and intel.c/h;
Split the chipsets from machines and sanitized Port 92 emulation;
Added support for the 15bpp mode to the Compaq ATI 28800;
Moved the MR 386DX and 486 machines to the Dev branch;
Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00;
Ported the new timer code from PCem;
Cleaned up the CPU table of unused stuff and better optimized its structure;
Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch;
Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem;
Added the AHA-1540A and the BusTek BT-542B;
Moved the Sumo SCSI-AT to the Dev branch;
Minor IDE, FDC, and floppy drive code clean-ups;
Made NCR 5380/53C400-based cards' BIOS address configurable;
Got rid of the legacy romset variable;
Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit;
Added the Amstead PPC512 per PCem patch by John Elliott;
Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages);
Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing;
Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem;
Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit;
Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement;
Amstrad MegaPC does now works correctly with non-internal graphics card;
The SLiRP code no longer casts a packed struct type to a non-packed struct type;
The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present;
The S3 Virge on BeOS is no longer broken (was broken by build #1591);
OS/2 2.0 build 6.167 now sees key presses again;
Xi8088 now work on CGA again;
86F images converted from either the old or new variants of the HxC MFM format now work correctly;
Hardware interrupts with a vector of 0xFF are now handled correctly;
OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct;
Fixed VNC keyboard input bugs;
Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver;
Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly;
Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4;
Compaq Portable now works with all graphics cards;
Fixed various MDSI Genius bugs;
Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly;
Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355;
OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400.
Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391.
Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389.
Fixed a minor IDE timing bug, fixes #388.
Fixed Toshiba T1000 RAM issues, fixes #379.
Fixed EGA/(S)VGA overscan border handling, fixes #378;
Got rid of the now long useless IDE channel 2 auto-removal, fixes #370;
Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366;
Ported the Unicode CD image file name fix from VARCem, fixes #365;
Fixed high density floppy disks on the Xi8088, fixes #359;
Fixed some bugs in the Hercules emulation, fixes #346, fixes #358;
Fixed the SCSI hard disk mode sense pages, fixes #356;
Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349;
Fixed bugs in the serial mouse emulation, fixes #344;
Compiled 86Box binaries now include all the required .DLL's, fixes #341;
Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
# endif
2020-02-29 19:12:23 +01:00
# include "x86_ops.h"
2020-03-29 14:24:42 +02:00
# include <86box/io.h>
# include <86box/rom.h>
# include <86box/dma.h>
# include <86box/pci.h>
# include <86box/pic.h>
# include <86box/timer.h>
# include <86box/device.h>
# include <86box/pit.h>
# include <86box/random.h>
# include <86box/nvr.h>
# include <86box/machine.h>
# include <86box/bugger.h>
# include <86box/postcard.h>
2024-01-07 11:50:22 +13:00
# include <86box/unittester.h>
2024-02-26 03:15:44 +06:00
# include <86box/novell_cardkey.h>
2020-03-29 14:24:42 +02:00
# include <86box/isamem.h>
2025-05-04 21:44:53 -04:00
# include <86box/isarom.h>
2020-03-29 14:24:42 +02:00
# include <86box/isartc.h>
# include <86box/lpt.h>
# include <86box/serial.h>
2023-02-14 20:37:58 -05:00
# include <86box/serial_passthrough.h>
2020-03-29 14:24:42 +02:00
# include <86box/keyboard.h>
# include <86box/mouse.h>
# include <86box/gameport.h>
# include <86box/fdd.h>
# include <86box/fdc.h>
2020-06-16 16:53:24 +02:00
# include <86box/fdc_ext.h>
2020-03-29 14:24:42 +02:00
# include <86box/hdd.h>
# include <86box/hdc.h>
# include <86box/hdc_ide.h>
# include <86box/scsi.h>
# include <86box/scsi_device.h>
# include <86box/cdrom.h>
2023-01-08 14:19:28 +01:00
# include <86box/cdrom_interface.h>
2025-07-25 16:30:40 +02:00
# include <86box/rdisk.h>
2020-07-15 09:03:45 +08:00
# include <86box/mo.h>
2020-03-29 14:24:42 +02:00
# include <86box/scsi_disk.h>
# include <86box/cdrom_image.h>
2022-08-21 16:55:47 +02:00
# include <86box/thread.h>
2020-03-29 14:24:42 +02:00
# include <86box/network.h>
# include <86box/sound.h>
# include <86box/midi.h>
# include <86box/snd_speaker.h>
# include <86box/video.h>
# include <86box/ui.h>
2022-04-19 23:06:39 +02:00
# include <86box/path.h>
2020-03-29 14:24:42 +02:00
# include <86box/plat.h>
2020-06-26 13:26:42 +02:00
# include <86box/version.h>
2022-03-12 20:20:25 -03:00
# include <86box/gdbstub.h>
2022-07-13 01:04:01 +02:00
# include <86box/machine_status.h>
2023-02-06 01:39:34 +06:00
# include <86box/apm.h>
# include <86box/acpi.h>
2025-01-12 15:21:31 +00:00
# include <86box/nv/vid_nv_rivatimer.h>
2017-05-06 17:48:33 +02:00
2022-04-22 20:58:08 -04:00
// Disable c99-designator to avoid the warnings about int ng
# ifdef __clang__
2022-09-18 17:11:43 -04:00
# if __has_warning("-Wunused-but-set-variable")
# pragma clang diagnostic ignored "-Wunused-but-set-variable"
# endif
2022-04-22 20:58:08 -04:00
# endif
2020-05-12 13:36:47 +02:00
/* Stuff that used to be globally declared in plat.h but is now extern there
and declared here instead . */
2023-12-11 20:32:51 +01:00
int dopause = 1 ; /* system is paused */
2022-09-18 17:11:43 -04:00
atomic_flag doresize ; /* screen resize requested */
volatile int is_quit ; /* system exit requested */
uint64_t timer_freq ;
char emu_version [ 200 ] ; /* version ID string */
2020-05-12 13:36:47 +02:00
2021-02-10 20:22:51 +00:00
# ifdef MTR_ENABLED
2022-09-18 17:11:43 -04:00
int tracing_on = 0 ;
2021-02-10 20:22:51 +00:00
# endif
2020-05-12 13:36:47 +02:00
2017-10-19 21:26:02 -04:00
/* Commandline options. */
2022-09-18 17:11:43 -04:00
int dump_on_exit = 0 ; /* (O) dump regs on exit */
int start_in_fullscreen = 0 ; /* (O) start in fullscreen */
2017-11-23 17:42:00 -05:00
# ifdef _WIN32
2022-09-18 17:11:43 -04:00
int force_debug = 0 ; /* (O) force debug output */
2017-11-23 17:42:00 -05:00
# endif
2017-10-27 20:54:31 -04:00
# ifdef USE_WX
2022-09-18 17:11:43 -04:00
int video_fps = RENDER_FPS ; /* (O) render speed in fps */
2017-10-27 20:54:31 -04:00
# endif
2022-09-18 17:11:43 -04:00
int settings_only = 0 ; /* (O) show only the settings dialog */
int confirm_exit_cmdl = 1 ; /* (O) do not ask for confirmation on quit if set to 0 */
2018-01-19 15:39:13 +01:00
# ifdef _WIN32
2022-09-18 17:11:43 -04:00
uint64_t unique_id = 0 ;
uint64_t source_hwnd = 0 ;
2018-01-19 15:39:13 +01:00
# endif
2022-09-18 17:11:43 -04:00
char rom_path [ 1024 ] = { ' \0 ' } ; /* (O) full path to ROMs */
rom_path_t rom_paths = { " " , NULL } ; /* (O) full paths to ROMs */
char log_path [ 1024 ] = { ' \0 ' } ; /* (O) full path of logfile */
char vm_name [ 1024 ] = { ' \0 ' } ; /* (O) display name of the VM */
2023-10-12 02:07:43 +02:00
int do_nothing = 0 ;
int dump_missing = 0 ;
2023-10-13 23:03:37 +02:00
int clear_cmos = 0 ;
2022-08-06 14:23:11 +02:00
# ifdef USE_INSTRUMENT
2023-10-12 02:07:43 +02:00
uint8_t instru_enabled = 0 ;
uint64_t instru_run_ms = 0 ;
2022-08-06 14:23:11 +02:00
# endif
2023-10-12 02:07:43 +02:00
int clear_flash = 0 ;
2023-10-13 23:03:37 +02:00
int auto_paused = 0 ;
2017-10-19 21:26:02 -04:00
/* Configuration values. */
2022-09-18 17:11:43 -04:00
int window_remember ;
2023-02-28 23:24:58 -05:00
int vid_resize ; /* (C) allow resizing */
int invert_display = 0 ; /* (C) invert the display */
int suppress_overscan = 0 ; /* (C) suppress overscans */
2025-05-03 01:45:21 +02:00
int lang_id = 0 ; /* (G) language id */
2023-02-28 23:24:58 -05:00
int scale = 0 ; /* (C) screen scale factor */
2023-10-13 23:03:37 +02:00
int dpi_scale = 0 ; /* (C) DPI scaling of the emulated
screen */
2023-02-28 23:24:58 -05:00
int vid_api = 0 ; /* (C) video renderer */
int vid_cga_contrast = 0 ; /* (C) video */
int video_fullscreen = 0 ; /* (C) video */
int video_fullscreen_scale = 0 ; /* (C) video */
int enable_overscan = 0 ; /* (C) video */
int force_43 = 0 ; /* (C) video */
int video_filter_method = 1 ; /* (C) video */
int video_vsync = 0 ; /* (C) video */
int video_framerate = - 1 ; /* (C) video */
2025-04-28 11:18:57 +02:00
bool serial_passthrough_enabled [ SERIAL_MAX - 1 ] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 } ; /* (C) activation and kind of
2024-06-28 23:30:56 -04:00
pass - through for serial ports */
2023-02-28 23:24:58 -05:00
int bugger_enabled = 0 ; /* (C) enable ISAbugger */
2024-02-26 03:15:44 +06:00
int novell_keycard_enabled = 0 ; /* (C) enable Novell NetWare 2.x key card emulation. */
2023-02-28 23:24:58 -05:00
int postcard_enabled = 0 ; /* (C) enable POST card */
2024-01-07 11:21:38 +13:00
int unittester_enabled = 0 ; /* (C) enable unit tester device */
2024-11-30 15:26:06 -05:00
int gameport_type [ GAMEPORT_MAX ] = { 0 , 0 } ; /* (C) enable gameports */
2023-02-28 23:24:58 -05:00
int isamem_type [ ISAMEM_MAX ] = { 0 , 0 , 0 , 0 } ; /* (C) enable ISA mem cards */
2025-05-04 21:44:53 -04:00
int isarom_type [ ISAROM_MAX ] = { 0 , 0 , 0 , 0 } ; /* (C) enable ISA ROM cards */
2023-02-28 23:24:58 -05:00
int isartc_type = 0 ; /* (C) enable ISA RTC card */
2024-06-29 19:43:42 -04:00
int gfxcard [ GFXCARD_MAX ] = { 0 , 0 } ; /* (C) graphics/video card */
2023-02-28 23:24:58 -05:00
int show_second_monitors = 1 ; /* (C) show non-primary monitors */
int sound_is_float = 1 ; /* (C) sound uses FP values */
int voodoo_enabled = 0 ; /* (C) video option */
2023-08-22 17:56:55 +05:00
int ibm8514_standalone_enabled = 0 ; /* (C) video option */
int xga_standalone_enabled = 0 ; /* (C) video option */
2024-08-15 10:52:16 +09:00
int da2_standalone_enabled = 0 ; /* (C) video option */
2023-10-13 23:03:37 +02:00
uint32_t mem_size = 0 ; /* (C) memory size (Installed on
system board ) */
2023-02-28 23:24:58 -05:00
uint32_t isa_mem_size = 0 ; /* (C) memory size (ISA Memory Cards) */
int cpu_use_dynarec = 0 ; /* (C) cpu uses/needs Dyna */
int cpu = 0 ; /* (C) cpu type */
int fpu_type = 0 ; /* (C) fpu type */
2023-04-29 18:56:57 +02:00
int fpu_softfloat = 0 ; /* (C) fpu uses softfloat */
2023-02-28 23:24:58 -05:00
int time_sync = 0 ; /* (C) enable time sync */
2025-05-03 01:45:21 +02:00
int confirm_reset = 1 ; /* (G) enable reset confirmation */
int confirm_exit = 1 ; /* (G) enable exit confirmation */
int confirm_save = 1 ; /* (G) enable save confirmation */
2023-02-28 23:24:58 -05:00
int enable_discord = 0 ; /* (C) enable Discord integration */
int pit_mode = - 1 ; /* (C) force setting PIT mode */
int fm_driver = 0 ; /* (C) select FM sound driver */
2025-05-03 01:45:21 +02:00
int open_dir_usr_path = 0 ; /* (G) default file open dialog directory
2023-10-13 23:03:37 +02:00
of usr_path */
int video_fullscreen_scale_maximized = 0 ; /* (C) Whether fullscreen scaling settings
also apply when maximized . */
int do_auto_pause = 0 ; /* (C) Auto-pause the emulator on focus
loss */
2025-08-19 21:05:12 +02:00
int force_constant_mouse = 0 ; /* (C) Force constant updating of the mouse */
2025-01-03 00:15:28 +01:00
int hook_enabled = 1 ; /* (C) Keyboard hook is enabled */
2025-02-13 05:10:55 +01:00
int test_mode = 0 ; /* (C) Test mode */
2024-03-29 08:23:55 -04:00
char uuid [ MAX_UUID_LEN ] = { ' \0 ' } ; /* (C) UUID or machine identifier */
2025-03-07 00:36:09 +06:00
int sound_muted = 0 ; /* (C) Is sound muted? */
2025-08-13 12:52:24 +02:00
int jumpered_internal_ecp_dma = 0 ; /* (C) Jumpered internal EPC DMA */
2025-05-03 01:45:21 +02:00
int inhibit_multimedia_keys ; /* (G) Inhibit multimedia keys on Windows. */
2025-07-09 12:59:16 +06:00
int force_10ms ; /* (C) Force 10ms CPU frame intervals. */
2025-08-21 17:17:52 +02:00
int vmm_disabled = 0 ; /* (G) disable built-in manager */
char vmm_path_cfg [ 1024 ] = { ' \0 ' } ; /* (G) VMs path (unless -E is used)*/
2017-10-19 04:27:04 -04:00
2024-05-03 17:02:13 +02:00
int other_ide_present = 0 ; /* IDE controllers from non-IDE cards are
present */
int other_scsi_present = 0 ; /* SCSI controllers from non-SCSI cards are
present */
2025-07-10 02:34:26 +02:00
int is_pcjr = 0 ; /* The current machine is PCjr. */
2025-04-19 19:44:47 -07:00
// Accelerator key array
struct accelKey acc_keys [ NUM_ACCELS ] ;
2025-04-20 13:43:14 -07:00
// Default accelerator key values
struct accelKey def_acc_keys [ NUM_ACCELS ] = {
2025-08-13 00:45:15 -04:00
{
. name = " send_ctrl_alt_del " ,
. desc = " Send Control+Alt+Del " ,
. seq = " Ctrl+F12 "
} ,
{
. name = " send_ctrl_alt_esc " ,
. desc = " Send Control+Alt+Escape " ,
. seq = " Ctrl+F10 "
} ,
{
. name = " fullscreen " ,
. desc = " Toggle fullscreen " ,
. seq = " Ctrl+Alt+PgUp "
} ,
{
. name = " screenshot " ,
. desc = " Screenshot " ,
. seq = " Ctrl+F11 "
} ,
{
. name = " release_mouse " ,
. desc = " Release mouse pointer " ,
. seq = " Ctrl+End "
} ,
{
. name = " hard_reset " ,
. desc = " Hard reset " ,
. seq = " Ctrl+Alt+F12 "
} ,
{
. name = " pause " ,
. desc = " Toggle pause " ,
. seq = " Ctrl+Alt+F1 "
} ,
{
. name = " mute " ,
. desc = " Toggle mute " ,
. seq = " Ctrl+Alt+M "
}
2025-04-20 13:43:14 -07:00
} ;
2025-08-22 12:41:35 +05:00
char vmm_path [ 1024 ] = { ' \0 ' } ; /* VM manager path to scan for VMs */
2025-08-21 15:28:32 +02:00
int start_vmm = 1 ;
2025-04-20 13:43:14 -07:00
2017-10-19 04:27:04 -04:00
/* Statistics. */
2021-03-25 02:41:57 -05:00
extern int mmuflush ;
extern int readlnum ;
extern int writelnum ;
2017-10-19 21:26:02 -04:00
2021-03-25 02:41:57 -05:00
/* emulator % */
2022-09-18 17:11:43 -04:00
int fps ;
2021-03-25 02:41:57 -05:00
int framecount ;
2017-10-19 04:27:04 -04:00
2022-09-18 17:11:43 -04:00
extern int CPUID ;
extern int output ;
int atfullspeed ;
2016-06-26 00:34:39 +02:00
2025-03-20 21:52:48 +06:00
extern double exp_pow_table [ 0x800 ] ;
2022-09-18 17:11:43 -04:00
char exe_path [ 2048 ] ; /* path (dir) of executable */
char usr_path [ 1024 ] ; /* path (dir) of user data */
char cfg_path [ 1024 ] ; /* full path of config file */
2025-05-03 01:45:21 +02:00
char global_cfg_path [ 1024 ] ; /* full path of config file */
2022-09-18 17:11:43 -04:00
FILE * stdlog = NULL ; /* file to log output to */
2023-06-26 22:31:03 -04:00
#if 0
int scrnsz_x = SCREEN_RES_X ; /* current screen size, X */
int scrnsz_y = SCREEN_RES_Y ; /* current screen size, Y */
# endif
2022-09-18 17:11:43 -04:00
int config_changed ; /* config has changed */
int title_update ;
int framecountx = 0 ;
int hard_reset_pending = 0 ;
2017-11-18 16:39:01 +01:00
2023-06-26 22:31:03 -04:00
#if 0
int unscaled_size_x = SCREEN_RES_X ; /* current unscaled size X */
int unscaled_size_y = SCREEN_RES_Y ; /* current unscaled size Y */
int efscrnsz_y = SCREEN_RES_Y ;
# endif
2017-11-18 16:39:01 +01:00
2025-03-08 02:13:14 +06:00
__thread int is_cpu_thread = 0 ;
2022-09-18 17:11:43 -04:00
static wchar_t mouse_msg [ 3 ] [ 200 ] ;
2021-03-24 19:52:44 +01:00
2023-12-11 20:32:51 +01:00
static volatile atomic_int do_pause_ack = 0 ;
static volatile atomic_int pause_ack = 0 ;
2023-10-31 00:44:04 +01:00
2025-08-09 14:52:58 +02:00
# define LOG_SIZE_BUFFER 8192 /* Log size buffer */
2025-01-12 15:21:31 +00:00
2025-08-09 17:25:32 +02:00
# ifndef RELEASE_BUILD
2025-01-12 15:21:31 +00:00
static char buff [ LOG_SIZE_BUFFER ] ;
static int seen = 0 ;
2018-01-26 22:17:09 +01:00
2018-03-19 09:48:44 +01:00
static int suppr_seen = 1 ;
2025-01-12 23:15:43 +00:00
// Functions only used in this translation unit
2025-01-12 23:22:22 +00:00
void pclog_ensure_stdlog_open ( void ) ;
2018-03-19 09:48:44 +01:00
# endif
2025-05-03 01:45:21 +02:00
/*
2025-01-12 15:21:31 +00:00
Ensures STDLOG is open for pclog_ex and pclog_ex_cyclic
*/
2025-01-12 23:22:22 +00:00
void pclog_ensure_stdlog_open ( void )
2025-01-12 15:21:31 +00:00
{
2025-01-12 23:15:43 +00:00
# ifndef RELEASE_BUILD
2025-01-12 15:21:31 +00:00
if ( stdlog = = NULL ) {
if ( log_path [ 0 ] ! = ' \0 ' ) {
stdlog = plat_fopen ( log_path , " w " ) ;
if ( stdlog = = NULL )
stdlog = stdout ;
} else
stdlog = stdout ;
}
2018-03-19 09:48:44 +01:00
# endif
2025-01-12 15:21:31 +00:00
}
2018-03-19 09:48:44 +01:00
2017-12-04 11:59:26 -05:00
/*
* Log something to the logfile or stdout .
*
* To avoid excessively - large logfiles because some
* module repeatedly logs , we keep track of what is
* being logged , and catch repeating entries .
*/
2017-10-02 02:15:35 -04:00
void
2025-01-26 15:15:53 -05:00
pclog_ex ( UNUSED ( const char * fmt ) , UNUSED ( va_list ap ) )
2016-06-26 00:34:39 +02:00
{
# ifndef RELEASE_BUILD
2025-01-12 15:21:31 +00:00
char temp [ LOG_SIZE_BUFFER ] ;
2017-11-23 17:42:00 -05:00
2021-06-07 00:15:09 +02:00
if ( strcmp ( fmt , " " ) = = 0 )
2022-09-18 17:11:43 -04:00
return ;
PIC rewrite, proper SMRAM API, complete SiS 471 rewrite and addition of 40x, 460, and 461, changes to mem.c/h, disabled Voodoo memory dumping on exit, bumped SDL Hardware scale quality to 2, bumped IDE/ATAPI drives to ATA-6, finally bumped emulator version to 3.0, redid the bus type ID's to allow for planned ATAPI hard disks, made SST flash set its high mappings to the correct address if the CPU is 16-bit, and added the SiS 401 AMI 486 Clone, AOpen Vi15G, and the Soyo 4SA2 (486 with SiS 496/497 that can boot from CD-ROM), assorted 286+ protected mode fixes (for slightly more accuracy), and fixes to 808x emulation (MS Word 1.0 and 1.10 for DOS now work correctly from floppy).
2020-10-14 23:15:01 +02:00
2025-01-12 15:21:31 +00:00
pclog_ensure_stdlog_open ( ) ;
2017-11-23 17:42:00 -05:00
2021-06-07 00:15:09 +02:00
vsprintf ( temp , fmt , ap ) ;
2022-09-18 17:11:43 -04:00
if ( suppr_seen & & ! strcmp ( buff , temp ) )
seen + + ;
2021-06-07 00:15:09 +02:00
else {
2022-09-18 17:11:43 -04:00
if ( suppr_seen & & seen )
fprintf ( stdlog , " *** %d repeats *** \n " , seen ) ;
seen = 0 ;
strcpy ( buff , temp ) ;
fprintf ( stdlog , " %s " , temp ) ;
2021-06-07 00:15:09 +02:00
}
2017-12-04 11:59:26 -05:00
2021-06-07 00:15:09 +02:00
fflush ( stdlog ) ;
2016-06-26 00:34:39 +02:00
# endif
}
2018-03-19 09:48:44 +01:00
void
pclog_toggle_suppr ( void )
{
# ifndef RELEASE_BUILD
2022-09-18 17:11:43 -04:00
suppr_seen ^ = 1 ;
2018-03-19 09:48:44 +01:00
# endif
}
2017-12-10 02:53:10 -05:00
/* Log something. We only do this in non-release builds. */
void
2025-01-26 15:15:53 -05:00
pclog ( UNUSED ( const char * fmt ) , . . . )
2017-12-10 02:53:10 -05:00
{
# ifndef RELEASE_BUILD
2022-09-18 17:11:43 -04:00
va_list ap ;
2017-12-10 02:53:10 -05:00
2022-09-18 17:11:43 -04:00
va_start ( ap , fmt ) ;
pclog_ex ( fmt , ap ) ;
va_end ( ap ) ;
2017-12-10 02:53:10 -05:00
# endif
}
2025-08-09 15:01:08 +02:00
/* Log something even in release builds. */
void
always_log ( const char * fmt , . . . )
{
char temp [ LOG_SIZE_BUFFER ] ;
va_list ap ;
va_start ( ap , fmt ) ;
if ( stdlog = = NULL ) {
if ( log_path [ 0 ] ! = ' \0 ' ) {
stdlog = plat_fopen ( log_path , " w " ) ;
if ( stdlog = = NULL )
stdlog = stdout ;
} else
stdlog = stdout ;
}
vsprintf ( temp , fmt , ap ) ;
fprintf ( stdlog , " %s " , temp ) ;
fflush ( stdlog ) ;
va_end ( ap ) ;
}
2017-10-02 02:15:35 -04:00
/* Log a fatal error, and display a UI message before exiting. */
void
2017-12-04 11:59:26 -05:00
fatal ( const char * fmt , . . . )
2016-06-26 00:34:39 +02:00
{
2025-08-09 15:01:08 +02:00
char temp [ LOG_SIZE_BUFFER ] ;
2021-06-07 00:15:09 +02:00
va_list ap ;
2022-09-18 17:11:43 -04:00
char * sp ;
2017-10-02 02:15:35 -04:00
2021-06-07 00:15:09 +02:00
va_start ( ap , fmt ) ;
2017-11-23 17:42:00 -05:00
2021-06-07 00:15:09 +02:00
if ( stdlog = = NULL ) {
2022-09-18 17:11:43 -04:00
if ( log_path [ 0 ] ! = ' \0 ' ) {
stdlog = plat_fopen ( log_path , " w " ) ;
if ( stdlog = = NULL )
stdlog = stdout ;
} else
stdlog = stdout ;
2021-06-07 00:15:09 +02:00
}
2017-11-23 17:42:00 -05:00
2021-06-07 00:15:09 +02:00
vsprintf ( temp , fmt , ap ) ;
fprintf ( stdlog , " %s " , temp ) ;
fflush ( stdlog ) ;
va_end ( ap ) ;
2017-10-02 02:15:35 -04:00
2021-06-07 00:15:09 +02:00
nvr_save ( ) ;
2017-10-02 02:15:35 -04:00
2021-06-07 00:15:09 +02:00
config_save ( ) ;
2017-10-02 02:15:35 -04:00
2019-02-06 03:34:39 +01:00
# ifdef ENABLE_808X_LOG
2021-06-07 00:15:09 +02:00
dumpregs ( 1 ) ;
2019-02-06 03:34:39 +01:00
# endif
2016-06-26 00:34:39 +02:00
2021-06-07 00:15:09 +02:00
/* Make sure the message does not have a trailing newline. */
2022-09-18 17:11:43 -04:00
if ( ( sp = strchr ( temp , ' \n ' ) ) ! = NULL )
* sp = ' \0 ' ;
2021-06-07 00:15:09 +02:00
2024-06-26 23:09:55 +02:00
do_pause ( 2 ) ;
ui_msgbox ( MBX_ERROR | MBX_FATAL | MBX_ANSI , temp ) ;
2021-06-07 00:15:09 +02:00
/* Cleanly terminate all of the emulator's components so as
to avoid things like threads getting stuck . */
do_stop ( ) ;
fflush ( stdlog ) ;
exit ( - 1 ) ;
}
void
fatal_ex ( const char * fmt , va_list ap )
{
2025-08-09 15:01:08 +02:00
char temp [ LOG_SIZE_BUFFER ] ;
2021-06-07 00:15:09 +02:00
char * sp ;
if ( stdlog = = NULL ) {
2022-09-18 17:11:43 -04:00
if ( log_path [ 0 ] ! = ' \0 ' ) {
stdlog = plat_fopen ( log_path , " w " ) ;
if ( stdlog = = NULL )
stdlog = stdout ;
} else
stdlog = stdout ;
2021-06-07 00:15:09 +02:00
}
vsprintf ( temp , fmt , ap ) ;
fprintf ( stdlog , " %s " , temp ) ;
fflush ( stdlog ) ;
nvr_save ( ) ;
config_save ( ) ;
# ifdef ENABLE_808X_LOG
dumpregs ( 1 ) ;
# endif
2017-05-07 02:14:44 -04:00
2021-06-07 00:15:09 +02:00
/* Make sure the message does not have a trailing newline. */
2022-09-18 17:11:43 -04:00
if ( ( sp = strchr ( temp , ' \n ' ) ) ! = NULL )
* sp = ' \0 ' ;
2018-09-21 03:19:29 +02:00
2024-06-26 23:09:55 +02:00
do_pause ( 2 ) ;
ui_msgbox ( MBX_ERROR | MBX_FATAL | MBX_ANSI , temp ) ;
2021-06-07 00:15:09 +02:00
/* Cleanly terminate all of the emulator's components so as
to avoid things like threads getting stuck . */
do_stop ( ) ;
2016-06-26 00:34:39 +02:00
2021-06-07 00:15:09 +02:00
fflush ( stdlog ) ;
2016-06-26 00:34:39 +02:00
}
2025-03-22 00:49:20 +01:00
/* Log a warning error, and display a UI message without exiting. */
void
warning ( const char * fmt , . . . )
{
2025-08-09 15:01:08 +02:00
char temp [ LOG_SIZE_BUFFER ] ;
2025-03-22 00:49:20 +01:00
va_list ap ;
char * sp ;
va_start ( ap , fmt ) ;
if ( stdlog = = NULL ) {
if ( log_path [ 0 ] ! = ' \0 ' ) {
stdlog = plat_fopen ( log_path , " w " ) ;
if ( stdlog = = NULL )
stdlog = stdout ;
} else
stdlog = stdout ;
}
vsprintf ( temp , fmt , ap ) ;
fprintf ( stdlog , " %s " , temp ) ;
fflush ( stdlog ) ;
va_end ( ap ) ;
/* Make sure the message does not have a trailing newline. */
if ( ( sp = strchr ( temp , ' \n ' ) ) ! = NULL )
* sp = ' \0 ' ;
do_pause ( 2 ) ;
ui_msgbox ( MBX_ERROR | MBX_ANSI , temp ) ;
fflush ( stdlog ) ;
do_pause ( 0 ) ;
}
void
warning_ex ( const char * fmt , va_list ap )
{
2025-08-09 15:01:08 +02:00
char temp [ LOG_SIZE_BUFFER ] ;
2025-03-22 00:49:20 +01:00
char * sp ;
if ( stdlog = = NULL ) {
if ( log_path [ 0 ] ! = ' \0 ' ) {
stdlog = plat_fopen ( log_path , " w " ) ;
if ( stdlog = = NULL )
stdlog = stdout ;
} else
stdlog = stdout ;
}
vsprintf ( temp , fmt , ap ) ;
fprintf ( stdlog , " %s " , temp ) ;
fflush ( stdlog ) ;
/* Make sure the message does not have a trailing newline. */
if ( ( sp = strchr ( temp , ' \n ' ) ) ! = NULL )
* sp = ' \0 ' ;
do_pause ( 2 ) ;
ui_msgbox ( MBX_ERROR | MBX_ANSI , temp ) ;
fflush ( stdlog ) ;
do_pause ( 0 ) ;
}
2018-05-21 19:04:05 +02:00
# ifdef ENABLE_PC_LOG
int pc_do_log = ENABLE_PC_LOG ;
static void
2018-10-19 00:39:32 +02:00
pc_log ( const char * fmt , . . . )
2018-05-21 19:04:05 +02:00
{
2022-09-18 17:11:43 -04:00
va_list ap ;
2018-05-21 19:04:05 +02:00
2022-09-18 17:11:43 -04:00
if ( pc_do_log ) {
va_start ( ap , fmt ) ;
pclog_ex ( fmt , ap ) ;
va_end ( ap ) ;
}
2018-05-21 19:04:05 +02:00
}
2018-10-19 00:39:32 +02:00
# else
2022-09-18 17:11:43 -04:00
# define pc_log(fmt, ...)
2018-10-19 00:39:32 +02:00
# endif
2018-05-21 19:04:05 +02:00
2023-10-12 02:07:43 +02:00
static void
delete_nvr_file ( uint8_t flash )
{
char * fn = NULL ;
int c ;
/* Set up the NVR file's name. */
2025-02-13 00:45:10 +01:00
c = strlen ( machine_get_nvr_name ( ) ) + 5 ;
2023-10-12 02:07:43 +02:00
fn = ( char * ) malloc ( c + 1 ) ;
if ( fn = = NULL )
fatal ( " Error allocating memory for the removal of the %s file \n " ,
flash ? " BIOS flash " : " CMOS " ) ;
if ( flash )
2025-02-13 00:45:10 +01:00
sprintf ( fn , " %s.bin " , machine_get_nvr_name ( ) ) ;
2023-10-12 02:07:43 +02:00
else
2025-02-13 00:45:10 +01:00
sprintf ( fn , " %s.nvr " , machine_get_nvr_name ( ) ) ;
2023-10-12 02:07:43 +02:00
remove ( nvr_path ( fn ) ) ;
free ( fn ) ;
fn = NULL ;
}
2025-01-03 00:15:28 +01:00
extern void device_find_all_descs ( void ) ;
2025-04-27 17:52:53 +02:00
static void
pc_show_usage ( char * s )
{
2025-08-09 14:47:59 +02:00
char p [ 8192 ] = { 0 } ;
2025-04-27 17:52:53 +02:00
sprintf ( p ,
" \n %sUsage: 86box [options] [cfg-file] \n \n "
" Valid options are: \n \n "
" -? or --help \t \t \t - show this information \n "
2025-08-09 14:38:53 +02:00
# ifdef SHOW_EXTRA_PARAMS
2025-04-27 17:52:53 +02:00
" -C or --config path \t \t - set 'path' to be config file \n "
2025-08-09 14:38:53 +02:00
# endif
2025-04-27 17:52:53 +02:00
# ifdef _WIN32
" -D or --debug \t \t \t - force debug output logging \n "
# endif
2025-08-21 17:17:52 +02:00
# ifndef USE_SDL_UI
2024-06-08 13:25:09 -04:00
" -E or --vmmpath \t \t - vm manager path \n "
2025-04-27 17:52:53 +02:00
# endif
" -F or --fullscreen \t \t - start in fullscreen mode \n "
" -G or --lang langid \t \t - start with specified language \n "
" \t \t \t \t (e.g. en-US, or system) \n "
2025-08-09 14:46:38 +02:00
# ifdef SHOW_EXTRA_PARAMS
2025-04-27 17:52:53 +02:00
# ifdef _WIN32
" -H or --hwnd id,hwnd \t \t - sends back the main dialog's hwnd \n "
2025-08-09 14:46:38 +02:00
# endif
2025-04-27 17:52:53 +02:00
# endif
" -I or --image d:path \t \t - load 'path' as floppy image on drive d \n "
# ifdef USE_INSTRUMENT
" -J or --instrument name \t - set 'name' to be the profiling instrument \n "
# endif
2025-08-07 19:06:09 -03:00
" -L or --logfile path \t \t - set 'path' to be the logfile \n "
2025-04-27 17:52:53 +02:00
" -M or --missing \t \t - dump missing machines and video cards \n "
" -N or --noconfirm \t \t - do not ask for confirmation on quit \n "
" -P or --vmpath path \t \t - set 'path' to be root for vm \n "
2025-05-03 01:45:21 +02:00
" -O or --global path \t \t - set 'path' to be global config file \n "
2025-04-27 17:52:53 +02:00
" -R or --rompath path \t \t - set 'path' to be ROM path \n "
# ifndef USE_SDL_UI
" -S or --settings \t \t \t - show only the settings dialog \n "
# endif
2025-08-09 14:38:53 +02:00
# ifdef SHOW_EXTRA_PARAMS
2025-04-27 17:52:53 +02:00
" -T or --testmode \t \t - test mode: execute the test mode entry \n "
" \t \t \t \t point on init/hard reset \n "
2025-08-09 14:38:53 +02:00
# endif
2025-04-27 17:52:53 +02:00
" -V or --vmname name \t \t - overrides the name of the running VM \n "
2025-08-09 14:38:53 +02:00
# ifdef _WIN32
2025-04-27 17:52:53 +02:00
" -W or --nohook \t \t - disables keyboard hook \n "
2025-08-09 14:38:53 +02:00
# else
" -W or --nohook \t \t - alters keyboard behavior \n "
# endif
2025-04-27 17:52:53 +02:00
" -X or --clear what \t \t - clears the 'what' (cmos/flash/both) \n "
2025-08-09 14:38:53 +02:00
# ifdef SHOW_EXTRA_PARAMS
2025-04-27 17:52:53 +02:00
" -Y or --donothing \t \t - do not show any UI or run the emulation \n "
2025-08-09 14:38:53 +02:00
# endif
2025-08-09 14:44:14 +02:00
" -Z or --lastvmpath \t \t - the last param. is VM path rather than config \n "
2025-04-27 17:52:53 +02:00
" \n A config file can be specified. If none is, the default file will be used. \n " ,
2025-08-09 14:38:53 +02:00
s ) ;
2025-04-27 17:52:53 +02:00
2025-04-28 04:37:58 +02:00
# ifdef _WIN32
2025-04-27 17:52:53 +02:00
ui_msgbox ( MBX_ANSI | ( ( s = = NULL ) ? MBX_INFO : MBX_WARNING ) , p ) ;
2025-04-28 04:37:58 +02:00
# else
if ( s = = NULL )
2025-08-09 15:01:08 +02:00
always_log ( " %s " , p ) ;
2025-04-28 04:37:58 +02:00
else
ui_msgbox ( MBX_ANSI | MBX_WARNING , p ) ;
# endif
2025-04-27 17:52:53 +02:00
}
2017-10-02 02:15:35 -04:00
/*
* Perform initial startup of the PC .
*
* This is the platform - indepenent part of the startup ,
2017-10-24 22:10:21 -04:00
* where we check commandline arguments and load a
2017-10-02 02:15:35 -04:00
* configuration file .
*/
2017-10-07 00:46:54 -04:00
int
2021-03-14 20:35:01 +01:00
pc_init ( int argc , char * argv [ ] )
2016-06-26 00:34:39 +02:00
{
2023-07-20 18:58:26 -04:00
char * ppath = NULL ;
char * rpath = NULL ;
char * cfg = NULL ;
2025-05-03 01:45:21 +02:00
char * global = NULL ;
2023-07-20 18:58:26 -04:00
char * p ;
char temp [ 2048 ] ;
char * fn [ FDD_NUM ] = { NULL } ;
char drive = 0 ;
char * temp2 = NULL ;
2023-10-13 23:03:37 +02:00
char * what ;
2023-07-20 18:58:26 -04:00
const struct tm * info ;
time_t now ;
int c ;
int lvmp = 0 ;
2022-07-18 02:32:31 +02:00
# ifdef ENABLE_NG
2022-09-18 17:11:43 -04:00
int ng = 0 ;
2022-07-18 02:32:31 +02:00
# endif
2022-04-14 06:48:25 +05:00
# ifdef _WIN32
2023-05-11 03:02:36 -04:00
uint32_t * uid ;
uint32_t * shwnd ;
2022-04-14 06:48:25 +05:00
# endif
2025-04-17 21:52:32 +05:00
int lang_init = 0 ;
2022-02-19 23:52:47 -05:00
2022-09-18 17:11:43 -04:00
/* Grab the executable's full path. */
plat_get_exe_name ( exe_path , sizeof ( exe_path ) - 1 ) ;
p = path_get_filename ( exe_path ) ;
* p = ' \0 ' ;
2022-04-20 13:27:57 -03:00
# if defined(__APPLE__)
c = strlen ( exe_path ) ;
if ( ( c > = 16 ) & & ! strcmp ( & exe_path [ c - 16 ] , " /Contents/MacOS/ " ) ) {
exe_path [ c - 16 ] = ' \0 ' ;
2022-09-18 17:11:43 -04:00
p = path_get_filename ( exe_path ) ;
* p = ' \0 ' ;
2022-05-03 21:08:08 -03:00
}
if ( ! strncmp ( exe_path , " /private/var/folders/ " , 21 ) ) {
2022-05-22 22:39:27 -03:00
ui_msgbox_header ( MBX_FATAL , L " App Translocation " , EMU_NAME_W L " cannot determine the emulated machine's location due to a macOS security feature. Please move the " EMU_NAME_W L " app to another folder (not /Applications), or make a copy of it and open that copy instead. " ) ;
2023-05-29 01:30:51 -04:00
return 0 ;
2022-04-08 01:49:04 +02:00
}
2022-04-20 13:27:57 -03:00
# elif !defined(_WIN32)
/* Grab the actual path if we are an AppImage. */
p = getenv ( " APPIMAGE " ) ;
if ( p & & ( p [ 0 ] ! = ' \0 ' ) )
path_get_dirname ( exe_path , p ) ;
2022-04-08 01:49:04 +02:00
# endif
2022-09-18 17:11:43 -04:00
path_slash ( exe_path ) ;
2022-04-19 23:24:49 +02:00
2022-09-18 17:11:43 -04:00
/*
* Get the current working directory .
*
* This is normally the directory from where the
* program was run . If we have been started via
* a shortcut ( desktop icon ) , however , the CWD
* could have been set to something else .
*/
plat_getcwd ( usr_path , sizeof ( usr_path ) - 1 ) ;
plat_getcwd ( rom_path , sizeof ( rom_path ) - 1 ) ;
2022-02-19 23:52:47 -05:00
2022-09-18 17:11:43 -04:00
for ( c = 1 ; c < argc ; c + + ) {
if ( argv [ c ] [ 0 ] ! = ' - ' )
break ;
2017-10-11 17:45:46 -04:00
2022-09-18 17:11:43 -04:00
if ( ! strcasecmp ( argv [ c ] , " --help " ) | | ! strcasecmp ( argv [ c ] , " -? " ) ) {
2017-09-23 21:12:26 -04:00
usage :
2023-06-26 22:31:03 -04:00
for ( uint8_t i = 0 ; i < FDD_NUM ; i + + ) {
2022-10-31 03:24:09 +01:00
if ( fn [ i ] ! = NULL ) {
free ( fn [ i ] ) ;
fn [ i ] = NULL ;
}
}
2025-08-09 14:38:53 +02:00
pc_show_usage ( " " ) ;
2023-05-11 03:02:36 -04:00
return 0 ;
2022-09-18 17:11:43 -04:00
} else if ( ! strcasecmp ( argv [ c ] , " --lastvmpath " ) | | ! strcasecmp ( argv [ c ] , " -Z " ) ) {
lvmp = 1 ;
2017-11-23 17:42:00 -05:00
# ifdef _WIN32
2022-09-18 17:11:43 -04:00
} else if ( ! strcasecmp ( argv [ c ] , " --debug " ) | | ! strcasecmp ( argv [ c ] , " -D " ) ) {
force_debug = 1 ;
2017-11-23 17:42:00 -05:00
# endif
2025-08-21 17:17:52 +02:00
# ifndef USE_SDL_UI
2024-06-08 13:25:09 -04:00
} else if ( ! strcasecmp ( argv [ c ] , " --vmmpath " ) | |
! strcasecmp ( argv [ c ] , " -E " ) ) {
/* Using this variable for vm manager path
Temporary solution ! */
if ( ( c + 1 ) = = argc ) goto usage ;
2025-06-24 05:13:05 +02:00
char * vp = argv [ + + c ] ;
if ( ( strlen ( vp ) + 1 ) > = sizeof ( vmm_path ) )
memcpy ( vmm_path , vp , sizeof ( vmm_path ) ) ;
else
memcpy ( vmm_path , vp , strlen ( vp ) + 1 ) ;
2025-08-21 17:17:52 +02:00
# endif
2022-09-18 17:11:43 -04:00
} else if ( ! strcasecmp ( argv [ c ] , " --fullscreen " ) | | ! strcasecmp ( argv [ c ] , " -F " ) ) {
start_in_fullscreen = 1 ;
} else if ( ! strcasecmp ( argv [ c ] , " --logfile " ) | | ! strcasecmp ( argv [ c ] , " -L " ) ) {
if ( ( c + 1 ) = = argc )
goto usage ;
strcpy ( log_path , argv [ + + c ] ) ;
} else if ( ! strcasecmp ( argv [ c ] , " --vmpath " ) | | ! strcasecmp ( argv [ c ] , " -P " ) ) {
if ( ( c + 1 ) = = argc )
goto usage ;
ppath = argv [ + + c ] ;
2025-08-21 15:28:32 +02:00
start_vmm = 0 ;
2022-09-18 17:11:43 -04:00
} else if ( ! strcasecmp ( argv [ c ] , " --rompath " ) | | ! strcasecmp ( argv [ c ] , " -R " ) ) {
if ( ( c + 1 ) = = argc )
goto usage ;
rpath = argv [ + + c ] ;
rom_add_path ( rpath ) ;
} else if ( ! strcasecmp ( argv [ c ] , " --config " ) | | ! strcasecmp ( argv [ c ] , " -C " ) ) {
if ( ( c + 1 ) = = argc | | plat_dir_check ( argv [ c + 1 ] ) )
goto usage ;
cfg = argv [ + + c ] ;
2025-08-21 15:28:32 +02:00
start_vmm = 0 ;
2025-05-03 01:45:21 +02:00
} else if ( ! strcasecmp ( argv [ c ] , " --global " ) | | ! strcasecmp ( argv [ c ] , " -O " ) ) {
if ( ( c + 1 ) = = argc | | plat_dir_check ( argv [ c + 1 ] ) )
goto usage ;
global = argv [ + + c ] ;
2022-10-31 03:24:09 +01:00
} else if ( ! strcasecmp ( argv [ c ] , " --image " ) | | ! strcasecmp ( argv [ c ] , " -I " ) ) {
if ( ( c + 1 ) = = argc )
goto usage ;
temp2 = ( char * ) calloc ( 2048 , 1 ) ;
2025-06-28 23:02:10 -04:00
if ( sscanf ( argv [ + + c ] , " %c:%2047s " , & drive , temp2 ) ! = 2 ) {
fprintf ( stderr , " Invalid input format for --image option. \n " ) ;
free ( temp2 ) ;
goto usage ;
}
2022-10-31 03:24:09 +01:00
if ( drive > 0x40 )
drive = ( drive & 0x1f ) - 1 ;
else
drive = drive & 0x1f ;
if ( drive < 0 )
drive = 0 ;
if ( drive > = FDD_NUM )
drive = FDD_NUM - 1 ;
fn [ ( int ) drive ] = ( char * ) calloc ( 2048 , 1 ) ;
strcpy ( fn [ ( int ) drive ] , temp2 ) ;
pclog ( " Drive %c: %s \n " , drive + 0x41 , fn [ ( int ) drive ] ) ;
free ( temp2 ) ;
temp2 = NULL ;
2022-09-18 17:11:43 -04:00
} else if ( ! strcasecmp ( argv [ c ] , " --vmname " ) | | ! strcasecmp ( argv [ c ] , " -V " ) ) {
if ( ( c + 1 ) = = argc )
goto usage ;
strcpy ( vm_name , argv [ + + c ] ) ;
2023-12-28 11:45:53 +01:00
# ifndef USE_SDL_UI
2022-09-18 17:11:43 -04:00
} else if ( ! strcasecmp ( argv [ c ] , " --settings " ) | | ! strcasecmp ( argv [ c ] , " -S " ) ) {
settings_only = 1 ;
2023-12-28 11:45:53 +01:00
# endif
2025-02-13 05:10:55 +01:00
} else if ( ! strcasecmp ( argv [ c ] , " --testmode " ) | | ! strcasecmp ( argv [ c ] , " -T " ) ) {
test_mode = 1 ;
2022-09-18 17:11:43 -04:00
} else if ( ! strcasecmp ( argv [ c ] , " --noconfirm " ) | | ! strcasecmp ( argv [ c ] , " -N " ) ) {
confirm_exit_cmdl = 0 ;
2023-10-13 23:03:37 +02:00
} else if ( ! strcasecmp ( argv [ c ] , " --missing " ) | | ! strcasecmp ( argv [ c ] , " -M " ) ) {
2023-10-12 02:07:43 +02:00
dump_missing = 1 ;
} else if ( ! strcasecmp ( argv [ c ] , " --donothing " ) | | ! strcasecmp ( argv [ c ] , " -Y " ) ) {
do_nothing = 1 ;
2025-01-03 00:15:28 +01:00
} else if ( ! strcasecmp ( argv [ c ] , " --nohook " ) | | ! strcasecmp ( argv [ c ] , " -W " ) ) {
hook_enabled = 0 ;
2023-10-12 02:07:43 +02:00
} else if ( ! strcasecmp ( argv [ c ] , " --clearboth " ) | | ! strcasecmp ( argv [ c ] , " -X " ) ) {
2023-10-13 23:03:37 +02:00
if ( ( c + 1 ) = = argc )
goto usage ;
what = argv [ + + c ] ;
if ( ! strcasecmp ( what , " cmos " ) )
clear_cmos = 1 ;
else if ( ! strcasecmp ( what , " flash " ) )
clear_flash = 1 ;
else if ( ! strcasecmp ( what , " both " ) ) {
clear_cmos = 1 ;
clear_flash = 1 ;
} else
goto usage ;
2021-09-02 20:15:46 +02:00
# ifdef _WIN32
2022-09-18 17:11:43 -04:00
} else if ( ! strcasecmp ( argv [ c ] , " --hwnd " ) | | ! strcasecmp ( argv [ c ] , " -H " ) ) {
2021-03-14 20:35:01 +01:00
2022-09-18 17:11:43 -04:00
if ( ( c + 1 ) = = argc )
goto usage ;
2021-11-09 18:53:15 +01:00
2022-09-18 17:11:43 -04:00
uid = ( uint32_t * ) & unique_id ;
shwnd = ( uint32_t * ) & source_hwnd ;
sscanf ( argv [ + + c ] , " %08X%08X,%08X%08X " , uid + 1 , uid , shwnd + 1 , shwnd ) ;
2017-10-27 20:54:31 -04:00
# endif
2023-10-12 02:07:43 +02:00
} else if ( ! strcasecmp ( argv [ c ] , " --lang " ) | | ! strcasecmp ( argv [ c ] , " -G " ) ) {
2022-09-18 17:11:43 -04:00
// This function is currently unimplemented for *nix but has placeholders.
2021-11-09 18:53:15 +01:00
2022-09-18 17:11:43 -04:00
lang_init = plat_language_code ( argv [ + + c ] ) ;
if ( ! lang_init )
2025-08-09 15:01:08 +02:00
always_log ( " \n Warning: Invalid language code, ignoring --lang parameter. \n \n " ) ;
2021-11-09 18:53:15 +01:00
2022-09-18 17:11:43 -04:00
// The return value of 0 only means that the code is invalid,
// not related to that translation is exists or not for the
// selected language.
2023-10-12 02:07:43 +02:00
} else if ( ! strcasecmp ( argv [ c ] , " --test " ) | | ! strcasecmp ( argv [ c ] , " -T " ) ) {
2022-09-18 17:11:43 -04:00
/* some (undocumented) test function here.. */
2017-05-05 01:49:42 +02:00
2022-09-18 17:11:43 -04:00
/* .. and then exit. */
2023-05-11 03:02:36 -04:00
return 0 ;
2022-08-06 14:23:11 +02:00
# ifdef USE_INSTRUMENT
2023-10-12 02:07:43 +02:00
} else if ( ! strcasecmp ( argv [ c ] , " --instrument " ) | | ! strcasecmp ( argv [ c ] , " -J " ) ) {
2022-09-18 17:11:43 -04:00
if ( ( c + 1 ) = = argc )
goto usage ;
instru_enabled = 1 ;
sscanf ( argv [ + + c ] , " %llu " , & instru_run_ms ) ;
2022-08-06 14:23:11 +02:00
# endif
2022-09-18 17:11:43 -04:00
}
/* Uhm... out of options here.. */
else
goto usage ;
}
/* One argument (config file) allowed. */
if ( c < argc ) {
if ( lvmp )
ppath = argv [ c + + ] ;
else
cfg = argv [ c + + ] ;
2025-04-27 17:52:53 +02:00
2025-08-21 15:28:32 +02:00
start_vmm = 0 ;
2022-09-18 17:11:43 -04:00
}
if ( c ! = argc )
goto usage ;
path_slash ( usr_path ) ;
path_slash ( rom_path ) ;
/*
* If the user provided a path for files , use that
* instead of the current working directory . We do
* make sure that if that was a relative path , we
* make it absolute .
*/
if ( ppath ! = NULL ) {
if ( ! path_abs ( ppath ) ) {
/*
* This looks like a relative path .
*
* Add it to the current working directory
* to convert it ( back ) to an absolute path .
*/
strcat ( usr_path , ppath ) ;
} else {
/*
* The user - provided path seems like an
* absolute path , so just use that .
*/
strcpy ( usr_path , ppath ) ;
}
/* If the specified path does not yet exist,
create it . */
if ( ! plat_dir_check ( usr_path ) )
plat_dir_create ( usr_path ) ;
}
2018-07-15 01:41:53 +02:00
2022-04-08 01:33:49 +02:00
// Add the VM-local ROM path.
2022-04-19 23:06:39 +02:00
path_append_filename ( temp , usr_path , " roms " ) ;
2022-04-08 01:33:49 +02:00
rom_add_path ( temp ) ;
2022-04-05 02:16:23 +06:00
2022-04-08 01:33:49 +02:00
// Add the standard ROM path in the same directory as the executable.
2022-04-19 23:06:39 +02:00
path_append_filename ( temp , exe_path , " roms " ) ;
2022-04-08 01:33:49 +02:00
rom_add_path ( temp ) ;
2021-11-19 16:42:43 +01:00
2022-04-06 16:16:25 +06:00
plat_init_rom_paths ( ) ;
2021-09-02 23:26:24 +02:00
2022-09-18 17:11:43 -04:00
/*
* If the user provided a path for ROMs , use that
* instead of the current working directory . We do
* make sure that if that was a relative path , we
* make it absolute .
*/
if ( rpath ! = NULL ) {
if ( ! path_abs ( rpath ) ) {
/*
* This looks like a relative path .
*
* Add it to the current working directory
* to convert it ( back ) to an absolute path .
*/
strcat ( rom_path , rpath ) ;
} else {
/*
* The user - provided path seems like an
* absolute path , so just use that .
*/
strcpy ( rom_path , rpath ) ;
}
/* If the specified path does not yet exist,
create it . */
if ( ! plat_dir_check ( rom_path ) )
plat_dir_create ( rom_path ) ;
} else
rom_path [ 0 ] = ' \0 ' ;
/* Grab the name of the configuration file. */
if ( cfg = = NULL )
cfg = CONFIG_FILE ;
/*
* If the configuration file name has ( part of )
* a pathname , consider that to be part of the
* actual working directory .
*
* This can happen when people load a config
* file using the UI , for example .
*/
p = path_get_filename ( cfg ) ;
if ( cfg ! = p ) {
/*
* OK , the configuration file name has a
* path component . Separate the two , and
* add the path component to the cfg path .
*/
* ( p - 1 ) = ' \0 ' ;
/*
* If this is an absolute path , keep it , as
* there is probably have a reason to do so .
* Otherwise , assume the pathname given is
* relative to whatever the usr_path is .
*/
if ( path_abs ( cfg ) )
strcpy ( usr_path , cfg ) ;
else
strcat ( usr_path , cfg ) ;
}
/* Make sure we have a trailing backslash. */
path_slash ( usr_path ) ;
if ( rom_path [ 0 ] ! = ' \0 ' )
path_slash ( rom_path ) ;
/* At this point, we can safely create the full path name. */
path_append_filename ( cfg_path , usr_path , p ) ;
2025-05-03 01:45:21 +02:00
/* Build the global configuration file path. */
if ( global = = NULL ) {
plat_get_global_config_dir ( global_cfg_path , sizeof ( global_cfg_path ) ) ;
2025-08-16 18:57:07 +02:00
path_append_filename ( global_cfg_path , global_cfg_path , GLOBAL_CONFIG_FILE ) ;
2025-05-03 01:45:21 +02:00
} else {
strncpy ( global_cfg_path , global , sizeof ( global_cfg_path ) - 1 ) ;
}
2022-09-18 17:11:43 -04:00
/*
* Get the current directory ' s name
*
* At this point usr_path is perfectly initialized .
* If no - - vmname parameter specified we ' ll use the
* working directory name as the VM ' s name .
*/
if ( strlen ( vm_name ) = = 0 ) {
char ltemp [ 1024 ] = { ' \0 ' } ;
path_get_dirname ( ltemp , usr_path ) ;
strcpy ( vm_name , path_get_filename ( ltemp ) ) ;
}
/*
* This is where we start outputting to the log file ,
* if there is one . Create a little info header first .
*/
2025-06-28 23:02:10 -04:00
struct tm time_buf ;
2022-09-18 17:11:43 -04:00
( void ) time ( & now ) ;
2025-06-28 23:02:10 -04:00
# ifdef _WIN32
if ( localtime_s ( & time_buf , & now ) = = 0 )
info = & time_buf ;
# else
info = localtime_r ( & now , & time_buf ) ;
# endif
if ( info )
strftime ( temp , sizeof ( temp ) , " %Y/%m/%d %H:%M:%S " , info ) ;
else
strcpy ( temp , " unknown " ) ;
2022-09-18 17:11:43 -04:00
pclog ( " # \n # %ls v%ls logfile, created %s \n # \n " ,
EMU_NAME_W , EMU_VERSION_FULL_W , temp ) ;
2022-04-08 02:18:28 +02:00
2025-08-21 19:48:36 +02:00
pclog ( " # Emulator path: %s \n " , exe_path ) ;
2025-05-03 01:45:21 +02:00
pclog ( " # Global configuration file: %s \n " , global_cfg_path ) ;
2025-04-22 22:38:16 +02:00
2025-08-17 04:34:35 +05:00
/* Load the global configuration file. */
config_load_global ( ) ;
2025-08-21 20:01:18 +02:00
config_save_global ( ) ; // hack
2025-08-17 04:34:35 +05:00
2025-08-21 19:49:09 +02:00
/* Determine whether to start the VM manager. */
2025-08-21 17:17:52 +02:00
# ifndef USE_SDL_UI
if ( vmm_disabled )
# endif
{
2025-08-21 15:28:32 +02:00
start_vmm = 0 ;
}
2025-08-21 17:17:52 +02:00
# ifndef USE_SDL_UI
if ( strlen ( vmm_path ) ! = 0 ) {
/* -E specified on the command line. */
start_vmm = 1 ;
} else {
2025-08-21 17:41:23 +02:00
strncpy ( vmm_path , vmm_path_cfg , sizeof ( vmm_path ) - 1 ) ;
2025-08-21 17:17:52 +02:00
}
2025-08-21 19:48:36 +02:00
if ( start_vmm ) {
2025-08-21 17:17:52 +02:00
pclog ( " # VM Manager enabled. Path: %s \n " , vmm_path ) ;
2025-08-21 19:49:09 +02:00
strncpy ( usr_path , vmm_path , sizeof ( usr_path ) - 1 ) ;
2025-08-21 17:17:52 +02:00
} else
# endif
{
2025-08-21 19:48:36 +02:00
pclog ( " # VM: %s \n # \n " , vm_name ) ;
pclog ( " # Configuration file: %s \n # \n \n " , cfg_path ) ;
pclog ( " # Userfiles path: %s \n " , usr_path ) ;
for ( rom_path_t * rom_path = & rom_paths ; rom_path ! = NULL ; rom_path = rom_path - > next ) {
pclog ( " # ROM path: %s \n " , rom_path - > path ) ;
}
2025-07-27 04:24:02 +05:00
/*
* We are about to read the configuration file , which MAY
* put data into global variables ( the hard - and floppy
* disks are an example ) so we have to initialize those
* modules before we load the config . .
*/
hdd_init ( ) ;
network_init ( ) ;
mouse_init ( ) ;
cdrom_global_init ( ) ;
rdisk_global_init ( ) ;
mo_global_init ( ) ;
/* Initialize the keyboard accelerator list with default values */
for ( int x = 0 ; x < NUM_ACCELS ; x + + ) {
strcpy ( acc_keys [ x ] . name , def_acc_keys [ x ] . name ) ;
strcpy ( acc_keys [ x ] . desc , def_acc_keys [ x ] . desc ) ;
strcpy ( acc_keys [ x ] . seq , def_acc_keys [ x ] . seq ) ;
}
2022-09-18 17:11:43 -04:00
2025-07-27 04:24:02 +05:00
/* Load the configuration file. */
config_load ( ) ;
2023-10-12 02:07:43 +02:00
2025-07-27 04:24:02 +05:00
/* Clear the CMOS and/or BIOS flash file, if we were started with
the relevant parameter ( s ) . */
if ( clear_cmos ) {
delete_nvr_file ( 0 ) ;
clear_cmos = 0 ;
}
2023-10-12 02:07:43 +02:00
2025-07-27 04:24:02 +05:00
if ( clear_flash ) {
delete_nvr_file ( 1 ) ;
clear_flash = 0 ;
}
2023-10-12 02:07:43 +02:00
2025-07-27 04:24:02 +05:00
for ( uint8_t i = 0 ; i < FDD_NUM ; i + + ) {
if ( fn [ i ] ! = NULL ) {
if ( strlen ( fn [ i ] ) < = 511 )
strncpy ( floppyfns [ i ] , fn [ i ] , 511 ) ;
free ( fn [ i ] ) ;
fn [ i ] = NULL ;
}
2022-10-31 03:24:09 +01:00
}
}
2022-09-18 17:11:43 -04:00
/* Load the desired language */
if ( lang_init )
lang_id = lang_init ;
gdbstub_init ( ) ;
/* All good! */
2023-05-11 03:02:36 -04:00
return 1 ;
2017-10-02 02:15:35 -04:00
}
void
Added the IBM 5161 ISA expansion for PC and XT;
Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port;
Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX);
Finished the 586MC1;
Added 8087 emulation;
Moved Cyrix 6x86'es to the Dev branch;
Sanitized/cleaned up memregs.c/h and intel.c/h;
Split the chipsets from machines and sanitized Port 92 emulation;
Added support for the 15bpp mode to the Compaq ATI 28800;
Moved the MR 386DX and 486 machines to the Dev branch;
Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00;
Ported the new timer code from PCem;
Cleaned up the CPU table of unused stuff and better optimized its structure;
Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch;
Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem;
Added the AHA-1540A and the BusTek BT-542B;
Moved the Sumo SCSI-AT to the Dev branch;
Minor IDE, FDC, and floppy drive code clean-ups;
Made NCR 5380/53C400-based cards' BIOS address configurable;
Got rid of the legacy romset variable;
Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit;
Added the Amstead PPC512 per PCem patch by John Elliott;
Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages);
Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing;
Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem;
Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit;
Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement;
Amstrad MegaPC does now works correctly with non-internal graphics card;
The SLiRP code no longer casts a packed struct type to a non-packed struct type;
The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present;
The S3 Virge on BeOS is no longer broken (was broken by build #1591);
OS/2 2.0 build 6.167 now sees key presses again;
Xi8088 now work on CGA again;
86F images converted from either the old or new variants of the HxC MFM format now work correctly;
Hardware interrupts with a vector of 0xFF are now handled correctly;
OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct;
Fixed VNC keyboard input bugs;
Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver;
Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly;
Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4;
Compaq Portable now works with all graphics cards;
Fixed various MDSI Genius bugs;
Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly;
Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355;
OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400.
Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391.
Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389.
Fixed a minor IDE timing bug, fixes #388.
Fixed Toshiba T1000 RAM issues, fixes #379.
Fixed EGA/(S)VGA overscan border handling, fixes #378;
Got rid of the now long useless IDE channel 2 auto-removal, fixes #370;
Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366;
Ported the Unicode CD image file name fix from VARCem, fixes #365;
Fixed high density floppy disks on the Xi8088, fixes #359;
Fixed some bugs in the Hercules emulation, fixes #346, fixes #358;
Fixed the SCSI hard disk mode sense pages, fixes #356;
Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349;
Fixed bugs in the serial mouse emulation, fixes #344;
Compiled 86Box binaries now include all the required .DLL's, fixes #341;
Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
pc_speed_changed ( void )
2017-10-02 02:15:35 -04:00
{
2022-09-18 17:11:43 -04:00
if ( cpu_s - > cpu_type > = CPU_286 )
pit_set_clock ( cpu_s - > rspeed ) ;
else
2023-10-13 15:34:00 -04:00
pit_set_clock ( ( uint32_t ) 14318184.0 ) ;
2017-05-29 01:18:32 +02:00
}
2017-10-02 02:15:35 -04:00
void
Added the IBM 5161 ISA expansion for PC and XT;
Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port;
Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX);
Finished the 586MC1;
Added 8087 emulation;
Moved Cyrix 6x86'es to the Dev branch;
Sanitized/cleaned up memregs.c/h and intel.c/h;
Split the chipsets from machines and sanitized Port 92 emulation;
Added support for the 15bpp mode to the Compaq ATI 28800;
Moved the MR 386DX and 486 machines to the Dev branch;
Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00;
Ported the new timer code from PCem;
Cleaned up the CPU table of unused stuff and better optimized its structure;
Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch;
Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem;
Added the AHA-1540A and the BusTek BT-542B;
Moved the Sumo SCSI-AT to the Dev branch;
Minor IDE, FDC, and floppy drive code clean-ups;
Made NCR 5380/53C400-based cards' BIOS address configurable;
Got rid of the legacy romset variable;
Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit;
Added the Amstead PPC512 per PCem patch by John Elliott;
Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages);
Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing;
Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem;
Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit;
Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement;
Amstrad MegaPC does now works correctly with non-internal graphics card;
The SLiRP code no longer casts a packed struct type to a non-packed struct type;
The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present;
The S3 Virge on BeOS is no longer broken (was broken by build #1591);
OS/2 2.0 build 6.167 now sees key presses again;
Xi8088 now work on CGA again;
86F images converted from either the old or new variants of the HxC MFM format now work correctly;
Hardware interrupts with a vector of 0xFF are now handled correctly;
OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct;
Fixed VNC keyboard input bugs;
Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver;
Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly;
Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4;
Compaq Portable now works with all graphics cards;
Fixed various MDSI Genius bugs;
Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly;
Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355;
OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400.
Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391.
Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389.
Fixed a minor IDE timing bug, fixes #388.
Fixed Toshiba T1000 RAM issues, fixes #379.
Fixed EGA/(S)VGA overscan border handling, fixes #378;
Got rid of the now long useless IDE channel 2 auto-removal, fixes #370;
Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366;
Ported the Unicode CD image file name fix from VARCem, fixes #365;
Fixed high density floppy disks on the Xi8088, fixes #359;
Fixed some bugs in the Hercules emulation, fixes #346, fixes #358;
Fixed the SCSI hard disk mode sense pages, fixes #356;
Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349;
Fixed bugs in the serial mouse emulation, fixes #344;
Compiled 86Box binaries now include all the required .DLL's, fixes #341;
Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
pc_full_speed ( void )
2017-05-29 01:18:32 +02:00
{
2022-09-18 17:11:43 -04:00
if ( ! atfullspeed ) {
2022-09-13 14:32:16 +02:00
pc_log ( " Set fullspeed - %i %i \n " , is386 , is486 ) ;
2022-09-18 17:11:43 -04:00
pc_speed_changed ( ) ;
}
atfullspeed = 1 ;
2017-10-02 02:15:35 -04:00
}
2017-05-29 01:18:32 +02:00
2017-10-02 02:15:35 -04:00
/* Initialize modules, ran once, after pc_init. */
2017-10-07 00:46:54 -04:00
int
2025-08-14 07:04:51 +05:00
pc_init_roms ( void )
2017-10-02 02:15:35 -04:00
{
2023-05-11 03:02:36 -04:00
int c ;
int m ;
2022-09-18 17:11:43 -04:00
char tempc [ 512 ] ;
2017-10-07 00:46:54 -04:00
2023-10-12 02:07:43 +02:00
if ( dump_missing ) {
dump_missing = 0 ;
2022-09-18 17:11:43 -04:00
2023-10-12 02:07:43 +02:00
c = m = 0 ;
while ( machine_get_internal_name_ex ( c ) ! = NULL ) {
m = machine_available ( c ) ;
if ( ! m )
pclog ( " Missing machine: %s \n " , machine_getname_ex ( c ) ) ;
c + + ;
}
c = m = 0 ;
while ( video_get_internal_name ( c ) ! = NULL ) {
memset ( tempc , 0 , sizeof ( tempc ) ) ;
device_get_name ( video_card_getdevice ( c ) , 0 , tempc ) ;
if ( ( c > 1 ) & & ! ( tempc [ 0 ] ) )
break ;
m = video_card_available ( c ) ;
if ( ! m )
pclog ( " Missing video card: %s \n " , tempc ) ;
c + + ;
}
2022-09-18 17:11:43 -04:00
}
2021-10-09 17:37:09 +02:00
2022-09-18 17:11:43 -04:00
pc_log ( " Scanning for ROM images: \n " ) ;
c = m = 0 ;
while ( machine_get_internal_name_ex ( m ) ! = NULL ) {
c + = machine_available ( m ) ;
m + + ;
}
if ( c = = 0 ) {
/* No usable ROMs found, aborting. */
2023-05-11 03:02:36 -04:00
return 0 ;
2022-09-18 17:11:43 -04:00
}
pc_log ( " A total of %d ROM sets have been loaded. \n " , c ) ;
2025-08-14 07:04:51 +05:00
return 1 ;
}
int
pc_init_modules ( void )
{
int c ;
wchar_t temp [ 512 ] ;
char tempc [ 512 ] ;
2022-09-18 17:11:43 -04:00
/* Load the ROMs for the selected machine. */
if ( ! machine_available ( machine ) ) {
2024-03-19 14:27:19 +05:00
swprintf ( temp , sizeof_w ( temp ) , plat_get_string ( STRING_HW_NOT_AVAILABLE_MACHINE ) , machine_getname ( ) ) ;
2022-09-18 17:11:43 -04:00
c = 0 ;
machine = - 1 ;
while ( machine_get_internal_name_ex ( c ) ! = NULL ) {
if ( machine_available ( c ) ) {
2024-03-19 14:27:19 +05:00
ui_msgbox_header ( MBX_INFO , plat_get_string ( STRING_HW_NOT_AVAILABLE_TITLE ) , temp ) ;
2022-09-18 17:11:43 -04:00
machine = c ;
config_save ( ) ;
break ;
}
c + + ;
}
if ( machine = = - 1 ) {
fatal ( " No available machines \n " ) ;
exit ( - 1 ) ;
}
}
/* Make sure we have a usable video card. */
2023-02-06 04:12:46 -05:00
if ( ! video_card_available ( gfxcard [ 0 ] ) ) {
2022-09-18 17:11:43 -04:00
memset ( tempc , 0 , sizeof ( tempc ) ) ;
2023-02-06 04:12:46 -05:00
device_get_name ( video_card_getdevice ( gfxcard [ 0 ] ) , 0 , tempc ) ;
2024-03-19 14:27:19 +05:00
swprintf ( temp , sizeof_w ( temp ) , plat_get_string ( STRING_HW_NOT_AVAILABLE_VIDEO ) , tempc ) ;
2022-09-18 17:11:43 -04:00
c = 0 ;
while ( video_get_internal_name ( c ) ! = NULL ) {
2023-02-06 04:12:46 -05:00
gfxcard [ 0 ] = - 1 ;
2022-09-18 17:11:43 -04:00
if ( video_card_available ( c ) ) {
2024-03-19 14:27:19 +05:00
ui_msgbox_header ( MBX_INFO , plat_get_string ( STRING_HW_NOT_AVAILABLE_TITLE ) , temp ) ;
2023-02-06 04:12:46 -05:00
gfxcard [ 0 ] = c ;
2022-09-18 17:11:43 -04:00
config_save ( ) ;
break ;
}
c + + ;
}
2023-02-06 04:12:46 -05:00
if ( gfxcard [ 0 ] = = - 1 ) {
2022-09-18 17:11:43 -04:00
fatal ( " No available video cards \n " ) ;
exit ( - 1 ) ;
}
}
2024-06-29 19:43:42 -04:00
// TODO
for ( uint8_t i = 1 ; i < GFXCARD_MAX ; i + + ) {
if ( ! video_card_available ( gfxcard [ i ] ) ) {
char tempc [ 512 ] = { 0 } ;
device_get_name ( video_card_getdevice ( gfxcard [ i ] ) , 0 , tempc ) ;
swprintf ( temp , sizeof_w ( temp ) , plat_get_string ( STRING_HW_NOT_AVAILABLE_VIDEO2 ) , tempc ) ;
ui_msgbox_header ( MBX_INFO , plat_get_string ( STRING_HW_NOT_AVAILABLE_TITLE ) , temp ) ;
gfxcard [ i ] = 0 ;
}
2022-07-10 13:35:09 +06:00
}
2022-09-18 17:11:43 -04:00
atfullspeed = 0 ;
2017-10-02 02:15:35 -04:00
2022-09-18 17:11:43 -04:00
random_init ( ) ;
2017-10-01 16:29:15 -04:00
2022-09-18 17:11:43 -04:00
mem_init ( ) ;
2017-10-03 05:33:31 +02:00
2017-10-15 02:43:13 +02:00
# ifdef USE_DYNAREC
2022-09-18 17:11:43 -04:00
# if defined(__APPLE__) && defined(__aarch64__)
2023-08-09 07:37:45 -04:00
if ( __builtin_available ( macOS 11.0 , * ) ) {
pthread_jit_write_protect_np ( 0 ) ;
}
2022-09-18 17:11:43 -04:00
# endif
codegen_init ( ) ;
# if defined(__APPLE__) && defined(__aarch64__)
2023-08-09 07:37:45 -04:00
if ( __builtin_available ( macOS 11.0 , * ) ) {
pthread_jit_write_protect_np ( 1 ) ;
}
2022-09-18 17:11:43 -04:00
# endif
2017-10-15 02:43:13 +02:00
# endif
2017-10-03 05:33:31 +02:00
2022-09-18 17:11:43 -04:00
keyboard_init ( ) ;
joystick_init ( ) ;
2018-03-19 04:19:19 +01:00
2022-09-18 17:11:43 -04:00
video_init ( ) ;
2017-01-16 01:49:19 +01:00
2022-09-18 17:11:43 -04:00
fdd_init ( ) ;
2017-01-16 01:49:19 +01:00
2022-09-18 17:11:43 -04:00
sound_init ( ) ;
2017-10-01 16:29:15 -04:00
2022-09-18 17:11:43 -04:00
hdc_init ( ) ;
2017-01-16 01:49:19 +01:00
2022-09-18 17:11:43 -04:00
video_reset_close ( ) ;
Added the IBM 5161 ISA expansion for PC and XT;
Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port;
Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX);
Finished the 586MC1;
Added 8087 emulation;
Moved Cyrix 6x86'es to the Dev branch;
Sanitized/cleaned up memregs.c/h and intel.c/h;
Split the chipsets from machines and sanitized Port 92 emulation;
Added support for the 15bpp mode to the Compaq ATI 28800;
Moved the MR 386DX and 486 machines to the Dev branch;
Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00;
Ported the new timer code from PCem;
Cleaned up the CPU table of unused stuff and better optimized its structure;
Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch;
Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem;
Added the AHA-1540A and the BusTek BT-542B;
Moved the Sumo SCSI-AT to the Dev branch;
Minor IDE, FDC, and floppy drive code clean-ups;
Made NCR 5380/53C400-based cards' BIOS address configurable;
Got rid of the legacy romset variable;
Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit;
Added the Amstead PPC512 per PCem patch by John Elliott;
Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages);
Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing;
Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem;
Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit;
Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement;
Amstrad MegaPC does now works correctly with non-internal graphics card;
The SLiRP code no longer casts a packed struct type to a non-packed struct type;
The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present;
The S3 Virge on BeOS is no longer broken (was broken by build #1591);
OS/2 2.0 build 6.167 now sees key presses again;
Xi8088 now work on CGA again;
86F images converted from either the old or new variants of the HxC MFM format now work correctly;
Hardware interrupts with a vector of 0xFF are now handled correctly;
OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct;
Fixed VNC keyboard input bugs;
Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver;
Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly;
Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4;
Compaq Portable now works with all graphics cards;
Fixed various MDSI Genius bugs;
Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly;
Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355;
OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400.
Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391.
Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389.
Fixed a minor IDE timing bug, fixes #388.
Fixed Toshiba T1000 RAM issues, fixes #379.
Fixed EGA/(S)VGA overscan border handling, fixes #378;
Got rid of the now long useless IDE channel 2 auto-removal, fixes #370;
Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366;
Ported the Unicode CD image file name fix from VARCem, fixes #365;
Fixed high density floppy disks on the Xi8088, fixes #359;
Fixed some bugs in the Hercules emulation, fixes #346, fixes #358;
Fixed the SCSI hard disk mode sense pages, fixes #356;
Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349;
Fixed bugs in the serial mouse emulation, fixes #344;
Compiled 86Box binaries now include all the required .DLL's, fixes #341;
Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
2022-09-18 17:11:43 -04:00
machine_status_init ( ) ;
2022-07-13 01:04:01 +02:00
2025-08-02 14:51:28 +02:00
serial_set_next_inst ( 0 ) ;
lpt_set_3bc_used ( 0 ) ;
lpt_set_next_inst ( 0 ) ;
2025-03-20 21:52:48 +06:00
for ( c = 0 ; c < = 0x7ff ; c + + ) {
int64_t exp = c - 1023 ; /* 1023 = BIAS64 */
exp_pow_table [ c ] = pow ( 2.0 , ( double ) exp ) ;
}
2023-10-12 02:07:43 +02:00
if ( do_nothing ) {
do_nothing = 0 ;
exit ( - 1 ) ;
}
2023-05-11 03:02:36 -04:00
return 1 ;
2016-06-26 00:34:39 +02:00
}
2017-10-02 02:15:35 -04:00
void
2020-12-28 14:06:16 +01:00
pc_send_ca ( uint16_t sc )
2016-06-26 00:34:39 +02:00
{
2025-02-22 22:02:44 +09:00
if ( keyboard_mode > = 0x81 ) {
/* Use R-Alt because PS/55 DOS and OS/2 assign L-Alt Kanji */
2025-02-15 17:36:00 +09:00
keyboard_input ( 1 , 0x1D ) ; /* Ctrl key pressed */
2025-05-10 14:25:29 +02:00
if ( keyboard_get_in_reset ( ) )
return ;
2025-02-15 17:36:00 +09:00
keyboard_input ( 1 , 0x138 ) ; /* R-Alt key pressed */
2025-05-10 14:25:29 +02:00
if ( keyboard_get_in_reset ( ) )
return ;
2025-02-15 17:36:00 +09:00
keyboard_input ( 1 , sc ) ;
2025-05-10 14:25:29 +02:00
if ( keyboard_get_in_reset ( ) )
return ;
2025-02-15 17:36:00 +09:00
usleep ( 50000 ) ;
2025-05-10 14:25:29 +02:00
if ( keyboard_get_in_reset ( ) )
return ;
2025-02-15 17:36:00 +09:00
keyboard_input ( 0 , sc ) ;
2025-05-10 14:25:29 +02:00
if ( keyboard_get_in_reset ( ) )
return ;
2025-02-15 17:36:00 +09:00
keyboard_input ( 0 , 0x138 ) ; /* R-Alt key released */
2025-05-10 14:25:29 +02:00
if ( keyboard_get_in_reset ( ) )
return ;
2025-02-15 17:36:00 +09:00
keyboard_input ( 0 , 0x1D ) ; /* Ctrl key released */
2025-05-10 14:25:29 +02:00
if ( keyboard_get_in_reset ( ) )
return ;
2025-02-15 17:36:00 +09:00
} else {
keyboard_input ( 1 , 0x1D ) ; /* Ctrl key pressed */
2025-05-10 14:25:29 +02:00
if ( keyboard_get_in_reset ( ) )
return ;
2025-02-15 17:36:00 +09:00
keyboard_input ( 1 , 0x38 ) ; /* Alt key pressed */
2025-05-10 14:25:29 +02:00
if ( keyboard_get_in_reset ( ) )
return ;
2025-02-15 17:36:00 +09:00
keyboard_input ( 1 , sc ) ;
2025-05-10 14:25:29 +02:00
if ( keyboard_get_in_reset ( ) )
return ;
2025-02-15 17:36:00 +09:00
usleep ( 50000 ) ;
2025-05-10 14:25:29 +02:00
if ( keyboard_get_in_reset ( ) )
return ;
2025-02-15 17:36:00 +09:00
keyboard_input ( 0 , sc ) ;
2025-05-10 14:25:29 +02:00
if ( keyboard_get_in_reset ( ) )
return ;
2025-02-15 17:36:00 +09:00
keyboard_input ( 0 , 0x38 ) ; /* Alt key released */
2025-05-10 14:25:29 +02:00
if ( keyboard_get_in_reset ( ) )
return ;
2025-02-15 17:36:00 +09:00
keyboard_input ( 0 , 0x1D ) ; /* Ctrl key released */
2025-05-10 14:25:29 +02:00
if ( keyboard_get_in_reset ( ) )
return ;
2025-02-15 17:36:00 +09:00
}
2016-06-26 00:34:39 +02:00
}
2018-04-25 23:51:13 +02:00
/* Send the machine a Control-Alt-DEL sequence. */
2017-10-02 02:15:35 -04:00
void
2018-04-25 23:51:13 +02:00
pc_send_cad ( void )
2017-07-16 22:07:06 +02:00
{
2022-09-18 17:11:43 -04:00
pc_send_ca ( 0x153 ) ;
2017-07-16 22:07:06 +02:00
}
2018-04-25 23:51:13 +02:00
/* Send the machine a Control-Alt-ESC sequence. */
2017-11-01 01:51:19 -05:00
void
2018-04-25 23:51:13 +02:00
pc_send_cae ( void )
2017-11-01 01:51:19 -05:00
{
2023-10-29 03:20:25 +01:00
pc_send_ca ( 1 ) ;
2017-11-01 01:51:19 -05:00
}
2025-02-13 05:10:55 +01:00
/*
Currently available API :
2025-02-13 05:27:10 +01:00
extern void resetx86 ( void ) ;
extern void softresetx86 ( void ) ;
extern void hardresetx86 ( void ) ;
2025-02-13 05:10:55 +01:00
extern void prefetch_queue_set_pos ( int pos ) ;
extern void prefetch_queue_set_ip ( uint16_t ip ) ;
extern void prefetch_queue_set_prefetching ( int p ) ;
extern int prefetch_queue_get_pos ( void ) ;
extern uint16_t prefetch_queue_get_ip ( void ) ;
extern int prefetch_queue_get_prefetching ( void ) ;
extern int prefetch_queue_get_size ( void ) ;
*/
static void
pc_test_mode_entry_point ( void )
{
pclog ( " Test mode entry point \n ===================== \n " ) ;
}
2017-10-02 02:15:35 -04:00
void
2017-10-07 00:46:54 -04:00
pc_reset_hard_close ( void )
2016-06-26 00:34:39 +02:00
{
2022-09-18 17:11:43 -04:00
ui_sb_set_ready ( 0 ) ;
2018-10-19 19:10:12 +02:00
2022-09-18 17:11:43 -04:00
/* Close all the memory mappings. */
mem_close ( ) ;
PIC rewrite, proper SMRAM API, complete SiS 471 rewrite and addition of 40x, 460, and 461, changes to mem.c/h, disabled Voodoo memory dumping on exit, bumped SDL Hardware scale quality to 2, bumped IDE/ATAPI drives to ATA-6, finally bumped emulator version to 3.0, redid the bus type ID's to allow for planned ATAPI hard disks, made SST flash set its high mappings to the correct address if the CPU is 16-bit, and added the SiS 401 AMI 486 Clone, AOpen Vi15G, and the Soyo 4SA2 (486 with SiS 496/497 that can boot from CD-ROM), assorted 286+ protected mode fixes (for slightly more accuracy), and fixes to 808x emulation (MS Word 1.0 and 1.10 for DOS now work correctly from floppy).
2020-10-14 23:15:01 +02:00
2024-05-03 17:02:13 +02:00
suppress_overscan = 0 ;
2022-09-18 17:11:43 -04:00
/* Turn off timer processing to avoid potential segmentation faults. */
timer_close ( ) ;
Added the IBM 5161 ISA expansion for PC and XT;
Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port;
Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX);
Finished the 586MC1;
Added 8087 emulation;
Moved Cyrix 6x86'es to the Dev branch;
Sanitized/cleaned up memregs.c/h and intel.c/h;
Split the chipsets from machines and sanitized Port 92 emulation;
Added support for the 15bpp mode to the Compaq ATI 28800;
Moved the MR 386DX and 486 machines to the Dev branch;
Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00;
Ported the new timer code from PCem;
Cleaned up the CPU table of unused stuff and better optimized its structure;
Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch;
Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem;
Added the AHA-1540A and the BusTek BT-542B;
Moved the Sumo SCSI-AT to the Dev branch;
Minor IDE, FDC, and floppy drive code clean-ups;
Made NCR 5380/53C400-based cards' BIOS address configurable;
Got rid of the legacy romset variable;
Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit;
Added the Amstead PPC512 per PCem patch by John Elliott;
Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages);
Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing;
Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem;
Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit;
Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement;
Amstrad MegaPC does now works correctly with non-internal graphics card;
The SLiRP code no longer casts a packed struct type to a non-packed struct type;
The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present;
The S3 Virge on BeOS is no longer broken (was broken by build #1591);
OS/2 2.0 build 6.167 now sees key presses again;
Xi8088 now work on CGA again;
86F images converted from either the old or new variants of the HxC MFM format now work correctly;
Hardware interrupts with a vector of 0xFF are now handled correctly;
OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct;
Fixed VNC keyboard input bugs;
Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver;
Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly;
Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4;
Compaq Portable now works with all graphics cards;
Fixed various MDSI Genius bugs;
Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly;
Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355;
OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400.
Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391.
Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389.
Fixed a minor IDE timing bug, fixes #388.
Fixed Toshiba T1000 RAM issues, fixes #379.
Fixed EGA/(S)VGA overscan border handling, fixes #378;
Got rid of the now long useless IDE channel 2 auto-removal, fixes #370;
Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366;
Ported the Unicode CD image file name fix from VARCem, fixes #365;
Fixed high density floppy disks on the Xi8088, fixes #359;
Fixed some bugs in the Hercules emulation, fixes #346, fixes #358;
Fixed the SCSI hard disk mode sense pages, fixes #356;
Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349;
Fixed bugs in the serial mouse emulation, fixes #344;
Compiled 86Box binaries now include all the required .DLL's, fixes #341;
Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
2024-05-03 17:02:13 +02:00
lpt_devices_close ( ) ;
2022-09-18 17:11:43 -04:00
nvr_save ( ) ;
nvr_close ( ) ;
2017-11-23 17:42:00 -05:00
2022-09-18 17:11:43 -04:00
mouse_close ( ) ;
2018-01-29 01:19:49 +01:00
2022-09-18 17:11:43 -04:00
device_close_all ( ) ;
2017-11-23 17:42:00 -05:00
2022-09-18 17:11:43 -04:00
scsi_device_close_all ( ) ;
2018-10-30 13:32:25 +01:00
2022-09-18 17:11:43 -04:00
midi_out_close ( ) ;
2022-03-13 09:00:03 -04:00
2022-09-18 17:11:43 -04:00
midi_in_close ( ) ;
2017-12-04 11:59:26 -05:00
2022-09-18 17:11:43 -04:00
cdrom_close ( ) ;
2018-04-25 23:51:13 +02:00
2025-07-25 16:30:40 +02:00
rdisk_close ( ) ;
2018-10-10 22:33:24 +02:00
2022-09-18 17:11:43 -04:00
mo_close ( ) ;
2020-07-15 09:03:45 +08:00
2022-09-18 17:11:43 -04:00
scsi_disk_close ( ) ;
2018-10-10 22:33:24 +02:00
2022-09-18 17:11:43 -04:00
closeal ( ) ;
Added the IBM 5161 ISA expansion for PC and XT;
Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port;
Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX);
Finished the 586MC1;
Added 8087 emulation;
Moved Cyrix 6x86'es to the Dev branch;
Sanitized/cleaned up memregs.c/h and intel.c/h;
Split the chipsets from machines and sanitized Port 92 emulation;
Added support for the 15bpp mode to the Compaq ATI 28800;
Moved the MR 386DX and 486 machines to the Dev branch;
Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00;
Ported the new timer code from PCem;
Cleaned up the CPU table of unused stuff and better optimized its structure;
Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch;
Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem;
Added the AHA-1540A and the BusTek BT-542B;
Moved the Sumo SCSI-AT to the Dev branch;
Minor IDE, FDC, and floppy drive code clean-ups;
Made NCR 5380/53C400-based cards' BIOS address configurable;
Got rid of the legacy romset variable;
Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit;
Added the Amstead PPC512 per PCem patch by John Elliott;
Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages);
Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing;
Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem;
Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit;
Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement;
Amstrad MegaPC does now works correctly with non-internal graphics card;
The SLiRP code no longer casts a packed struct type to a non-packed struct type;
The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present;
The S3 Virge on BeOS is no longer broken (was broken by build #1591);
OS/2 2.0 build 6.167 now sees key presses again;
Xi8088 now work on CGA again;
86F images converted from either the old or new variants of the HxC MFM format now work correctly;
Hardware interrupts with a vector of 0xFF are now handled correctly;
OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct;
Fixed VNC keyboard input bugs;
Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver;
Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly;
Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4;
Compaq Portable now works with all graphics cards;
Fixed various MDSI Genius bugs;
Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly;
Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355;
OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400.
Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391.
Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389.
Fixed a minor IDE timing bug, fixes #388.
Fixed Toshiba T1000 RAM issues, fixes #379.
Fixed EGA/(S)VGA overscan border handling, fixes #378;
Got rid of the now long useless IDE channel 2 auto-removal, fixes #370;
Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366;
Ported the Unicode CD image file name fix from VARCem, fixes #365;
Fixed high density floppy disks on the Xi8088, fixes #359;
Fixed some bugs in the Hercules emulation, fixes #346, fixes #358;
Fixed the SCSI hard disk mode sense pages, fixes #356;
Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349;
Fixed bugs in the serial mouse emulation, fixes #344;
Compiled 86Box binaries now include all the required .DLL's, fixes #341;
Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
2022-09-18 17:11:43 -04:00
video_reset_close ( ) ;
2021-04-22 04:27:50 +02:00
2022-09-18 17:11:43 -04:00
cpu_close ( ) ;
2022-10-23 05:13:46 +02:00
serial_set_next_inst ( 0 ) ;
2025-08-02 14:51:28 +02:00
lpt_set_3bc_used ( 0 ) ;
lpt_set_next_inst ( 0 ) ;
2017-06-19 06:46:08 +02:00
}
2017-10-07 00:46:54 -04:00
/*
* This is basically the spot where we start up the actual machine ,
* by issuing a ' hard reset ' to the entire configuration . Order is
* somewhat important here . Functions here should be named _reset
* really , as that is what they do .
*/
2017-10-02 02:15:35 -04:00
void
2017-10-07 00:46:54 -04:00
pc_reset_hard_init ( void )
2017-06-19 06:46:08 +02:00
{
2022-09-18 17:11:43 -04:00
/*
* First , we reset the modules that are not part of
* the actual machine , but which support some of the
* modules that are .
*/
2021-03-25 02:41:57 -05:00
2025-03-27 19:14:01 +01:00
keyboard_init ( ) ;
2024-05-03 17:02:13 +02:00
/* Reset the IDE and SCSI presences */
other_ide_present = other_scsi_present = 0 ;
2023-02-06 01:39:34 +06:00
/* Mark ACPI as unavailable */
acpi_enabled = 0 ;
2022-09-18 17:11:43 -04:00
/* Reset the general machine support modules. */
io_init ( ) ;
2021-03-24 19:52:44 +01:00
2022-09-18 17:11:43 -04:00
/* Turn on and (re)initialize timer processing. */
timer_init ( ) ;
2017-06-22 18:32:53 +02:00
2022-09-18 17:11:43 -04:00
device_init ( ) ;
Added the IBM 5161 ISA expansion for PC and XT;
Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port;
Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX);
Finished the 586MC1;
Added 8087 emulation;
Moved Cyrix 6x86'es to the Dev branch;
Sanitized/cleaned up memregs.c/h and intel.c/h;
Split the chipsets from machines and sanitized Port 92 emulation;
Added support for the 15bpp mode to the Compaq ATI 28800;
Moved the MR 386DX and 486 machines to the Dev branch;
Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00;
Ported the new timer code from PCem;
Cleaned up the CPU table of unused stuff and better optimized its structure;
Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch;
Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem;
Added the AHA-1540A and the BusTek BT-542B;
Moved the Sumo SCSI-AT to the Dev branch;
Minor IDE, FDC, and floppy drive code clean-ups;
Made NCR 5380/53C400-based cards' BIOS address configurable;
Got rid of the legacy romset variable;
Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit;
Added the Amstead PPC512 per PCem patch by John Elliott;
Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages);
Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing;
Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem;
Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit;
Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement;
Amstrad MegaPC does now works correctly with non-internal graphics card;
The SLiRP code no longer casts a packed struct type to a non-packed struct type;
The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present;
The S3 Virge on BeOS is no longer broken (was broken by build #1591);
OS/2 2.0 build 6.167 now sees key presses again;
Xi8088 now work on CGA again;
86F images converted from either the old or new variants of the HxC MFM format now work correctly;
Hardware interrupts with a vector of 0xFF are now handled correctly;
OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct;
Fixed VNC keyboard input bugs;
Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver;
Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly;
Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4;
Compaq Portable now works with all graphics cards;
Fixed various MDSI Genius bugs;
Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly;
Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355;
OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400.
Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391.
Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389.
Fixed a minor IDE timing bug, fixes #388.
Fixed Toshiba T1000 RAM issues, fixes #379.
Fixed EGA/(S)VGA overscan border handling, fixes #378;
Got rid of the now long useless IDE channel 2 auto-removal, fixes #370;
Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366;
Ported the Unicode CD image file name fix from VARCem, fixes #365;
Fixed high density floppy disks on the Xi8088, fixes #359;
Fixed some bugs in the Hercules emulation, fixes #346, fixes #358;
Fixed the SCSI hard disk mode sense pages, fixes #356;
Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349;
Fixed bugs in the serial mouse emulation, fixes #344;
Compiled 86Box binaries now include all the required .DLL's, fixes #341;
Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
2022-09-18 17:11:43 -04:00
sound_reset ( ) ;
2018-04-25 23:51:13 +02:00
2022-09-18 17:11:43 -04:00
scsi_reset ( ) ;
scsi_device_init ( ) ;
2017-10-07 00:46:54 -04:00
2025-08-01 16:39:42 +02:00
ide_hard_reset ( ) ;
2022-09-18 17:11:43 -04:00
/* Initialize the actual machine and its basic modules. */
machine_init ( ) ;
2017-10-07 00:46:54 -04:00
2023-08-07 03:04:52 +02:00
/* Reset some basic devices. */
speaker_init ( ) ;
shadowbios = 0 ;
2018-01-17 18:43:36 +01:00
2022-09-18 17:11:43 -04:00
/*
* Once the machine has been initialized , all that remains
* should be resetting all devices set up for it , to their
* current configurations !
*
* For now , we will call their reset functions here , but
* that will be a call to device_reset_all ( ) later !
*/
2017-10-07 00:46:54 -04:00
2023-08-07 03:04:52 +02:00
/* Reset and reconfigure the Sound Card layer. */
sound_card_reset ( ) ;
2023-09-23 20:57:33 +03:00
/* Initialize parallel devices. */
/* note: PLIP LPT side has to be initialized before the network side */
2025-08-02 14:51:28 +02:00
lpt_standalone_init ( ) ;
2023-09-23 20:57:33 +03:00
lpt_devices_init ( ) ;
2023-08-07 03:04:52 +02:00
/* Reset and reconfigure the serial ports. */
2024-03-08 16:45:17 +06:00
/* note: SLIP COM side has to be initialized before the network side */
2023-08-07 03:04:52 +02:00
serial_standalone_init ( ) ;
serial_passthrough_init ( ) ;
2024-03-08 16:45:17 +06:00
/* Reset and reconfigure the Network Card layer. */
network_reset ( ) ;
2023-08-07 04:03:58 +02:00
/*
* Reset the mouse , this will attach it to any port needed .
*/
mouse_reset ( ) ;
2022-09-18 17:11:43 -04:00
/* Reset the Hard Disk Controller module. */
hdc_reset ( ) ;
2023-01-07 23:48:45 +01:00
2023-08-07 03:04:52 +02:00
fdc_card_init ( ) ;
fdd_reset ( ) ;
2022-09-18 17:11:43 -04:00
/* Reset and reconfigure the SCSI layer. */
scsi_card_init ( ) ;
2017-10-07 00:46:54 -04:00
2023-08-07 03:04:52 +02:00
scsi_disk_hard_reset ( ) ;
2018-10-10 22:33:24 +02:00
2023-08-07 03:04:52 +02:00
cdrom_hard_reset ( ) ;
2018-10-10 22:33:24 +02:00
2025-07-29 22:40:02 +02:00
/* Reset the CD-ROM Controller module. */
cdrom_interface_reset ( ) ;
2022-09-18 17:11:43 -04:00
mo_hard_reset ( ) ;
2020-07-15 09:03:45 +08:00
2025-07-25 16:30:40 +02:00
rdisk_hard_reset ( ) ;
2017-10-02 02:15:35 -04:00
2025-05-04 21:44:53 -04:00
/* Reset any ISA ROM cards. */
isarom_reset ( ) ;
2017-10-02 02:15:35 -04:00
2023-08-07 03:04:52 +02:00
/* Reset any ISA RTC cards. */
isartc_reset ( ) ;
2017-10-29 04:20:20 -05:00
2023-12-27 13:54:01 -03:00
/* Initialize the Voodoo cards here inorder to minimize
2023-08-10 01:37:33 +02:00
the chances of the SCSI controller ending up on the bridge . */
video_voodoo_init ( ) ;
2025-08-11 21:59:36 -04:00
/* installs first game port if no device provides one, must be late */
if ( joystick_type [ 0 ] )
gameport_update_joystick_type ( 0 ) ;
2023-12-27 13:54:01 -03:00
2022-09-18 17:11:43 -04:00
ui_sb_update_panes ( ) ;
2017-10-29 04:20:20 -05:00
2022-09-18 17:11:43 -04:00
if ( config_changed ) {
config_save ( ) ;
2017-10-29 04:20:20 -05:00
2022-09-18 17:11:43 -04:00
config_changed = 0 ;
} else
ui_sb_set_ready ( 1 ) ;
2017-10-29 04:20:20 -05:00
2022-09-18 17:11:43 -04:00
/* Needs the status bar... */
if ( bugger_enabled )
device_add ( & bugger_device ) ;
if ( postcard_enabled )
device_add ( & postcard_device ) ;
2024-01-07 11:50:22 +13:00
if ( unittester_enabled )
device_add ( & unittester_device ) ;
2024-03-09 11:39:35 +01:00
2024-02-26 03:15:44 +06:00
if ( novell_keycard_enabled )
device_add ( & novell_keycard_device ) ;
2017-10-29 04:20:20 -05:00
2023-08-07 03:04:52 +02:00
if ( IS_ARCH ( machine , MACHINE_BUS_PCI ) ) {
pci_register_cards ( ) ;
device_reset_all ( DEVICE_PCI ) ;
}
2024-01-08 22:27:09 +01:00
/* Mark IDE shadow drives (slaves with a present master) as such in case
the IDE controllers present are not some form of PCI . */
ide_drives_set_shadow ( ) ;
2022-09-18 17:11:43 -04:00
/* Reset the CPU module. */
resetx86 ( ) ;
dma_reset ( ) ;
pci_pic_reset ( ) ;
cpu_cache_int_enabled = cpu_cache_ext_enabled = 0 ;
2021-12-19 23:41:23 +01:00
2022-09-18 17:11:43 -04:00
atfullspeed = 0 ;
pc_full_speed ( ) ;
2020-11-16 17:47:05 +01:00
2022-09-18 17:11:43 -04:00
cycles = 0 ;
2022-02-02 02:43:40 +01:00
# ifdef FPU_CYCLES
2022-09-18 17:11:43 -04:00
fpu_cycles = 0 ;
2022-02-02 02:43:40 +01:00
# endif
2022-01-29 05:30:34 -08:00
# ifdef USE_DYNAREC
2022-09-18 17:11:43 -04:00
cycles_main = 0 ;
2022-01-29 05:30:34 -08:00
# endif
2022-09-18 17:11:43 -04:00
update_mouse_msg ( ) ;
2023-01-03 15:42:57 +06:00
2025-02-13 05:10:55 +01:00
if ( test_mode )
pc_test_mode_entry_point ( ) ;
2023-01-03 15:42:57 +06:00
ui_hard_reset_completed ( ) ;
2021-11-13 21:35:43 +01:00
}
2021-03-24 19:52:44 +01:00
2022-09-18 17:11:43 -04:00
void
2022-11-17 22:44:06 +01:00
update_mouse_msg ( void )
2021-11-13 21:35:43 +01:00
{
2023-06-09 23:46:54 -04:00
wchar_t wcpufamily [ 2048 ] ;
wchar_t wcpu [ 2048 ] ;
wchar_t wmachine [ 2048 ] ;
2023-05-11 03:02:36 -04:00
wchar_t * wcp ;
2022-02-19 23:52:47 -05:00
2022-09-18 17:11:43 -04:00
mbstowcs ( wmachine , machine_getname ( ) , strlen ( machine_getname ( ) ) + 1 ) ;
2021-05-09 02:48:24 +02:00
2022-09-18 17:11:43 -04:00
if ( ! cpu_override )
mbstowcs ( wcpufamily , cpu_f - > name , strlen ( cpu_f - > name ) + 1 ) ;
else
swprintf ( wcpufamily , sizeof_w ( wcpufamily ) , L " [U] %hs " , cpu_f - > name ) ;
2021-05-09 02:48:24 +02:00
2022-09-18 17:11:43 -04:00
wcp = wcschr ( wcpufamily , L ' ( ' ) ;
if ( wcp ) /* remove parentheses */
* ( wcp - 1 ) = L ' \0 ' ;
mbstowcs ( wcpu , cpu_s - > name , strlen ( cpu_s - > name ) + 1 ) ;
2022-01-10 01:20:21 +01:00
# ifdef _WIN32
2025-07-09 16:45:11 +06:00
swprintf ( mouse_msg [ 0 ] , sizeof_w ( mouse_msg [ 0 ] ) , L " %%i.%%i%%%% - %ls " ,
2024-03-19 14:27:19 +05:00
plat_get_string ( STRING_MOUSE_CAPTURE ) ) ;
2025-07-09 16:45:11 +06:00
swprintf ( mouse_msg [ 1 ] , sizeof_w ( mouse_msg [ 1 ] ) , L " %%i.%%i%%%% - %ls " ,
2024-03-19 14:27:19 +05:00
( mouse_get_buttons ( ) > 2 ) ? plat_get_string ( STRING_MOUSE_RELEASE ) : plat_get_string ( STRING_MOUSE_RELEASE_MMB ) ) ;
2025-07-12 15:58:32 +06:00
wcsncpy ( mouse_msg [ 2 ] , L " %i.%i%% " , sizeof_w ( mouse_msg [ 2 ] ) ) ;
2022-01-10 01:20:21 +01:00
# else
2025-07-09 16:45:11 +06:00
swprintf ( mouse_msg [ 0 ] , sizeof_w ( mouse_msg [ 0 ] ) , L " %ls v%ls - %%i.%%i%%%% - %ls - %ls/%ls - %ls " ,
2022-09-18 17:11:43 -04:00
EMU_NAME_W , EMU_VERSION_FULL_W , wmachine , wcpufamily , wcpu ,
2024-03-19 14:27:19 +05:00
plat_get_string ( STRING_MOUSE_CAPTURE ) ) ;
2025-07-09 16:45:11 +06:00
swprintf ( mouse_msg [ 1 ] , sizeof_w ( mouse_msg [ 1 ] ) , L " %ls v%ls - %%i.%%i%%%% - %ls - %ls/%ls - %ls " ,
2022-09-18 17:11:43 -04:00
EMU_NAME_W , EMU_VERSION_FULL_W , wmachine , wcpufamily , wcpu ,
2024-03-19 14:27:19 +05:00
( mouse_get_buttons ( ) > 2 ) ? plat_get_string ( STRING_MOUSE_RELEASE ) : plat_get_string ( STRING_MOUSE_RELEASE_MMB ) ) ;
2025-07-09 16:45:11 +06:00
swprintf ( mouse_msg [ 2 ] , sizeof_w ( mouse_msg [ 2 ] ) , L " %ls v%ls - %%i.%%i%%%% - %ls - %ls/%ls " ,
2022-09-18 17:11:43 -04:00
EMU_NAME_W , EMU_VERSION_FULL_W , wmachine , wcpufamily , wcpu ) ;
2022-01-10 01:20:21 +01:00
# endif
2016-06-26 00:34:39 +02:00
}
2017-10-02 02:15:35 -04:00
void
pc_reset_hard ( void )
2016-06-26 00:34:39 +02:00
{
2022-09-18 17:11:43 -04:00
hard_reset_pending = 1 ;
2017-06-19 06:46:08 +02:00
}
2017-10-02 02:15:35 -04:00
void
2023-06-09 23:46:54 -04:00
pc_close ( UNUSED ( thread_t * ptr ) )
2017-10-02 02:15:35 -04:00
{
2022-09-18 17:11:43 -04:00
/* Wait a while so things can shut down. */
plat_delay_ms ( 200 ) ;
2017-10-19 04:27:04 -04:00
2022-09-18 17:11:43 -04:00
/* Claim the video blitter. */
startblit ( ) ;
2017-10-19 04:27:04 -04:00
2022-09-18 17:11:43 -04:00
/* Terminate the UI thread. */
is_quit = 1 ;
2017-10-19 04:27:04 -04:00
2022-09-18 17:11:43 -04:00
nvr_save ( ) ;
2017-10-19 04:27:04 -04:00
2022-09-18 17:11:43 -04:00
config_save ( ) ;
2017-10-19 04:27:04 -04:00
2022-09-18 17:11:43 -04:00
plat_mouse_capture ( 0 ) ;
2017-10-19 04:27:04 -04:00
2022-09-18 17:11:43 -04:00
/* Close all the memory mappings. */
mem_close ( ) ;
PIC rewrite, proper SMRAM API, complete SiS 471 rewrite and addition of 40x, 460, and 461, changes to mem.c/h, disabled Voodoo memory dumping on exit, bumped SDL Hardware scale quality to 2, bumped IDE/ATAPI drives to ATA-6, finally bumped emulator version to 3.0, redid the bus type ID's to allow for planned ATAPI hard disks, made SST flash set its high mappings to the correct address if the CPU is 16-bit, and added the SiS 401 AMI 486 Clone, AOpen Vi15G, and the Soyo 4SA2 (486 with SiS 496/497 that can boot from CD-ROM), assorted 286+ protected mode fixes (for slightly more accuracy), and fixes to 808x emulation (MS Word 1.0 and 1.10 for DOS now work correctly from floppy).
2020-10-14 23:15:01 +02:00
2022-09-18 17:11:43 -04:00
/* Turn off timer processing to avoid potential segmentation faults. */
timer_close ( ) ;
Added the IBM 5161 ISA expansion for PC and XT;
Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port;
Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX);
Finished the 586MC1;
Added 8087 emulation;
Moved Cyrix 6x86'es to the Dev branch;
Sanitized/cleaned up memregs.c/h and intel.c/h;
Split the chipsets from machines and sanitized Port 92 emulation;
Added support for the 15bpp mode to the Compaq ATI 28800;
Moved the MR 386DX and 486 machines to the Dev branch;
Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00;
Ported the new timer code from PCem;
Cleaned up the CPU table of unused stuff and better optimized its structure;
Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch;
Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem;
Added the AHA-1540A and the BusTek BT-542B;
Moved the Sumo SCSI-AT to the Dev branch;
Minor IDE, FDC, and floppy drive code clean-ups;
Made NCR 5380/53C400-based cards' BIOS address configurable;
Got rid of the legacy romset variable;
Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit;
Added the Amstead PPC512 per PCem patch by John Elliott;
Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages);
Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing;
Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem;
Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit;
Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement;
Amstrad MegaPC does now works correctly with non-internal graphics card;
The SLiRP code no longer casts a packed struct type to a non-packed struct type;
The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present;
The S3 Virge on BeOS is no longer broken (was broken by build #1591);
OS/2 2.0 build 6.167 now sees key presses again;
Xi8088 now work on CGA again;
86F images converted from either the old or new variants of the HxC MFM format now work correctly;
Hardware interrupts with a vector of 0xFF are now handled correctly;
OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct;
Fixed VNC keyboard input bugs;
Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver;
Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly;
Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4;
Compaq Portable now works with all graphics cards;
Fixed various MDSI Genius bugs;
Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly;
Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355;
OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400.
Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391.
Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389.
Fixed a minor IDE timing bug, fixes #388.
Fixed Toshiba T1000 RAM issues, fixes #379.
Fixed EGA/(S)VGA overscan border handling, fixes #378;
Got rid of the now long useless IDE channel 2 auto-removal, fixes #370;
Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366;
Ported the Unicode CD image file name fix from VARCem, fixes #365;
Fixed high density floppy disks on the Xi8088, fixes #359;
Fixed some bugs in the Hercules emulation, fixes #346, fixes #358;
Fixed the SCSI hard disk mode sense pages, fixes #356;
Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349;
Fixed bugs in the serial mouse emulation, fixes #344;
Compiled 86Box binaries now include all the required .DLL's, fixes #341;
Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
2022-09-18 17:11:43 -04:00
lpt_devices_close ( ) ;
2018-02-06 19:53:34 +01:00
2023-05-11 03:02:36 -04:00
for ( uint8_t i = 0 ; i < FDD_NUM ; i + + )
2022-09-18 17:11:43 -04:00
fdd_close ( i ) ;
2017-10-02 02:15:35 -04:00
2019-02-06 03:34:39 +01:00
# ifdef ENABLE_808X_LOG
2022-09-18 17:11:43 -04:00
if ( dump_on_exit )
dumpregs ( 0 ) ;
2019-02-06 03:34:39 +01:00
# endif
2017-10-02 02:15:35 -04:00
2022-09-18 17:11:43 -04:00
video_close ( ) ;
2017-10-02 02:15:35 -04:00
2022-09-18 17:11:43 -04:00
device_close_all ( ) ;
2018-10-30 13:32:25 +01:00
2022-09-18 17:11:43 -04:00
scsi_device_close_all ( ) ;
2017-10-02 02:15:35 -04:00
2022-09-18 17:11:43 -04:00
midi_out_close ( ) ;
2022-03-13 09:00:03 -04:00
2022-09-18 17:11:43 -04:00
midi_in_close ( ) ;
2017-10-02 02:15:35 -04:00
2022-09-18 17:11:43 -04:00
network_close ( ) ;
2017-12-05 20:19:19 +01:00
2022-09-18 17:11:43 -04:00
sound_cd_thread_end ( ) ;
2018-10-10 22:33:24 +02:00
2022-09-18 17:11:43 -04:00
cdrom_close ( ) ;
2018-03-15 22:57:24 +01:00
2025-07-25 16:30:40 +02:00
rdisk_close ( ) ;
2018-07-15 01:41:53 +02:00
2022-09-18 17:11:43 -04:00
mo_close ( ) ;
2020-07-15 09:03:45 +08:00
2022-09-18 17:11:43 -04:00
scsi_disk_close ( ) ;
2022-03-12 20:20:25 -03:00
2022-09-18 17:11:43 -04:00
gdbstub_close ( ) ;
2025-06-25 19:35:59 +02:00
# if (!(defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64))
mem_free ( ) ;
# endif
2017-10-02 02:15:35 -04:00
}
2021-09-03 19:35:25 +02:00
# ifdef __APPLE__
2022-09-18 17:11:43 -04:00
static void
_ui_window_title ( void * s )
2021-09-03 19:35:25 +02:00
{
2022-04-14 07:00:06 +05:00
ui_window_title ( ( wchar_t * ) s ) ;
2021-09-03 19:35:25 +02:00
free ( s ) ;
}
# endif
2023-10-31 00:44:04 +01:00
void
ack_pause ( void )
{
2023-12-11 20:32:51 +01:00
if ( atomic_load ( & do_pause_ack ) ) {
atomic_store ( & do_pause_ack , 0 ) ;
atomic_store ( & pause_ack , 1 ) ;
2023-10-31 00:44:04 +01:00
}
}
2017-10-19 04:27:04 -04:00
void
2021-03-24 19:52:44 +01:00
pc_run ( void )
2016-06-26 00:34:39 +02:00
{
2022-09-18 17:11:43 -04:00
int mouse_msg_idx ;
wchar_t temp [ 200 ] ;
/* Trigger a hard reset if one is pending. */
if ( hard_reset_pending ) {
hard_reset_pending = 0 ;
pc_reset_hard_close ( ) ;
pc_reset_hard_init ( ) ;
}
2025-01-12 15:21:31 +00:00
/* Update the guest-CPU independent timer for devices with independent clock speed */
rivatimer_update_all ( ) ;
2022-09-18 17:11:43 -04:00
/* Run a block of code. */
startblit ( ) ;
2025-07-09 12:59:16 +06:00
cpu_exec ( ( int32_t ) cpu_s - > rspeed / ( force_10ms ? 100 : 1000 ) ) ;
2023-10-31 00:44:04 +01:00
ack_pause ( ) ;
2022-03-16 00:33:01 -03:00
# ifdef USE_GDBSTUB /* avoid a KBC FIFO overflow when CPU emulation is stalled */
2023-08-07 18:49:58 +02:00
if ( gdbstub_step = = GDBSTUB_EXEC ) {
2022-03-16 00:33:01 -03:00
# endif
2023-08-07 18:49:58 +02:00
if ( ! mouse_timed )
mouse_process ( ) ;
# ifdef USE_GDBSTUB /* avoid a KBC FIFO overflow when CPU emulation is stalled */
}
2023-06-28 13:46:28 -04:00
# endif
2025-08-11 21:59:36 -04:00
joystick_process ( 0 ) ; // Gameport 0
2022-09-18 17:11:43 -04:00
endblit ( ) ;
/* Done with this frame, update statistics. */
framecount + + ;
2025-07-09 12:59:16 +06:00
if ( + + framecountx > = ( force_10ms ? 100 : 1000 ) ) {
2022-09-18 17:11:43 -04:00
framecountx = 0 ;
frames = 0 ;
}
if ( title_update ) {
2023-10-23 01:21:28 +02:00
mouse_msg_idx = ( ( mouse_type = = MOUSE_TYPE_NONE ) | | ( mouse_input_mode > = 1 ) ) ? 2 : ! ! mouse_capture ;
2025-07-09 16:45:11 +06:00
swprintf ( temp , sizeof_w ( temp ) , mouse_msg [ mouse_msg_idx ] , fps / ( force_10ms ? 1 : 10 ) , force_10ms ? 0 : ( fps % 10 ) ) ;
2021-09-03 19:23:50 +02:00
# ifdef __APPLE__
2022-09-18 17:11:43 -04:00
/* Needed due to modifying the UI on the non-main thread is a big no-no. */
dispatch_async_f ( dispatch_get_main_queue ( ) , wcsdup ( ( const wchar_t * ) temp ) , _ui_window_title ) ;
2021-09-03 19:23:50 +02:00
# else
2022-09-18 17:11:43 -04:00
ui_window_title ( temp ) ;
2021-09-03 19:23:50 +02:00
# endif
2022-09-18 17:11:43 -04:00
title_update = 0 ;
}
2016-06-26 00:34:39 +02:00
}
2017-10-19 04:27:04 -04:00
/* Handler for the 1-second timer to refresh the window title. */
2017-10-02 02:15:35 -04:00
void
2017-10-19 04:27:04 -04:00
pc_onesec ( void )
2016-06-26 00:34:39 +02:00
{
2022-09-18 17:11:43 -04:00
fps = framecount ;
framecount = 0 ;
2017-10-19 04:27:04 -04:00
2022-09-18 17:11:43 -04:00
title_update = 1 ;
2016-06-26 00:34:39 +02:00
}
2017-12-04 11:59:26 -05:00
void
2022-07-07 17:56:32 +06:00
set_screen_size_monitor ( int x , int y , int monitor_index )
2017-12-04 11:59:26 -05:00
{
2022-09-18 17:11:43 -04:00
int temp_overscan_x = monitors [ monitor_index ] . mon_overscan_x ;
int temp_overscan_y = monitors [ monitor_index ] . mon_overscan_y ;
2025-03-29 19:54:48 +01:00
int is_svga = ( video_get_type_monitor ( monitor_index ) = = VIDEO_FLAG_TYPE_SPECIAL ) | |
( video_get_type_monitor ( monitor_index ) = = VIDEO_FLAG_TYPE_8514 ) ;
2023-05-11 03:02:36 -04:00
double dx ;
double dy ;
double dtx ;
double dty ;
2017-12-04 11:59:26 -05:00
2021-04-22 04:27:50 +02:00
/* Make sure we keep usable values. */
2017-12-04 11:59:26 -05:00
#if 0
2021-04-22 04:27:50 +02:00
pc_log ( " SetScreenSize(%d, %d) resize=%d \n " , x , y , vid_resize ) ;
2017-12-04 11:59:26 -05:00
# endif
2022-09-18 17:11:43 -04:00
if ( x < 320 )
x = 320 ;
if ( y < 200 )
y = 200 ;
if ( x > 2048 )
x = 2048 ;
if ( y > 2048 )
y = 2048 ;
2021-04-22 04:27:50 +02:00
/* Save the new values as "real" (unscaled) resolution. */
2022-07-07 17:56:32 +06:00
monitors [ monitor_index ] . mon_unscaled_size_x = x ;
2022-09-18 17:11:43 -04:00
monitors [ monitor_index ] . mon_efscrnsz_y = y ;
2021-04-22 04:27:50 +02:00
if ( suppress_overscan )
2022-09-18 17:11:43 -04:00
temp_overscan_x = temp_overscan_y = 0 ;
2021-04-22 04:27:50 +02:00
if ( force_43 ) {
2022-09-18 17:11:43 -04:00
dx = ( double ) x ;
dtx = ( double ) temp_overscan_x ;
dy = ( double ) y ;
dty = ( double ) temp_overscan_y ;
/* Account for possible overscan. */
2025-03-29 19:54:48 +01:00
if ( ! is_svga & & ( temp_overscan_y = = 16 ) ) {
2022-09-18 17:11:43 -04:00
/* CGA */
2022-07-07 17:56:32 +06:00
dy = ( ( ( dx - dtx ) / 4.0 ) * 3.0 ) + dty ;
2025-03-29 19:54:48 +01:00
} else if ( ! is_svga & & ( temp_overscan_y < 16 ) ) {
2022-09-18 17:11:43 -04:00
/* MDA/Hercules */
2025-03-29 19:54:48 +01:00
dy = ( dx / 4.0 ) * 3.0 ;
2022-09-18 17:11:43 -04:00
} else {
if ( enable_overscan ) {
/* EGA/(S)VGA with overscan */
dy = ( ( ( dx - dtx ) / 4.0 ) * 3.0 ) + dty ;
} else {
/* EGA/(S)VGA without overscan */
2025-03-29 19:54:48 +01:00
dy = ( dx / 4.0 ) * 3.0 ;
2022-09-18 17:11:43 -04:00
}
2022-07-07 17:56:32 +06:00
}
2022-09-18 17:11:43 -04:00
monitors [ monitor_index ] . mon_unscaled_size_y = ( int ) dy ;
2021-04-22 04:27:50 +02:00
} else
2022-09-18 17:11:43 -04:00
monitors [ monitor_index ] . mon_unscaled_size_y = monitors [ monitor_index ] . mon_efscrnsz_y ;
switch ( scale ) {
case 0 : /* 50% */
monitors [ monitor_index ] . mon_scrnsz_x = ( monitors [ monitor_index ] . mon_unscaled_size_x > > 1 ) ;
monitors [ monitor_index ] . mon_scrnsz_y = ( monitors [ monitor_index ] . mon_unscaled_size_y > > 1 ) ;
break ;
case 1 : /* 100% */
monitors [ monitor_index ] . mon_scrnsz_x = monitors [ monitor_index ] . mon_unscaled_size_x ;
monitors [ monitor_index ] . mon_scrnsz_y = monitors [ monitor_index ] . mon_unscaled_size_y ;
break ;
case 2 : /* 150% */
monitors [ monitor_index ] . mon_scrnsz_x = ( ( monitors [ monitor_index ] . mon_unscaled_size_x * 3 ) > > 1 ) ;
monitors [ monitor_index ] . mon_scrnsz_y = ( ( monitors [ monitor_index ] . mon_unscaled_size_y * 3 ) > > 1 ) ;
break ;
case 3 : /* 200% */
monitors [ monitor_index ] . mon_scrnsz_x = ( monitors [ monitor_index ] . mon_unscaled_size_x < < 1 ) ;
monitors [ monitor_index ] . mon_scrnsz_y = ( monitors [ monitor_index ] . mon_unscaled_size_y < < 1 ) ;
break ;
2022-11-01 11:53:49 -07:00
case 4 : /* 300% */
monitors [ monitor_index ] . mon_scrnsz_x = ( monitors [ monitor_index ] . mon_unscaled_size_x * 3 ) ;
monitors [ monitor_index ] . mon_scrnsz_y = ( monitors [ monitor_index ] . mon_unscaled_size_y * 3 ) ;
break ;
case 5 : /* 400% */
monitors [ monitor_index ] . mon_scrnsz_x = ( monitors [ monitor_index ] . mon_unscaled_size_x < < 2 ) ;
monitors [ monitor_index ] . mon_scrnsz_y = ( monitors [ monitor_index ] . mon_unscaled_size_y < < 2 ) ;
break ;
case 6 : /* 500% */
monitors [ monitor_index ] . mon_scrnsz_x = ( monitors [ monitor_index ] . mon_unscaled_size_x * 5 ) ;
monitors [ monitor_index ] . mon_scrnsz_y = ( monitors [ monitor_index ] . mon_unscaled_size_y * 5 ) ;
break ;
case 7 : /* 600% */
monitors [ monitor_index ] . mon_scrnsz_x = ( monitors [ monitor_index ] . mon_unscaled_size_x * 6 ) ;
monitors [ monitor_index ] . mon_scrnsz_y = ( monitors [ monitor_index ] . mon_unscaled_size_y * 6 ) ;
break ;
case 8 : /* 700% */
monitors [ monitor_index ] . mon_scrnsz_x = ( monitors [ monitor_index ] . mon_unscaled_size_x * 7 ) ;
monitors [ monitor_index ] . mon_scrnsz_y = ( monitors [ monitor_index ] . mon_unscaled_size_y * 7 ) ;
break ;
case 9 : /* 800% */
monitors [ monitor_index ] . mon_scrnsz_x = ( monitors [ monitor_index ] . mon_unscaled_size_x < < 3 ) ;
monitors [ monitor_index ] . mon_scrnsz_y = ( monitors [ monitor_index ] . mon_unscaled_size_y < < 3 ) ;
break ;
2023-06-28 13:46:28 -04:00
default :
break ;
2021-04-22 04:27:50 +02:00
}
2017-12-04 11:59:26 -05:00
2022-07-12 14:41:38 +06:00
plat_resize_request ( monitors [ monitor_index ] . mon_scrnsz_x , monitors [ monitor_index ] . mon_scrnsz_y , monitor_index ) ;
2022-07-07 17:56:32 +06:00
}
void
set_screen_size ( int x , int y )
{
set_screen_size_monitor ( x , y , monitor_index_global ) ;
2017-12-04 11:59:26 -05:00
}
2022-07-07 17:56:32 +06:00
void
reset_screen_size_monitor ( int monitor_index )
{
set_screen_size ( monitors [ monitor_index ] . mon_unscaled_size_x , monitors [ monitor_index ] . mon_efscrnsz_y ) ;
}
2017-12-04 11:59:26 -05:00
2020-11-28 07:04:40 +01:00
void
reset_screen_size ( void )
{
2023-06-26 22:31:03 -04:00
for ( uint8_t i = 0 ; i < MONITORS_NUM ; i + + )
2022-07-07 17:56:32 +06:00
set_screen_size ( monitors [ i ] . mon_unscaled_size_x , monitors [ i ] . mon_efscrnsz_y ) ;
2020-11-28 07:04:40 +01:00
}
2017-12-04 11:59:26 -05:00
void
set_screen_size_natural ( void )
{
2023-06-26 22:31:03 -04:00
for ( uint8_t i = 0 ; i < MONITORS_NUM ; i + + )
2022-07-07 17:56:32 +06:00
set_screen_size ( monitors [ i ] . mon_unscaled_size_x , monitors [ i ] . mon_unscaled_size_y ) ;
2017-12-04 11:59:26 -05:00
}
int
get_actual_size_x ( void )
{
2022-09-18 17:11:43 -04:00
return ( unscaled_size_x ) ;
2017-12-04 11:59:26 -05:00
}
int
get_actual_size_y ( void )
{
2022-09-18 17:11:43 -04:00
return ( efscrnsz_y ) ;
2017-12-04 11:59:26 -05:00
}
2023-10-31 00:44:04 +01:00
void
do_pause ( int p )
{
2023-12-11 20:32:51 +01:00
int old_p = dopause ;
2023-12-21 15:05:15 +01:00
if ( ( p = = 1 ) & & ! old_p )
2023-10-31 00:44:04 +01:00
do_pause_ack = p ;
2023-12-21 15:05:15 +01:00
dopause = ! ! p ;
if ( ( p = = 1 ) & & ! old_p ) {
2023-12-11 20:32:51 +01:00
while ( ! atomic_load ( & pause_ack ) )
2023-10-31 00:44:04 +01:00
;
}
2023-12-11 20:32:51 +01:00
atomic_store ( & pause_ack , 0 ) ;
2023-10-31 00:44:04 +01:00
}
2025-04-19 19:44:47 -07:00
// Helper to find an accelerator key and return it's index in acc_keys
int FindAccelerator ( const char * name ) {
2025-08-13 00:45:15 -04:00
for ( int x = 0 ; x < NUM_ACCELS ; x + + ) {
if ( strcmp ( acc_keys [ x ] . name , name ) = = 0 )
return ( x ) ;
}
// No key was found
return - 1 ;
2025-05-04 21:44:53 -04:00
}