├── .gitignore ├── .gitlab-ci.yml ├── DOSBOX-AUTHORS ├── DOSBOX-THANKS ├── LICENSE ├── Makefile ├── README.md ├── core_options.h ├── dosbox_pure_libretro.cpp ├── dosbox_pure_libretro.info ├── dosbox_pure_libretro.sln ├── dosbox_pure_libretro.vcxproj ├── dosbox_pure_libretro.vcxproj.filters ├── dosbox_pure_osd.h ├── dosbox_pure_run.h ├── images ├── logo.png ├── onscreenkeyboard.png ├── padmapper.png └── startmenu.png ├── include ├── bios.h ├── bios_disk.h ├── callback.h ├── config.h ├── control.h ├── cpu.h ├── cross.h ├── dbp_network.h ├── dbp_opengl.h ├── dbp_serialize.h ├── dbp_threads.h ├── debug.h ├── dma.h ├── dos_inc.h ├── dos_system.h ├── dosbox.h ├── fpu.h ├── hardware.h ├── inout.h ├── ipx.h ├── ipxserver.h ├── joystick.h ├── keyboard.h ├── logging.h ├── mapper.h ├── mem.h ├── midi.h ├── mixer.h ├── mouse.h ├── paging.h ├── pci_bus.h ├── pic.h ├── programs.h ├── regs.h ├── render.h ├── serialport.h ├── setup.h ├── shell.h ├── support.h ├── timer.h ├── vga.h └── video.h ├── jni ├── Android.mk └── Application.mk ├── keyb2joypad.cpp ├── keyb2joypad.h ├── libretro-common ├── features │ ├── features_cpu.c │ └── features_cpu.inl ├── include │ ├── libretro.h │ └── retro_timers.h └── rthreads │ ├── ctr_pthread.h │ ├── gx_pthread.h │ └── wiiu_pthread.h └── src ├── cpu ├── callback.cpp ├── core_dyn_x86.cpp ├── core_dyn_x86 │ ├── decoder.h │ ├── dyn_fpu.h │ ├── dyn_fpu_dh.h │ ├── helpers.h │ ├── risc_x64.h │ ├── risc_x86.h │ └── string.h ├── core_dynrec.cpp ├── core_dynrec │ ├── decoder.h │ ├── decoder_basic.h │ ├── decoder_opcodes.h │ ├── dyn_fpu.h │ ├── operators.h │ ├── risc_armv4le-common.h │ ├── risc_armv4le-o3.h │ ├── risc_armv4le-thumb-iw.h │ ├── risc_armv4le-thumb-niw.h │ ├── risc_armv4le-thumb.h │ ├── risc_armv4le.h │ ├── risc_armv8le.h │ ├── risc_mipsel32.h │ ├── risc_ppc.h │ ├── risc_x64.h │ └── risc_x86.h ├── core_full.cpp ├── core_full │ ├── ea_lookup.h │ ├── load.h │ ├── loadwrite.h │ ├── op.h │ ├── optable.h │ ├── save.h │ ├── string.h │ └── support.h ├── core_normal.cpp ├── core_normal │ ├── helpers.h │ ├── prefix_0f.h │ ├── prefix_66.h │ ├── prefix_66_0f.h │ ├── prefix_none.h │ ├── string.h │ ├── support.h │ └── table_ea.h ├── core_prefetch.cpp ├── core_simple.cpp ├── cpu.cpp ├── dyn_cache.h ├── flags.cpp ├── instructions.h ├── lazyflags.h ├── modrm.cpp ├── modrm.h └── paging.cpp ├── dbp_network.cpp ├── dbp_serialize.cpp ├── dos ├── cdrom.cpp ├── cdrom.h ├── cdrom_image.cpp ├── dev_con.h ├── dos.cpp ├── dos_classes.cpp ├── dos_codepages.h ├── dos_devices.cpp ├── dos_execute.cpp ├── dos_files.cpp ├── dos_ioctl.cpp ├── dos_keyboard_layout.cpp ├── dos_keyboard_layout_data.h ├── dos_memory.cpp ├── dos_misc.cpp ├── dos_mscdex.cpp ├── dos_programs.cpp ├── dos_tables.cpp ├── drive_cache.cpp ├── drive_fat.cpp ├── drive_iso.cpp ├── drive_local.cpp ├── drive_memory.cpp ├── drive_mirror.cpp ├── drive_overlay.cpp ├── drive_patch.cpp ├── drive_union.cpp ├── drive_virtual.cpp ├── drive_zip.cpp ├── drives.cpp ├── drives.h ├── scsidefs.h ├── stb_vorbis.inl └── wnaspi32.h ├── dosbox.cpp ├── fpu ├── fpu.cpp ├── fpu_instructions.h └── fpu_instructions_x86.h ├── gui ├── midi.cpp ├── midi_alsa.h ├── midi_coreaudio.h ├── midi_coremidi.h ├── midi_mt32.h ├── midi_opl.h ├── midi_oss.h ├── midi_retro.h ├── midi_tsf.h ├── midi_win32.h ├── mt32emu.h ├── render.cpp ├── render_glsl.h ├── render_loops.h ├── render_scalers.cpp ├── render_scalers.h ├── render_simple.h ├── render_templates.h ├── render_templates_hq.h ├── render_templates_hq2x.h ├── render_templates_hq3x.h ├── render_templates_sai.h └── tsf.h ├── hardware ├── adlib.cpp ├── adlib.h ├── cmos.cpp ├── dbopl.cpp ├── dbopl.h ├── disney.cpp ├── dma.cpp ├── gameblaster.cpp ├── gus.cpp ├── hardware.cpp ├── ide.cpp ├── iohandler.cpp ├── joystick.cpp ├── keyboard.cpp ├── mame │ ├── emu.h │ ├── saa1099.cpp │ ├── saa1099.h │ ├── sn76496.cpp │ └── sn76496.h ├── memory.cpp ├── mixer.cpp ├── mpu401.cpp ├── nukedopl3.cpp ├── nukedopl3.h ├── pci_bus.cpp ├── pci_devices.h ├── pcspeaker.cpp ├── pic.cpp ├── sblaster.cpp ├── serialport │ ├── directserial.h │ ├── libserial.h │ ├── misc_util.h │ ├── nullmodem.h │ ├── serialdummy.cpp │ ├── serialdummy.h │ ├── serialport.cpp │ └── softmodem.h ├── tandy_sound.cpp ├── timer.cpp ├── vga.cpp ├── vga_attr.cpp ├── vga_crtc.cpp ├── vga_dac.cpp ├── vga_draw.cpp ├── vga_gfx.cpp ├── vga_memory.cpp ├── vga_misc.cpp ├── vga_other.cpp ├── vga_paradise.cpp ├── vga_s3.cpp ├── vga_seq.cpp ├── vga_tseng.cpp ├── vga_xga.cpp └── voodoo.cpp ├── ints ├── bios.cpp ├── bios_disk.cpp ├── bios_keyboard.cpp ├── ems.cpp ├── int10.cpp ├── int10.h ├── int10_char.cpp ├── int10_memory.cpp ├── int10_misc.cpp ├── int10_modes.cpp ├── int10_pal.cpp ├── int10_put_pixel.cpp ├── int10_vesa.cpp ├── int10_video_state.cpp ├── int10_vptable.cpp ├── mouse.cpp ├── xms.cpp └── xms.h ├── misc ├── cross.cpp ├── messages.cpp ├── programs.cpp ├── setup.cpp └── support.cpp └── shell ├── shell.cpp ├── shell_batch.cpp ├── shell_cmds.cpp └── shell_misc.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | obj/ 3 | libs/ 4 | .vs/ 5 | *.ncb 6 | *.opt 7 | *.plg 8 | *.aps 9 | *.ipch 10 | *.suo 11 | *.user 12 | *.sdf 13 | *.opensdf 14 | *.cfg 15 | *.dll 16 | *.so 17 | *.dylib 18 | jni/*.bat 19 | -------------------------------------------------------------------------------- /DOSBOX-AUTHORS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/dosbox-pure/d96443ea4b020c2c23944ccd3540b7febc58e4c7/DOSBOX-AUTHORS -------------------------------------------------------------------------------- /DOSBOX-THANKS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/dosbox-pure/d96443ea4b020c2c23944ccd3540b7febc58e4c7/DOSBOX-THANKS -------------------------------------------------------------------------------- /dosbox_pure_libretro.info: -------------------------------------------------------------------------------- 1 | # Software Information 2 | display_name = "DOS (DOSBox-Pure)" 3 | authors = "DOSBox Team|Psyraven" 4 | supported_extensions = "zip|dosz|exe|com|bat|iso|chd|cue|ins|img|ima|vhd|jrc|tc|m3u|m3u8|conf|/" 5 | corename = "DOSBox-pure" 6 | categories = "Emulator" 7 | license = "GPLv2" 8 | permissions = "" 9 | display_version = "1.0-preview1" 10 | 11 | # Hardware Information 12 | manufacturer = "Microsoft" 13 | systemname = "DOS" 14 | systemid = "dos" 15 | 16 | # Libretro Features 17 | database = "DOS" 18 | supports_no_game = "true" 19 | savestate = "true" 20 | savestate_features = "serialized" 21 | libretro_saves = "true" 22 | cheats = "true" 23 | input_descriptors = "true" 24 | memory_descriptors = "true" 25 | core_options = "true" 26 | core_options_version = "2.0" 27 | load_subsystem = "false" 28 | hw_render = "false" 29 | needs_fullpath = "true" 30 | disk_control = "true" 31 | is_experimental = "false" 32 | needs_kbd_mouse_focus = "true" 33 | 34 | description = "A port of the mature and well-known DOSBox emulator to libretro with a goal of simplicty and ease of use. This core includes a streamlined workflow for launching games directly from ZIP archives (including disk images therein) with automated mapping of controls to gamepads and a native onscreen keyboard. This is a good core for most users who just want to play games and are not looking for a traditional DOS experience." 35 | -------------------------------------------------------------------------------- /dosbox_pure_libretro.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio 2013 3 | VisualStudioVersion = 12.0.0.0 4 | MinimumVisualStudioVersion = 10.0.0.0 5 | Project("{FFFFFFFF-FFFF-4FFF-FFFF-FFFFFFFFFFFF}") = "dosbox_pure_libretro", "dosbox_pure_libretro.vcxproj", "{FFFFFFFF-FFFF-4FFF-FFFF-FFFFFFFFFFFF}" 6 | EndProject 7 | Global 8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 9 | Debug|Win32 = Debug|Win32 10 | Debug|x64 = Debug|x64 11 | Release|Win32 = Release|Win32 12 | Release|x64 = Release|x64 13 | EndGlobalSection 14 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 15 | {FFFFFFFF-FFFF-4FFF-FFFF-FFFFFFFFFFFF}.Debug|Win32.ActiveCfg = Debug|Win32 16 | {FFFFFFFF-FFFF-4FFF-FFFF-FFFFFFFFFFFF}.Debug|Win32.Build.0 = Debug|Win32 17 | {FFFFFFFF-FFFF-4FFF-FFFF-FFFFFFFFFFFF}.Debug|x64.ActiveCfg = Debug|x64 18 | {FFFFFFFF-FFFF-4FFF-FFFF-FFFFFFFFFFFF}.Debug|x64.Build.0 = Debug|x64 19 | {FFFFFFFF-FFFF-4FFF-FFFF-FFFFFFFFFFFF}.Release|Win32.ActiveCfg = Release|Win32 20 | {FFFFFFFF-FFFF-4FFF-FFFF-FFFFFFFFFFFF}.Release|Win32.Build.0 = Release|Win32 21 | {FFFFFFFF-FFFF-4FFF-FFFF-FFFFFFFFFFFF}.Release|x64.ActiveCfg = Release|x64 22 | {FFFFFFFF-FFFF-4FFF-FFFF-FFFFFFFFFFFF}.Release|x64.Build.0 = Release|x64 23 | EndGlobalSection 24 | GlobalSection(SolutionProperties) = preSolution 25 | HideSolutionNode = FALSE 26 | EndGlobalSection 27 | EndGlobal 28 | -------------------------------------------------------------------------------- /images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/dosbox-pure/d96443ea4b020c2c23944ccd3540b7febc58e4c7/images/logo.png -------------------------------------------------------------------------------- /images/onscreenkeyboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/dosbox-pure/d96443ea4b020c2c23944ccd3540b7febc58e4c7/images/onscreenkeyboard.png -------------------------------------------------------------------------------- /images/padmapper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/dosbox-pure/d96443ea4b020c2c23944ccd3540b7febc58e4c7/images/padmapper.png -------------------------------------------------------------------------------- /images/startmenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/dosbox-pure/d96443ea4b020c2c23944ccd3540b7febc58e4c7/images/startmenu.png -------------------------------------------------------------------------------- /include/bios_disk.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef DOSBOX_BIOS_DISK_H 20 | #define DOSBOX_BIOS_DISK_H 21 | 22 | #include 23 | #ifndef DOSBOX_MEM_H 24 | #include "mem.h" 25 | #endif 26 | #ifndef DOSBOX_DOS_INC_H 27 | #include "dos_inc.h" 28 | #endif 29 | #ifndef DOSBOX_BIOS_H 30 | #include "bios.h" 31 | #endif 32 | 33 | /* The Section handling Bios Disk Access */ 34 | #define BIOS_MAX_DISK 10 35 | 36 | #ifdef C_DBP_ENABLE_DISKSWAP 37 | #define MAX_SWAPPABLE_DISKS 20 38 | #endif 39 | struct diskGeo { 40 | Bit32u ksize; /* Size in kilobytes */ 41 | Bit16u secttrack; /* Sectors per track */ 42 | Bit16u headscyl; /* Heads per cylinder */ 43 | Bit16u cylcount; /* Cylinders per side */ 44 | Bit16u biosval; /* Type to return from BIOS */ 45 | }; 46 | extern diskGeo DiskGeometryList[]; 47 | 48 | #ifdef C_DBP_SUPPORT_DISK_FAT_EMULATOR 49 | template struct StringToPointerHashMap; 50 | #endif 51 | 52 | class imageDisk { 53 | public: 54 | Bit8u Read_Sector(Bit32u head,Bit32u cylinder,Bit32u sector,void * data); 55 | Bit8u Write_Sector(Bit32u head,Bit32u cylinder,Bit32u sector,void * data); 56 | Bit8u Read_AbsoluteSector(Bit32u sectnum, void * data); 57 | Bit8u Write_AbsoluteSector(Bit32u sectnum, void * data); 58 | 59 | void Set_Geometry(Bit32u setHeads, Bit32u setCyl, Bit32u setSect, Bit32u setSectSize); 60 | void Get_Geometry(Bit32u * getHeads, Bit32u *getCyl, Bit32u *getSect, Bit32u *getSectSize); 61 | Bit8u GetBiosType(void); 62 | Bit32u getSectSize(void); 63 | #ifdef C_DBP_SUPPORT_DISK_MOUNT_DOSFILE 64 | imageDisk(class DOS_File *imgFile, const char *imgName, Bit32u imgSizeK, bool isHardDisk); 65 | ~imageDisk(); 66 | Bit32u Read_Raw(Bit8u *buffer, Bit32u seek, Bit32u len); 67 | void SetDifferencingDisk(const char* savePath); 68 | #else 69 | imageDisk(FILE *imgFile, const char *imgName, Bit32u imgSizeK, bool isHardDisk); 70 | ~imageDisk() { if(diskimg != NULL) { fclose(diskimg); } }; 71 | #endif 72 | #ifdef C_DBP_SUPPORT_DISK_FAT_EMULATOR 73 | imageDisk(class DOS_Drive *useDrive, Bit32u freeSpaceMB = 0, const char* savePath = NULL, Bit32u driveSerial = 0, const StringToPointerHashMap* fileFilter = NULL); 74 | void Set_GeometryForHardDisk(); 75 | #endif 76 | 77 | bool hardDrive; 78 | bool active; 79 | #ifdef C_DBP_SUPPORT_DISK_MOUNT_DOSFILE 80 | class DOS_File* dos_file; 81 | #else 82 | FILE *diskimg; 83 | #endif 84 | char diskname[512]; 85 | Bit8u floppytype; 86 | 87 | Bit32u sector_size; 88 | Bit32u heads,cylinders,sectors; 89 | private: 90 | #ifdef C_DBP_SUPPORT_DISK_MOUNT_DOSFILE 91 | Bit64u current_fpos; 92 | #ifdef C_DBP_SUPPORT_DISK_FAT_EMULATOR 93 | struct fatFromDOSDrive* ffdd = NULL; 94 | #endif 95 | struct discardDisk* discard = NULL; 96 | struct differencingDisk* differencing = NULL; 97 | #else 98 | Bit32u current_fpos; 99 | #endif 100 | enum { NONE,READ,WRITE } last_action; 101 | }; 102 | 103 | void updateDPT(void); 104 | void incrementFDD(void); 105 | 106 | //DBP: Increased from 2 to 4 107 | #define MAX_HDD_IMAGES 4 108 | 109 | #define MAX_DISK_IMAGES (2 + MAX_HDD_IMAGES) 110 | 111 | extern imageDisk *imageDiskList[MAX_DISK_IMAGES]; 112 | #ifdef C_DBP_ENABLE_DISKSWAP 113 | extern imageDisk *diskSwap[MAX_SWAPPABLE_DISKS]; 114 | extern Bit32s swapPosition; 115 | #endif 116 | extern Bit16u imgDTASeg; /* Real memory location of temporary DTA pointer for fat image disk access */ 117 | extern RealPt imgDTAPtr; /* Real memory location of temporary DTA pointer for fat image disk access */ 118 | extern DOS_DTA *imgDTA; 119 | 120 | #ifdef C_DBP_ENABLE_DISKSWAP 121 | void swapInDisks(void); 122 | void swapInNextDisk(void); 123 | #endif 124 | bool getSwapRequest(void); 125 | 126 | #endif 127 | -------------------------------------------------------------------------------- /include/callback.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | 20 | #ifndef DOSBOX_CALLBACK_H 21 | #define DOSBOX_CALLBACK_H 22 | 23 | #ifndef DOSBOX_MEM_H 24 | #include "mem.h" 25 | #endif 26 | 27 | typedef Bitu (*CallBack_Handler)(void); 28 | extern CallBack_Handler CallBack_Handlers[]; 29 | 30 | enum { CB_RETN,CB_RETF,CB_RETF8,CB_RETF_STI,CB_RETF_CLI, 31 | CB_IRET,CB_IRETD,CB_IRET_STI,CB_IRET_EOI_PIC1, 32 | CB_IRQ0,CB_IRQ1,CB_IRQ9,CB_IRQ12,CB_IRQ12_RET,CB_IRQ6_PCJR,CB_MOUSE, 33 | CB_INT29,CB_INT16,CB_HOOKABLE,CB_TDE_IRET,CB_IPXESR,CB_IPXESR_RET, 34 | CB_INT21,CB_INT13,CB_VESA_WAIT,CB_VESA_PM }; 35 | 36 | #define CB_MAX 128 37 | #define CB_SIZE 32 38 | #define CB_SEG 0xF000 39 | #define CB_SOFFSET 0x1000 40 | 41 | enum { 42 | CBRET_NONE=0,CBRET_STOP=1 43 | }; 44 | 45 | extern Bit8u lastint; 46 | 47 | static INLINE RealPt CALLBACK_RealPointer(Bitu callback) { 48 | return RealMake(CB_SEG,(Bit16u)(CB_SOFFSET+callback*CB_SIZE)); 49 | } 50 | static INLINE PhysPt CALLBACK_PhysPointer(Bitu callback) { 51 | return PhysMake(CB_SEG,(Bit16u)(CB_SOFFSET+callback*CB_SIZE)); 52 | } 53 | 54 | static INLINE PhysPt CALLBACK_GetBase(void) { 55 | return (CB_SEG << 4) + CB_SOFFSET; 56 | } 57 | 58 | Bitu CALLBACK_Allocate(); 59 | 60 | void CALLBACK_Idle(void); 61 | 62 | 63 | void CALLBACK_RunRealInt(Bit8u intnum); 64 | void CALLBACK_RunRealFar(Bit16u seg,Bit16u off); 65 | 66 | bool CALLBACK_Setup(Bitu callback,CallBack_Handler handler,Bitu type,const char* descr); 67 | Bitu CALLBACK_Setup(Bitu callback,CallBack_Handler handler,Bitu type,PhysPt addr,const char* descr); 68 | 69 | const char* CALLBACK_GetDescription(Bitu callback); 70 | bool CALLBACK_Free(Bitu callback); 71 | 72 | void CALLBACK_SCF(bool val); 73 | void CALLBACK_SZF(bool val); 74 | void CALLBACK_SIF(bool val); 75 | 76 | extern Bitu call_priv_io; 77 | 78 | 79 | class CALLBACK_HandlerObject{ 80 | private: 81 | bool installed; 82 | Bitu m_callback; 83 | enum {NONE,SETUP,SETUPAT} m_type; 84 | struct { 85 | RealPt old_vector; 86 | Bit8u interrupt; 87 | bool installed; 88 | } vectorhandler; 89 | public: 90 | CALLBACK_HandlerObject():installed(false),m_type(NONE) { 91 | vectorhandler.installed=false; 92 | } 93 | ~CALLBACK_HandlerObject(); 94 | 95 | //Install and allocate a callback. 96 | void Install(CallBack_Handler handler,Bitu type,const char* description); 97 | void Install(CallBack_Handler handler,Bitu type,PhysPt addr,const char* description); 98 | #ifdef C_DBP_LIBRETRO 99 | void InstallFixed(Bitu fix_callback, CallBack_Handler handler,Bitu type,const char* description); 100 | #endif 101 | 102 | void Uninstall(); 103 | 104 | //Only allocate a callback number 105 | void Allocate(CallBack_Handler handler,const char* description=0); 106 | Bit16u Get_callback() { 107 | return (Bit16u)m_callback; 108 | } 109 | RealPt Get_RealPointer() { 110 | return CALLBACK_RealPointer(m_callback); 111 | } 112 | void Set_RealVec(Bit8u vec); 113 | }; 114 | #endif 115 | -------------------------------------------------------------------------------- /include/control.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | 20 | #ifndef DOSBOX_CONTROL_H 21 | #define DOSBOX_CONTROL_H 22 | 23 | #ifdef _MSC_VER 24 | #pragma warning ( disable : 4786 ) 25 | #pragma warning ( disable : 4290 ) 26 | #endif 27 | 28 | #ifndef DOSBOX_PROGRAMS_H 29 | #include "programs.h" 30 | #endif 31 | #ifndef DOSBOX_SETUP_H 32 | #include "setup.h" 33 | #endif 34 | 35 | #ifndef CH_LIST 36 | #define CH_LIST 37 | #include 38 | #endif 39 | 40 | #ifndef CH_VECTOR 41 | #define CH_VECTOR 42 | #include 43 | #endif 44 | 45 | #ifndef CH_STRING 46 | #define CH_STRING 47 | #include 48 | #endif 49 | 50 | 51 | 52 | 53 | class Config{ 54 | public: 55 | #ifdef C_DBP_NATIVE_CONFIGFILE 56 | CommandLine * cmdline; 57 | #endif 58 | private: 59 | std::list sectionlist; 60 | typedef std::list::iterator it; 61 | typedef std::list::reverse_iterator reverse_it; 62 | typedef std::list::const_iterator const_it; 63 | typedef std::list::const_reverse_iterator const_reverse_it; 64 | void (* _start_function)(void); 65 | bool secure_mode; //Sandbox mode 66 | public: 67 | bool initialised; 68 | #ifdef C_DBP_NATIVE_CONFIGFILE 69 | std::vector startup_params; 70 | std::vector configfiles; 71 | Config(CommandLine * cmd):cmdline(cmd),secure_mode(false) { 72 | startup_params.push_back(cmdline->GetFileName()); 73 | cmdline->FillVector(startup_params); 74 | initialised=false; 75 | } 76 | #else 77 | friend class CONFIG; 78 | Config():secure_mode(false),initialised(false) {} 79 | #endif 80 | ~Config(); 81 | 82 | Section_line * AddSection_line(char const * const _name,void (*_initfunction)(Section*)); 83 | Section_prop * AddSection_prop(char const * const _name,void (*_initfunction)(Section*),bool canchange=false); 84 | 85 | Section* GetSection(int index); 86 | #ifdef C_DBP_LIBRETRO 87 | Section* GetSection(char const * const _sectionname) const; 88 | Property* GetProp(char const * const _sectionname, char const * const _property) const; 89 | #endif 90 | Section* GetSection(std::string const&_sectionname) const; 91 | Section* GetSectionFromProperty(char const * const prop) const; 92 | 93 | void SetStartUp(void (*_function)(void)); 94 | void Init(); 95 | void ShutDown(); 96 | void StartUp(); 97 | bool PrintConfig(char const * const configfilename) const; 98 | bool ParseConfigFile(char const * const configfilename); 99 | void ParseEnv(char ** envp); 100 | bool SecureMode() const { return secure_mode; } 101 | void SwitchToSecureMode() { secure_mode = true; }//can't be undone 102 | }; 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /include/dbp_network.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * Copyright (C) 2023 Bernhard Schelling 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program; if not, write to the Free Software Foundation, Inc., 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef DOSBOX_DBP_NETWORK_H 21 | #define DOSBOX_DBP_NETWORK_H 22 | 23 | #include "config.h" 24 | 25 | #ifdef C_DBP_ENABLE_LIBRETRO_MODEM 26 | #include "serialport.h" 27 | 28 | // Based on CSoftModem and CNullModem 29 | struct CModemBuf { enum { BUFSIZE = 1024 }; Bit8u buf[BUFSIZE]; Bit16u p_in, p_out; }; // If queue size is too high you overflow terminal clients buffers i think 30 | struct CLibretroDualModem : public CSerial 31 | { 32 | CLibretroDualModem(Bitu id, CommandLine* cmd); 33 | virtual void handleUpperEvent(Bit16u type); 34 | virtual void updateMSR(); 35 | virtual void setRTSDTR(bool rts, bool dtr); 36 | virtual void setRTS(bool val); 37 | virtual void setDTR(bool val); 38 | virtual void transmitByte(Bit8u val, bool first); 39 | virtual void setBreak(bool value); 40 | virtual void updatePortConfig(Bit16u divider, Bit8u lcr); 41 | 42 | void SM_SetState(bool set_connected, bool do_reset = false); 43 | void SM_SendRes(int response); 44 | void SM_DoCommand(); 45 | void SM_Poll(); 46 | void NM_DoSend(Bit8u val, bool is_escape); 47 | bool NM_DoReceive(); 48 | 49 | enum { MODE_DETECT, MODE_SOFTMODEM, MODE_NULLMODEM } mode; 50 | 51 | CModemBuf rbuf, tbuf; 52 | Bit8u tmpbuf[CModemBuf::BUFSIZE]; 53 | 54 | enum { SREGS = 100 }; 55 | struct { 56 | char cmdbuf[128]; 57 | bool commandmode, echo, numericresponse, ringing, connected; 58 | Bit8u reg[SREGS], doresponse, plusinc, waiting_tx_character, cmdpos, flowcontrol; 59 | Bit16u cmdpause, ringtimer; 60 | } sm; 61 | struct { 62 | Bit8u rx_state; 63 | bool transparent; // if true, don't send 0xff 0xXX to toggle DSR/CTS. 64 | Bit16u rx_retry; // counter of retries 65 | Bit16u rx_retry_max; // how many POLL_EVENTS to wait before causing a overrun error. 66 | //bool tx_block; // true while the SERIAL_TX_REDUCTION event is pending 67 | //Bit16u tx_gather; // how long to gather tx data before sending all of them [milliseconds] 68 | } nm; 69 | }; 70 | 71 | typedef CLibretroDualModem CLibretroModem; 72 | #endif 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /include/dbp_threads.h: -------------------------------------------------------------------------------- 1 | #define DBP_STACK_SIZE (2*1024*1024) //2 MB 2 | #ifdef WIN32 3 | #define WIN32_LEAN_AND_MEAN 4 | #include 5 | #define THREAD_CC WINAPI 6 | struct Thread { typedef DWORD RET_t; typedef RET_t (THREAD_CC *FUNC_t)(LPVOID); static void StartDetached(FUNC_t f, void* p = NULL) { HANDLE h = CreateThread(0,DBP_STACK_SIZE,f,p,0,0); CloseHandle(h); } }; 7 | struct Mutex { Mutex() : h(CreateMutexA(0,0,0)) {} ~Mutex() { CloseHandle(h); } __inline void Lock() { WaitForSingleObject(h,INFINITE); } __inline void Unlock() { ReleaseMutex(h); } private:HANDLE h;Mutex(const Mutex&);Mutex& operator=(const Mutex&);}; 8 | struct Semaphore { Semaphore() : h(CreateSemaphoreA(0,0,1,0)) {} ~Semaphore() { CloseHandle(h); } __inline void Post() { BOOL r = ReleaseSemaphore(h, 1, 0); DBP_ASSERT(r); } __inline void Wait() { WaitForSingleObject(h,INFINITE); } private:HANDLE h;Semaphore(const Semaphore&);Semaphore& operator=(const Semaphore&);}; 9 | #else 10 | #if defined(WIIU) 11 | #include "../libretro-common/rthreads/wiiu_pthread.h" 12 | #elif defined(GEKKO) 13 | #include "../libretro-common/rthreads/gx_pthread.h" 14 | #elif defined(_3DS) 15 | #include "../libretro-common/rthreads/ctr_pthread.h" 16 | #else 17 | #include 18 | #endif 19 | #define THREAD_CC 20 | struct Thread { typedef void* RET_t; typedef RET_t (THREAD_CC *FUNC_t)(void*); static void StartDetached(FUNC_t f, void* p = NULL) { pthread_t h = 0; pthread_attr_t a; pthread_attr_init(&a); pthread_attr_setstacksize(&a, DBP_STACK_SIZE); pthread_create(&h, &a, f, p); pthread_attr_destroy(&a); pthread_detach(h); } }; 21 | struct Mutex { Mutex() { pthread_mutex_init(&h,0); } ~Mutex() { pthread_mutex_destroy(&h); } __inline void Lock() { pthread_mutex_lock(&h); } __inline void Unlock() { pthread_mutex_unlock(&h); } private:pthread_mutex_t h;Mutex(const Mutex&);Mutex& operator=(const Mutex&);friend struct Conditional;}; 22 | struct Conditional { Conditional() { pthread_cond_init(&h,0); } ~Conditional() { pthread_cond_destroy(&h); } __inline void Broadcast() { pthread_cond_broadcast(&h); } __inline void Wait(Mutex& m) { pthread_cond_wait(&h,&m.h); } private:pthread_cond_t h;Conditional(const Conditional&);Conditional& operator=(const Conditional&);}; 23 | struct Semaphore { Semaphore() : v(0) {} __inline void Post() { m.Lock(); v = 1; c.Broadcast(); m.Unlock(); } __inline void Wait() { m.Lock(); while (!v) c.Wait(m); v = 0; m.Unlock(); } private:Mutex m;Conditional c;int v;Semaphore(const Semaphore&);Semaphore& operator=(const Semaphore&);}; 24 | #endif 25 | -------------------------------------------------------------------------------- /include/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | void DEBUG_SetupConsole(void); 20 | void DEBUG_DrawScreen(void); 21 | bool DEBUG_Breakpoint(void); 22 | bool DEBUG_IntBreakpoint(Bit8u intNum); 23 | void DEBUG_Enable(bool pressed); 24 | void DEBUG_CheckExecuteBreakpoint(Bit16u seg, Bit32u off); 25 | bool DEBUG_ExitLoop(void); 26 | void DEBUG_RefreshPage(char scroll); 27 | Bitu DEBUG_EnableDebugger(void); 28 | 29 | extern Bitu cycle_count; 30 | extern Bitu debugCallback; 31 | 32 | #ifdef C_HEAVY_DEBUG 33 | bool DEBUG_HeavyIsBreakpoint(void); 34 | void DEBUG_HeavyWriteLogInstruction(void); 35 | #endif 36 | -------------------------------------------------------------------------------- /include/dma.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | 20 | #ifndef DOSBOX_DMA_H 21 | #define DOSBOX_DMA_H 22 | 23 | enum DMAEvent { 24 | DMA_REACHED_TC, 25 | DMA_MASKED, 26 | DMA_UNMASKED, 27 | // DMA_TRANSFEREND, this shouldn't really be a ignal 28 | }; 29 | 30 | class DmaChannel; 31 | typedef void (* DMA_CallBack)(DmaChannel * chan,DMAEvent event); 32 | 33 | class DmaChannel { 34 | public: 35 | Bit32u pagebase; 36 | Bit16u baseaddr; 37 | Bit32u curraddr; 38 | Bit16u basecnt; 39 | Bit16u currcnt; 40 | Bit8u channum; 41 | Bit8u pagenum; 42 | Bit8u DMA16; 43 | bool increment; 44 | bool autoinit; 45 | // Bit8u trantype; //Not used at the moment 46 | bool masked; 47 | bool tcount; 48 | bool request; 49 | DMA_CallBack callback; 50 | 51 | DmaChannel(Bit8u num, bool dma16); 52 | void DoCallBack(DMAEvent event) { 53 | if (callback) (*callback)(this,event); 54 | } 55 | void SetMask(bool _mask) { 56 | masked=_mask; 57 | DoCallBack(masked ? DMA_MASKED : DMA_UNMASKED); 58 | } 59 | void Register_Callback(DMA_CallBack _cb) { 60 | callback = _cb; 61 | SetMask(masked); 62 | if (callback) Raise_Request(); 63 | else Clear_Request(); 64 | } 65 | void ReachedTC(void) { 66 | tcount=true; 67 | DoCallBack(DMA_REACHED_TC); 68 | } 69 | void SetPage(Bit8u val) { 70 | pagenum=val; 71 | pagebase=(pagenum >> DMA16) << (16+DMA16); 72 | } 73 | void Raise_Request(void) { 74 | request=true; 75 | } 76 | void Clear_Request(void) { 77 | request=false; 78 | } 79 | Bitu Read(Bitu size, Bit8u * buffer); 80 | Bitu Write(Bitu size, Bit8u * buffer); 81 | }; 82 | 83 | class DmaController { 84 | private: 85 | Bit8u ctrlnum; 86 | bool flipflop; 87 | DmaChannel *DmaChannels[4]; 88 | public: 89 | IO_ReadHandleObject DMA_ReadHandler[0x12]; 90 | IO_WriteHandleObject DMA_WriteHandler[0x12]; 91 | DmaController(Bit8u num) { 92 | flipflop = false; 93 | ctrlnum = num; /* first or second DMA controller */ 94 | for(Bit8u i=0;i<4;i++) { 95 | DmaChannels[i] = new DmaChannel(i+ctrlnum*4,ctrlnum==1); 96 | } 97 | } 98 | ~DmaController(void) { 99 | for(Bit8u i=0;i<4;i++) { 100 | delete DmaChannels[i]; 101 | } 102 | } 103 | DmaChannel * GetChannel(Bit8u chan) { 104 | if (chan<4) return DmaChannels[chan]; 105 | else return NULL; 106 | } 107 | void WriteControllerReg(Bitu reg,Bitu val,Bitu len); 108 | Bitu ReadControllerReg(Bitu reg,Bitu len); 109 | 110 | friend void DBPSerialize(struct DBPArchive& ar, DmaController* self); 111 | }; 112 | 113 | DmaChannel * GetDMAChannel(Bit8u chan); 114 | 115 | void CloseSecondDMAController(void); 116 | bool SecondDMAControllerAvailable(void); 117 | 118 | void DMA_SetWrapping(Bitu wrap); 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /include/dosbox.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | 20 | #ifndef DOSBOX_DOSBOX_H 21 | #define DOSBOX_DOSBOX_H 22 | 23 | #include "config.h" 24 | 25 | #ifdef C_DBP_USE_SDL 26 | GCC_ATTRIBUTE(noreturn) 27 | #endif 28 | void E_Exit(const char * message,...) GCC_ATTRIBUTE( __format__(__printf__, 1, 2)); 29 | 30 | void MSG_Add(const char*,const char*); //add messages to the internal languagefile 31 | const char* MSG_Get(char const *); //get messages from the internal languagefile 32 | 33 | class Section; 34 | 35 | typedef Bitu (LoopHandler)(void); 36 | 37 | void DOSBOX_RunMachine(); 38 | void DOSBOX_SetLoop(LoopHandler * handler); 39 | void DOSBOX_SetNormalLoop(); 40 | 41 | void DOSBOX_Init(void); 42 | 43 | class Config; 44 | extern Config * control; 45 | 46 | enum MachineType { 47 | MCH_HERC, 48 | MCH_CGA, 49 | MCH_TANDY, 50 | MCH_PCJR, 51 | MCH_EGA, 52 | MCH_VGA 53 | }; 54 | 55 | enum SVGACards { 56 | SVGA_None, 57 | SVGA_S3Trio, 58 | SVGA_TsengET4K, 59 | SVGA_TsengET3K, 60 | SVGA_ParadisePVGA1A 61 | }; 62 | 63 | extern SVGACards svgaCard; 64 | extern MachineType machine; 65 | #ifdef C_DBP_USE_SDL 66 | extern bool SDLNetInited; 67 | #endif 68 | 69 | #define IS_TANDY_ARCH ((machine==MCH_TANDY) || (machine==MCH_PCJR)) 70 | #define IS_EGAVGA_ARCH ((machine==MCH_EGA) || (machine==MCH_VGA)) 71 | #define IS_VGA_ARCH (machine==MCH_VGA) 72 | #define TANDY_ARCH_CASE MCH_TANDY: case MCH_PCJR 73 | #define EGAVGA_ARCH_CASE MCH_EGA: case MCH_VGA 74 | #define VGA_ARCH_CASE MCH_VGA 75 | 76 | #ifndef DOSBOX_LOGGING_H 77 | #include "logging.h" 78 | #endif // the logging system. 79 | 80 | #endif /* DOSBOX_DOSBOX_H */ 81 | -------------------------------------------------------------------------------- /include/fpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef DOSBOX_FPU_H 20 | #define DOSBOX_FPU_H 21 | 22 | #ifndef DOSBOX_DOSBOX_H 23 | //So the right config.h gets included for C_DEBUG 24 | #include "dosbox.h" 25 | #endif 26 | 27 | #ifndef DOSBOX_MEM_H 28 | #include "mem.h" 29 | #endif 30 | 31 | void FPU_ESC0_Normal(Bitu rm); 32 | void FPU_ESC0_EA(Bitu func,PhysPt ea); 33 | void FPU_ESC1_Normal(Bitu rm); 34 | void FPU_ESC1_EA(Bitu func,PhysPt ea); 35 | void FPU_ESC2_Normal(Bitu rm); 36 | void FPU_ESC2_EA(Bitu func,PhysPt ea); 37 | void FPU_ESC3_Normal(Bitu rm); 38 | void FPU_ESC3_EA(Bitu func,PhysPt ea); 39 | void FPU_ESC4_Normal(Bitu rm); 40 | void FPU_ESC4_EA(Bitu func,PhysPt ea); 41 | void FPU_ESC5_Normal(Bitu rm); 42 | void FPU_ESC5_EA(Bitu func,PhysPt ea); 43 | void FPU_ESC6_Normal(Bitu rm); 44 | void FPU_ESC6_EA(Bitu func,PhysPt ea); 45 | void FPU_ESC7_Normal(Bitu rm); 46 | void FPU_ESC7_EA(Bitu func,PhysPt ea); 47 | 48 | 49 | typedef union { 50 | double d; 51 | #ifndef WORDS_BIGENDIAN 52 | struct { 53 | Bit32u lower; 54 | Bit32s upper; 55 | } l; 56 | #else 57 | struct { 58 | Bit32s upper; 59 | Bit32u lower; 60 | } l; 61 | #endif 62 | Bit64s ll; 63 | } FPU_Reg; 64 | 65 | typedef struct { 66 | Bit32u m1; 67 | Bit32u m2; 68 | Bit16u m3; 69 | 70 | Bit16u d1; 71 | Bit32u d2; 72 | } FPU_P_Reg; 73 | 74 | enum FPU_Tag { 75 | TAG_Valid = 0, 76 | TAG_Zero = 1, 77 | TAG_Weird = 2, 78 | TAG_Empty = 3 79 | }; 80 | 81 | enum FPU_Round { 82 | ROUND_Nearest = 0, 83 | ROUND_Down = 1, 84 | ROUND_Up = 2, 85 | ROUND_Chop = 3 86 | }; 87 | 88 | typedef struct FPU_rec { 89 | FPU_Reg regs[9]; 90 | FPU_P_Reg p_regs[9]; 91 | FPU_Tag tags[9]; 92 | Bit16u cw,cw_mask_all; 93 | Bit16u sw; 94 | Bit32u top; 95 | FPU_Round round; 96 | } FPU_rec; 97 | 98 | 99 | //get pi from a real library 100 | #define PI 3.14159265358979323846 101 | #define L2E 1.4426950408889634 102 | #define L2T 3.3219280948873623 103 | #define LN2 0.69314718055994531 104 | #define LG2 0.3010299956639812 105 | 106 | 107 | extern FPU_rec fpu; 108 | extern Bit64s fpu_r64s[9]; 109 | 110 | #define TOP fpu.top 111 | #define STV(i) ( (fpu.top+ (i) ) & 7 ) 112 | 113 | 114 | Bit16u FPU_GetTag(void); 115 | void FPU_FLDCW(PhysPt addr); 116 | 117 | static INLINE void FPU_SetTag(Bit16u tag){ 118 | for(Bitu i=0;i<8;i++) 119 | fpu.tags[i] = static_cast((tag >>(2*i))&3); 120 | } 121 | 122 | static INLINE void FPU_SetCW(Bitu word){ 123 | fpu.cw = (Bit16u)word; 124 | fpu.cw_mask_all = (Bit16u)(word | 0x3f); 125 | fpu.round = (FPU_Round)((word >> 10) & 3); 126 | } 127 | 128 | 129 | static INLINE Bitu FPU_GET_TOP(void) { 130 | return (fpu.sw & 0x3800)>>11; 131 | } 132 | 133 | static INLINE void FPU_SET_TOP(Bitu val){ 134 | fpu.sw &= ~0x3800; 135 | fpu.sw |= (val&7)<<11; 136 | } 137 | 138 | 139 | static INLINE void FPU_SET_C0(Bitu C){ 140 | fpu.sw &= ~0x0100; 141 | if(C) fpu.sw |= 0x0100; 142 | } 143 | 144 | static INLINE void FPU_SET_C1(Bitu C){ 145 | fpu.sw &= ~0x0200; 146 | if(C) fpu.sw |= 0x0200; 147 | } 148 | 149 | static INLINE void FPU_SET_C2(Bitu C){ 150 | fpu.sw &= ~0x0400; 151 | if(C) fpu.sw |= 0x0400; 152 | } 153 | 154 | static INLINE void FPU_SET_C3(Bitu C){ 155 | fpu.sw &= ~0x4000; 156 | if(C) fpu.sw |= 0x4000; 157 | } 158 | 159 | static INLINE void FPU_LOG_WARN(Bitu tree, bool ea, Bitu group, Bitu sub) { 160 | LOG(LOG_FPU,LOG_WARN)("ESC %" sBitfs(d) "%s:Unhandled group %" sBitfs(d) " subfunction %" sBitfs(d),tree,ea?" EA":"",group,sub); 161 | } 162 | 163 | #define DB_FPU_STACK_CHECK_NONE 0 164 | #define DB_FPU_STACK_CHECK_LOG 1 165 | #define DB_FPU_STACK_CHECK_EXIT 2 166 | //NONE is 0.74 behavior: not care about stack overflow/underflow 167 | //Overflow is always logged/exited on. 168 | //Underflow can be controlled with by this. 169 | //LOG is giving a message when encountered 170 | //EXIT is to hard exit. 171 | //Currently pop is ignored in release mode and overflow is exit. 172 | //in debug mode: pop will log and overflow is exit. 173 | #if C_DEBUG 174 | #define DB_FPU_STACK_CHECK_POP DB_FPU_STACK_CHECK_LOG 175 | #define DB_FPU_STACK_CHECK_PUSH DB_FPU_STACK_CHECK_EXIT 176 | #elif defined(C_DBP_LIBRETRO) 177 | #define DB_FPU_STACK_CHECK_POP DB_FPU_STACK_CHECK_NONE 178 | #define DB_FPU_STACK_CHECK_PUSH DB_FPU_STACK_CHECK_NONE 179 | #else 180 | #define DB_FPU_STACK_CHECK_POP DB_FPU_STACK_CHECK_NONE 181 | #define DB_FPU_STACK_CHECK_PUSH DB_FPU_STACK_CHECK_EXIT 182 | #endif 183 | 184 | #endif 185 | -------------------------------------------------------------------------------- /include/hardware.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | 20 | #ifndef DOSBOX_HARDWARE_H 21 | #define DOSBOX_HARDWARE_H 22 | 23 | #include 24 | 25 | class Section; 26 | enum OPL_Mode { 27 | OPL_none,OPL_cms,OPL_opl2,OPL_dualopl2,OPL_opl3,OPL_opl3gold 28 | }; 29 | 30 | #ifdef C_DBP_ENABLE_CAPTURE 31 | #define CAPTURE_WAVE 0x01 32 | #define CAPTURE_OPL 0x02 33 | #define CAPTURE_MIDI 0x04 34 | #define CAPTURE_IMAGE 0x08 35 | #define CAPTURE_VIDEO 0x10 36 | 37 | extern Bitu CaptureState; 38 | #endif 39 | 40 | void OPL_Init(Section* sec,OPL_Mode mode); 41 | void CMS_Init(Section* sec); 42 | void OPL_ShutDown(Section* sec); 43 | void CMS_ShutDown(Section* sec); 44 | 45 | bool SB_Get_Address(Bitu& sbaddr, Bitu& sbirq, Bitu& sbdma); 46 | bool TS_Get_Address(Bitu& tsaddr, Bitu& tsirq, Bitu& tsdma); 47 | 48 | extern Bit8u adlib_commandreg; 49 | 50 | #ifdef C_DBP_ENABLE_CAPTURE 51 | FILE * OpenCaptureFile(const char * type,const char * ext); 52 | 53 | void CAPTURE_AddWave(Bit32u freq, Bitu len, Bit16s * data); 54 | #define CAPTURE_FLAG_DBLW 0x1 55 | #define CAPTURE_FLAG_DBLH 0x2 56 | #define CAPTURE_FLAG_DUPLICATE 0x4 57 | void CAPTURE_AddImage(Bitu width, Bitu height, Bitu bpp, Bitu pitch, Bitu flags, float fps, const Bit8u * data, const Bit8u * pal); 58 | void CAPTURE_AddMidi(bool sysex, Bitu len, Bit8u * data); 59 | void CAPTURE_VideoStart(); 60 | void CAPTURE_VideoStop(); 61 | #endif 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /include/inout.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | 20 | #ifndef DOSBOX_INOUT_H 21 | #define DOSBOX_INOUT_H 22 | 23 | #define IO_MAX (64*1024+3) 24 | 25 | #define IO_MB 0x1 26 | #define IO_MW 0x2 27 | #define IO_MD 0x4 28 | #define IO_MA (IO_MB | IO_MW | IO_MD ) 29 | 30 | typedef Bitu IO_ReadHandler(Bitu port,Bitu iolen); 31 | typedef void IO_WriteHandler(Bitu port,Bitu val,Bitu iolen); 32 | 33 | extern IO_WriteHandler * io_writehandlers[3][IO_MAX]; 34 | extern IO_ReadHandler * io_readhandlers[3][IO_MAX]; 35 | 36 | void IO_RegisterReadHandler(Bitu port,IO_ReadHandler * handler,Bitu mask,Bitu range=1); 37 | void IO_RegisterWriteHandler(Bitu port,IO_WriteHandler * handler,Bitu mask,Bitu range=1); 38 | 39 | void IO_FreeReadHandler(Bitu port,Bitu mask,Bitu range=1); 40 | void IO_FreeWriteHandler(Bitu port,Bitu mask,Bitu range=1); 41 | 42 | void IO_WriteB(Bitu port,Bitu val); 43 | void IO_WriteW(Bitu port,Bitu val); 44 | void IO_WriteD(Bitu port,Bitu val); 45 | 46 | Bitu IO_ReadB(Bitu port); 47 | Bitu IO_ReadW(Bitu port); 48 | Bitu IO_ReadD(Bitu port); 49 | 50 | /* Classes to manage the IO objects created by the various devices. 51 | * The io objects will remove itself on destruction.*/ 52 | class IO_Base{ 53 | protected: 54 | bool installed; 55 | Bitu m_port, m_mask,m_range; 56 | public: 57 | IO_Base():installed(false){}; 58 | }; 59 | class IO_ReadHandleObject: private IO_Base{ 60 | public: 61 | void Install(Bitu port,IO_ReadHandler * handler,Bitu mask,Bitu range=1); 62 | void Uninstall(); 63 | ~IO_ReadHandleObject(); 64 | }; 65 | class IO_WriteHandleObject: private IO_Base{ 66 | public: 67 | void Install(Bitu port,IO_WriteHandler * handler,Bitu mask,Bitu range=1); 68 | void Uninstall(); 69 | ~IO_WriteHandleObject(); 70 | }; 71 | 72 | static INLINE void IO_Write(Bitu port,Bit8u val) { 73 | IO_WriteB(port,val); 74 | } 75 | static INLINE Bit8u IO_Read(Bitu port){ 76 | return (Bit8u)IO_ReadB(port); 77 | } 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /include/ipx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | 20 | #ifndef DOSBOX_IPX_H 21 | #define DOSBOX_IPX_H 22 | 23 | // Uncomment this for a lot of debug messages: 24 | //#define IPX_DEBUGMSG 25 | 26 | #ifdef IPX_DEBUGMSG 27 | #define LOG_IPX LOG_MSG 28 | #else 29 | #if defined (_MSC_VER) 30 | #define LOG_IPX 31 | #else 32 | #define LOG_IPX(...) 33 | #endif 34 | #endif 35 | 36 | #ifndef DOSBOX_DOSBOX_H 37 | #include "dosbox.h" 38 | #endif 39 | #ifndef DOSBOX_MEM_H 40 | #include "mem.h" 41 | #endif 42 | 43 | // In Use Flag codes 44 | #define USEFLAG_AVAILABLE 0x00 45 | #define USEFLAG_AESTEMP 0xe0 46 | #define USEFLAG_IPXCRIT 0xf8 47 | #define USEFLAG_SPXLISTEN 0xf9 48 | #define USEFLAG_PROCESSING 0xfa 49 | #define USEFLAG_HOLDING 0xfb 50 | #define USEFLAG_AESWAITING 0xfc 51 | #define USEFLAG_AESCOUNT 0xfd 52 | #define USEFLAG_LISTENING 0xfe 53 | #define USEFLAG_SENDING 0xff 54 | 55 | // Completion codes 56 | #define COMP_SUCCESS 0x00 57 | #define COMP_REMOTETERM 0xec 58 | #define COMP_DISCONNECT 0xed 59 | #define COMP_INVALIDID 0xee 60 | #define COMP_SPXTABLEFULL 0xef 61 | #define COMP_EVENTNOTCANCELED 0xf9 62 | #define COMP_NOCONNECTION 0xfa 63 | #define COMP_CANCELLED 0xfc 64 | #define COMP_MALFORMED 0xfd 65 | #define COMP_UNDELIVERABLE 0xfe 66 | #define COMP_HARDWAREERROR 0xff 67 | 68 | #ifdef _MSC_VER 69 | #pragma pack(1) 70 | #endif 71 | 72 | // For Uint8 type 73 | #include "SDL_net.h" 74 | 75 | struct PackedIP { 76 | Uint32 host; 77 | Uint16 port; 78 | } GCC_ATTRIBUTE(packed); 79 | 80 | struct nodeType { 81 | Uint8 node[6]; 82 | } GCC_ATTRIBUTE(packed) ; 83 | 84 | struct IPXHeader { 85 | Uint8 checkSum[2]; 86 | Uint8 length[2]; 87 | Uint8 transControl; // Transport control 88 | Uint8 pType; // Packet type 89 | 90 | struct transport { 91 | Uint8 network[4]; 92 | union addrtype { 93 | nodeType byNode; 94 | PackedIP byIP ; 95 | } GCC_ATTRIBUTE(packed) addr; 96 | Uint8 socket[2]; 97 | } dest, src; 98 | } GCC_ATTRIBUTE(packed); 99 | 100 | struct fragmentDescriptor { 101 | Bit16u offset; 102 | Bit16u segment; 103 | Bit16u size; 104 | }; 105 | 106 | #define IPXBUFFERSIZE 1424 107 | 108 | class ECBClass { 109 | public: 110 | RealPt ECBAddr; 111 | bool isInESRList; 112 | ECBClass *prevECB; // Linked List 113 | ECBClass *nextECB; 114 | 115 | Bit8u iuflag; // Need to save data since we are not always in 116 | Bit16u mysocket; // real mode 117 | 118 | Bit8u* databuffer; // received data is stored here until we get called 119 | Bitu buflen; // by Interrupt 120 | 121 | #ifdef IPX_DEBUGMSG 122 | Bitu SerialNumber; 123 | #endif 124 | 125 | ECBClass(Bit16u segment, Bit16u offset); 126 | Bit16u getSocket(void); 127 | 128 | Bit8u getInUseFlag(void); 129 | 130 | void setInUseFlag(Bit8u flagval); 131 | 132 | void setCompletionFlag(Bit8u flagval); 133 | 134 | Bit16u getFragCount(void); 135 | 136 | bool writeData(); 137 | void writeDataBuffer(Bit8u* buffer, Bit16u length); 138 | 139 | void getFragDesc(Bit16u descNum, fragmentDescriptor *fragDesc); 140 | RealPt getESRAddr(void); 141 | 142 | void NotifyESR(void); 143 | 144 | void setImmAddress(Bit8u *immAddr); 145 | void getImmAddress(Bit8u* immAddr); 146 | 147 | ~ECBClass(); 148 | }; 149 | 150 | // The following routines may not be needed on all systems. On my build of SDL the IPaddress structure is 8 octects 151 | // and therefore screws up my IPXheader structure since it needs to be packed. 152 | 153 | void UnpackIP(PackedIP ipPack, IPaddress * ipAddr); 154 | void PackIP(IPaddress ipAddr, PackedIP *ipPack); 155 | 156 | #ifdef _MSC_VER 157 | #pragma pack() 158 | #endif 159 | 160 | #endif 161 | -------------------------------------------------------------------------------- /include/ipxserver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef DOSBOX_IPXSERVER_H_ 20 | #define DOSBOX_IPXSERVER_H_ 21 | 22 | #if C_IPX 23 | 24 | #include "SDL_net.h" 25 | 26 | struct packetBuffer { 27 | Bit8u buffer[1024]; 28 | Bit16s packetSize; // Packet size remaining in read 29 | Bit16s packetRead; // Bytes read of total packet 30 | bool inPacket; // In packet reception flag 31 | bool connected; // Connected flag 32 | bool waitsize; 33 | }; 34 | 35 | #define SOCKETTABLESIZE 16 36 | #define CONVIP(hostvar) hostvar & 0xff, (hostvar >> 8) & 0xff, (hostvar >> 16) & 0xff, (hostvar >> 24) & 0xff 37 | #define CONVIPX(hostvar) hostvar[0], hostvar[1], hostvar[2], hostvar[3], hostvar[4], hostvar[5] 38 | 39 | 40 | void IPX_StopServer(); 41 | bool IPX_StartServer(Bit16u portnum); 42 | bool IPX_isConnectedToServer(Bits tableNum, IPaddress ** ptrAddr); 43 | 44 | Bit8u packetCRC(Bit8u *buffer, Bit16u bufSize); 45 | 46 | #endif 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /include/joystick.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef DOSBOX_JOYSTICK_H 20 | #define DOSBOX_JOYSTICK_H 21 | void JOYSTICK_Enable(Bitu which,bool enabled); 22 | 23 | void JOYSTICK_Button(Bitu which,Bitu num,bool pressed); 24 | 25 | void JOYSTICK_Move_X(Bitu which,float x); 26 | 27 | void JOYSTICK_Move_Y(Bitu which,float y); 28 | 29 | bool JOYSTICK_IsEnabled(Bitu which); 30 | 31 | bool JOYSTICK_GetButton(Bitu which, Bitu num); 32 | 33 | float JOYSTICK_GetMove_X(Bitu which); 34 | 35 | float JOYSTICK_GetMove_Y(Bitu which); 36 | 37 | enum JoystickType { 38 | JOY_NONE, 39 | JOY_AUTO, 40 | JOY_2AXIS, 41 | JOY_4AXIS, 42 | JOY_4AXIS_2, 43 | JOY_FCS, 44 | JOY_CH 45 | }; 46 | 47 | extern JoystickType joytype; 48 | extern bool button_wrapping_enabled; 49 | #endif 50 | -------------------------------------------------------------------------------- /include/keyboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef DOSBOX_KEYBOARD_H 20 | #define DOSBOX_KEYBOARD_H 21 | 22 | enum KBD_KEYS { 23 | KBD_NONE, 24 | KBD_1, KBD_2, KBD_3, KBD_4, KBD_5, KBD_6, KBD_7, KBD_8, KBD_9, KBD_0, 25 | KBD_q, KBD_w, KBD_e, KBD_r, KBD_t, KBD_y, KBD_u, KBD_i, KBD_o, KBD_p, 26 | KBD_a, KBD_s, KBD_d, KBD_f, KBD_g, KBD_h, KBD_j, KBD_k, KBD_l, KBD_z, 27 | KBD_x, KBD_c, KBD_v, KBD_b, KBD_n, KBD_m, 28 | KBD_f1, KBD_f2, KBD_f3, KBD_f4, KBD_f5, KBD_f6, KBD_f7, KBD_f8, KBD_f9, KBD_f10,KBD_f11,KBD_f12, 29 | 30 | /*Now the weirder keys */ 31 | 32 | KBD_esc,KBD_tab,KBD_backspace,KBD_enter,KBD_space, 33 | KBD_leftalt,KBD_rightalt,KBD_leftctrl,KBD_rightctrl,KBD_leftshift,KBD_rightshift, 34 | KBD_capslock,KBD_scrolllock,KBD_numlock, 35 | 36 | KBD_grave,KBD_minus,KBD_equals,KBD_backslash,KBD_leftbracket,KBD_rightbracket, 37 | KBD_semicolon,KBD_quote,KBD_period,KBD_comma,KBD_slash,KBD_extra_lt_gt, 38 | 39 | KBD_printscreen,KBD_pause, 40 | KBD_insert,KBD_home,KBD_pageup,KBD_delete,KBD_end,KBD_pagedown, 41 | KBD_left,KBD_up,KBD_down,KBD_right, 42 | 43 | KBD_kp1,KBD_kp2,KBD_kp3,KBD_kp4,KBD_kp5,KBD_kp6,KBD_kp7,KBD_kp8,KBD_kp9,KBD_kp0, 44 | KBD_kpdivide,KBD_kpmultiply,KBD_kpminus,KBD_kpplus,KBD_kpenter,KBD_kpperiod, 45 | 46 | 47 | KBD_LAST 48 | }; 49 | 50 | // DBP: Added for syncing host LEDs (and states) with DOSBox 51 | enum KBD_LEDS : Bit8u { 52 | KLED_SCROLLLOCK = 0x01, 53 | KLED_NUMLOCK = 0x02, 54 | KLED_CAPSLOCK = 0x04, 55 | }; 56 | extern KBD_LEDS biosKeyLEDOverwrite; 57 | void BIOS_SetKeyboardLEDOverwrite(KBD_KEYS event_key, KBD_LEDS leds); 58 | 59 | void KEYBOARD_ClrBuffer(void); 60 | void KEYBOARD_AddKey(KBD_KEYS keytype,bool pressed); 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /include/logging.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef DOSBOX_LOGGING_H 20 | #define DOSBOX_LOGGING_H 21 | enum LOG_TYPES { 22 | LOG_ALL, 23 | LOG_VGA, LOG_VGAGFX,LOG_VGAMISC,LOG_INT10, 24 | LOG_SB,LOG_DMACONTROL, 25 | LOG_FPU,LOG_CPU,LOG_PAGING, 26 | LOG_FCB,LOG_FILES,LOG_IOCTL,LOG_EXEC,LOG_DOSMISC, 27 | LOG_PIT,LOG_KEYBOARD,LOG_PIC, 28 | LOG_MOUSE,LOG_BIOS,LOG_GUI,LOG_MISC, 29 | LOG_IO, 30 | LOG_PCI, 31 | LOG_MAX 32 | }; 33 | 34 | enum LOG_SEVERITIES { 35 | LOG_NORMAL, 36 | LOG_WARN, 37 | LOG_ERROR 38 | }; 39 | 40 | #if C_DEBUG 41 | class LOG 42 | { 43 | LOG_TYPES d_type; 44 | LOG_SEVERITIES d_severity; 45 | public: 46 | 47 | LOG (LOG_TYPES type , LOG_SEVERITIES severity): 48 | d_type(type), 49 | d_severity(severity) 50 | {} 51 | void operator() (char const* buf, ...) GCC_ATTRIBUTE(__format__(__printf__, 2, 3)); //../src/debug/debug_gui.cpp 52 | 53 | }; 54 | 55 | void DEBUG_ShowMsg(char const* format,...) GCC_ATTRIBUTE(__format__(__printf__, 1, 2)); 56 | #define LOG_MSG DEBUG_ShowMsg 57 | 58 | #else //C_DEBUG 59 | //#include 60 | //#include 61 | struct LOG 62 | { 63 | INLINE LOG(LOG_TYPES , LOG_SEVERITIES ) { } 64 | #if 1 // DBP replaced to avoid warnings 65 | INLINE void operator() (char const* buf, ...) {} //{va_list va;va_start(va, buf);vprintf(buf, va);printf("\n");va_end(va);} 66 | #else 67 | void operator()(char const* ) { } 68 | void operator()(char const* , double ) { } 69 | void operator()(char const* , double , double ) { } 70 | void operator()(char const* , double , double , double ) { } 71 | void operator()(char const* , double , double , double , double ) { } 72 | void operator()(char const* , double , double , double , double , double ) { } 73 | void operator()(char const* , double , double , double , double , double , double ) { } 74 | void operator()(char const* , double , double , double , double , double , double , double) { } 75 | 76 | 77 | 78 | void operator()(char const* , char const* ) { } 79 | void operator()(char const* , char const* , double ) { } 80 | void operator()(char const* , char const* , double ,double ) { } 81 | void operator()(char const* , double , char const* ) { } 82 | void operator()(char const* , double , double, char const* ) { } 83 | void operator()(char const* , char const*, char const*) { } 84 | 85 | void operator()(char const* , double , double , double , char const* ) { } 86 | void operator()(char const* , double, char const*, double, double ) {} 87 | #endif 88 | }; //add missing operators to here 89 | //try to avoid anything smaller than bit32... 90 | void GFX_ShowMsg(char const* format,...) GCC_ATTRIBUTE(__format__(__printf__, 1, 2)); 91 | #define LOG_MSG GFX_ShowMsg 92 | 93 | #endif //C_DEBUG 94 | 95 | 96 | #endif //DOSBOX_LOGGING_H 97 | -------------------------------------------------------------------------------- /include/mapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef DOSBOX_MAPPER_H 20 | #define DOSBOX_MAPPER_H 21 | 22 | #include "config.h" 23 | #ifdef C_DBP_ENABLE_MAPPER 24 | 25 | enum MapKeys { 26 | MK_f1,MK_f2,MK_f3,MK_f4,MK_f5,MK_f6,MK_f7,MK_f8,MK_f9,MK_f10,MK_f11,MK_f12, 27 | MK_return,MK_kpminus,MK_scrolllock,MK_printscreen,MK_pause,MK_home 28 | 29 | }; 30 | 31 | typedef void (MAPPER_Handler)(bool pressed); 32 | void MAPPER_AddHandler(MAPPER_Handler * handler,MapKeys key,Bitu mods,char const * const eventname,char const * const buttonname); 33 | void MAPPER_Init(void); 34 | void MAPPER_StartUp(Section * sec); 35 | void MAPPER_Run(bool pressed); 36 | void MAPPER_RunInternal(); 37 | void MAPPER_LosingFocus(void); 38 | 39 | 40 | #define MMOD1 0x1 41 | #define MMOD2 0x2 42 | 43 | #endif // C_DBP_ENABLE_MAPPER 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /include/midi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | 20 | #ifndef DOSBOX_MIDI_H 21 | #define DOSBOX_MIDI_H 22 | 23 | #ifndef DOSBOX_DOSBOX_H 24 | #include "dosbox.h" 25 | #endif 26 | 27 | #ifndef DOSBOX_PROGRAMS_H 28 | #include "programs.h" 29 | #endif 30 | 31 | class MidiHandler { 32 | public: 33 | MidiHandler(); 34 | virtual bool Open(const char * /*conf*/) { 35 | LOG_MSG("No working midi device found/selected! Please check your settings and/or compilation environment."); 36 | return true; 37 | }; 38 | virtual void Close(void) {}; 39 | virtual void PlayMsg(Bit8u * /*msg*/) {}; 40 | virtual void PlaySysex(Bit8u * /*sysex*/,Bitu /*len*/) {}; 41 | virtual const char * GetName(void) { return "none"; }; 42 | virtual void ListAll(Program * base) {}; 43 | virtual ~MidiHandler() { }; 44 | MidiHandler * next; 45 | }; 46 | 47 | 48 | #define SYSEX_SIZE 8192 49 | struct DB_Midi { 50 | Bitu status; 51 | Bitu cmd_len; 52 | Bitu cmd_pos; 53 | Bit8u cmd_buf[8]; 54 | Bit8u rt_buf[8]; 55 | struct { 56 | Bit8u buf[SYSEX_SIZE]; 57 | Bitu used; 58 | Bitu delay; 59 | Bit32u start; 60 | } sysex; 61 | bool available; 62 | MidiHandler * handler; 63 | 64 | //DBP: Added used flag and cache for serialization 65 | bool ever_used; 66 | struct { 67 | Bit8u preset_bank[2], preset; 68 | Bit8u pitch_tuning[3][2], pitch[2]; 69 | Bit8u control[96]; 70 | Bit8u rpn[2], rpn_data[3][2]; 71 | } cache[16]; 72 | }; 73 | 74 | extern DB_Midi midi; 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /include/mixer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | 20 | #ifndef DOSBOX_MIXER_H 21 | #define DOSBOX_MIXER_H 22 | 23 | #ifndef DOSBOX_DOSBOX_H 24 | #include "dosbox.h" 25 | #endif 26 | 27 | typedef void (*MIXER_MixHandler)(Bit8u * sampdate,Bit32u len); 28 | typedef void (*MIXER_Handler)(Bitu len); 29 | 30 | enum BlahModes { 31 | MIXER_8MONO,MIXER_8STEREO, 32 | MIXER_16MONO,MIXER_16STEREO 33 | }; 34 | 35 | enum MixerModes { 36 | M_8M,M_8S, 37 | M_16M,M_16S 38 | }; 39 | 40 | #define MIXER_BUFSIZE (16*1024) 41 | #define MIXER_BUFMASK (MIXER_BUFSIZE-1) 42 | extern Bit8u MixTemp[MIXER_BUFSIZE]; 43 | 44 | #define MAX_AUDIO ((1<<(16-1))-1) 45 | #define MIN_AUDIO -(1<<(16-1)) 46 | 47 | class MixerChannel { 48 | public: 49 | void SetVolume(float _left,float _right); 50 | void SetScale( float f ); 51 | void UpdateVolume(void); 52 | void SetFreq(Bitu _freq); 53 | void Mix(Bitu _needed); 54 | void AddSilence(void); //Fill up until needed 55 | 56 | template 57 | void AddSamples(Bitu len, const Type* data); 58 | 59 | void AddSamples_m8(Bitu len, const Bit8u * data); 60 | void AddSamples_s8(Bitu len, const Bit8u * data); 61 | void AddSamples_m8s(Bitu len, const Bit8s * data); 62 | void AddSamples_s8s(Bitu len, const Bit8s * data); 63 | void AddSamples_m16(Bitu len, const Bit16s * data); 64 | void AddSamples_s16(Bitu len, const Bit16s * data); 65 | void AddSamples_m16u(Bitu len, const Bit16u * data); 66 | void AddSamples_s16u(Bitu len, const Bit16u * data); 67 | void AddSamples_m32(Bitu len, const Bit32s * data); 68 | void AddSamples_s32(Bitu len, const Bit32s * data); 69 | void AddSamples_m16_nonnative(Bitu len, const Bit16s * data); 70 | void AddSamples_s16_nonnative(Bitu len, const Bit16s * data); 71 | void AddSamples_m16u_nonnative(Bitu len, const Bit16u * data); 72 | void AddSamples_s16u_nonnative(Bitu len, const Bit16u * data); 73 | void AddSamples_m32_nonnative(Bitu len, const Bit32s * data); 74 | void AddSamples_s32_nonnative(Bitu len, const Bit32s * data); 75 | 76 | void AddStretched(Bitu len,Bit16s * data); //Strech block up into needed data 77 | 78 | void FillUp(void); 79 | void Enable(bool _yesno); 80 | MIXER_Handler handler; 81 | float volmain[2]; 82 | float scale; 83 | Bit32s volmul[2]; 84 | 85 | //This gets added the frequency counter each mixer step 86 | Bitu freq_add; 87 | //When this flows over a new sample needs to be read from the device 88 | Bitu freq_counter; 89 | //Timing on how many samples have been done and were needed by th emixer 90 | Bitu done, needed; 91 | //Previous and next samples 92 | Bits prevSample[2]; 93 | Bits nextSample[2]; 94 | //Simple way to lower the impact of DC offset. if MIXER_UPRAMP_STEPS is >0. 95 | //Still work in progress and thus disabled for now. 96 | Bits offset[2]; 97 | const char * name; 98 | bool interpolate; 99 | bool enabled; 100 | bool ever_enabled; //DBP: added for serialization 101 | bool last_samples_were_stereo; 102 | bool last_samples_were_silence; 103 | MixerChannel * next; 104 | }; 105 | 106 | MixerChannel * MIXER_AddChannel(MIXER_Handler handler,Bitu freq,const char * name); 107 | MixerChannel * MIXER_FindChannel(const char * name); 108 | /* Find the device you want to delete with findchannel "delchan gets deleted" */ 109 | void MIXER_DelChannel(MixerChannel* delchan); 110 | 111 | /* Object to maintain a mixerchannel; As all objects it registers itself with create 112 | * and removes itself when destroyed. */ 113 | class MixerObject{ 114 | private: 115 | bool installed; 116 | char m_name[32]; 117 | public: 118 | MixerObject():installed(false){}; 119 | MixerChannel* Install(MIXER_Handler handler,Bitu freq,const char * name); 120 | ~MixerObject(); 121 | }; 122 | 123 | 124 | /* PC Speakers functions, tightly related to the timer functions */ 125 | void PCSPEAKER_SetCounter(Bitu cntr,Bitu mode); 126 | void PCSPEAKER_SetType(Bitu mode); 127 | 128 | #endif 129 | -------------------------------------------------------------------------------- /include/mouse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | 20 | 21 | #ifndef DOSBOX_MOUSE_H 22 | #define DOSBOX_MOUSE_H 23 | 24 | 25 | void Mouse_ShowCursor(void); 26 | void Mouse_HideCursor(void); 27 | 28 | bool Mouse_SetPS2State(bool use); 29 | 30 | void Mouse_ChangePS2Callback(Bit16u pseg, Bit16u pofs); 31 | 32 | 33 | void Mouse_CursorMoved(float xrel,float yrel,float x,float y,bool emulate); 34 | void Mouse_CursorSet(float x,float y); 35 | void Mouse_ButtonPressed(Bit8u button); 36 | void Mouse_ButtonReleased(Bit8u button); 37 | 38 | #ifdef C_DBP_ENABLE_AUTOLOCK 39 | void Mouse_AutoLock(bool enable); 40 | #else 41 | #define Mouse_AutoLock(dummy) 42 | #endif 43 | void Mouse_BeforeNewVideoMode(bool setmode); 44 | void Mouse_AfterNewVideoMode(bool setmode); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /include/pci_bus.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef DOSBOX_PCI_H 20 | #define DOSBOX_PCI_H 21 | 22 | #include "config.h" 23 | #ifdef C_DBP_ENABLE_VOODOO 24 | #define PCI_FUNCTIONALITY_ENABLED 1 25 | #else 26 | //#define PCI_FUNCTIONALITY_ENABLED 0 27 | #endif 28 | 29 | #if defined PCI_FUNCTIONALITY_ENABLED 30 | 31 | #ifdef C_DBP_LIBRETRO 32 | // Reduced to be just as much as needed 33 | #define PCI_MAX_PCIDEVICES 2 34 | #define PCI_MAX_PCIFUNCTIONS 2 35 | #else 36 | #define PCI_MAX_PCIDEVICES 10 37 | #define PCI_MAX_PCIFUNCTIONS 8 38 | #endif 39 | 40 | 41 | class PCI_Device { 42 | protected: 43 | Bits pci_id, pci_subfunction; 44 | Bit16u vendor_id, device_id; 45 | 46 | // subdevices declarations, they will respond to pci functions 1 to 7 47 | // (main device is attached to function 0) 48 | Bitu num_subdevices; 49 | PCI_Device* subdevices[PCI_MAX_PCIFUNCTIONS-1]; 50 | 51 | public: 52 | PCI_Device(Bit16u vendor, Bit16u device); 53 | 54 | Bits PCIId(void) { 55 | return pci_id; 56 | } 57 | Bits PCISubfunction(void) { 58 | return pci_subfunction; 59 | } 60 | Bit16u VendorID(void) { 61 | return vendor_id; 62 | } 63 | Bit16u DeviceID(void) { 64 | return device_id; 65 | } 66 | 67 | void SetPCIId(Bitu number, Bits subfct); 68 | 69 | bool AddSubdevice(PCI_Device* dev); 70 | void RemoveSubdevice(Bits subfct); 71 | 72 | PCI_Device* GetSubdevice(Bits subfct); 73 | 74 | Bit16u NumSubdevices(void) { 75 | if (num_subdevices>PCI_MAX_PCIFUNCTIONS-1) return (Bit16u)(PCI_MAX_PCIFUNCTIONS-1); 76 | return (Bit16u)num_subdevices; 77 | } 78 | 79 | Bits GetNextSubdeviceNumber(void) { 80 | if (num_subdevices>=PCI_MAX_PCIFUNCTIONS-1) return -1; 81 | return (Bits)num_subdevices+1; 82 | } 83 | 84 | virtual Bits ParseReadRegister(Bit8u regnum)=0; 85 | virtual bool OverrideReadRegister(Bit8u regnum, Bit8u* rval, Bit8u* rval_mask)=0; 86 | virtual Bits ParseWriteRegister(Bit8u regnum,Bit8u value)=0; 87 | virtual bool InitializeRegisters(Bit8u registers[256])=0; 88 | 89 | }; 90 | 91 | bool PCI_IsInitialized(); 92 | 93 | RealPt PCI_GetPModeInterface(void); 94 | 95 | #endif 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /include/pic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef DOSBOX_PIC_H 20 | #define DOSBOX_PIC_H 21 | 22 | 23 | /* CPU Cycle Timing */ 24 | extern Bit32s CPU_Cycles; 25 | extern Bit32s CPU_CycleLeft; 26 | extern Bit32s CPU_CycleMax; 27 | 28 | typedef void (PIC_EOIHandler) (void); 29 | typedef void (* PIC_EventHandler)(Bitu val); 30 | 31 | 32 | extern Bitu PIC_IRQCheck; 33 | extern Bitu PIC_Ticks; 34 | 35 | static INLINE float PIC_TickIndex(void) { 36 | return (CPU_CycleMax-CPU_CycleLeft-CPU_Cycles)/(float)CPU_CycleMax; 37 | } 38 | 39 | static INLINE Bits PIC_TickIndexND(void) { 40 | return CPU_CycleMax-CPU_CycleLeft-CPU_Cycles; 41 | } 42 | 43 | static INLINE Bits PIC_MakeCycles(double amount) { 44 | return (Bits)(CPU_CycleMax*amount); 45 | } 46 | 47 | static INLINE double PIC_FullIndex(void) { 48 | return PIC_Ticks+(double)PIC_TickIndex(); 49 | } 50 | 51 | void PIC_ActivateIRQ(Bitu irq); 52 | void PIC_DeActivateIRQ(Bitu irq); 53 | 54 | void PIC_runIRQs(void); 55 | bool PIC_RunQueue(void); 56 | 57 | //Delay in milliseconds 58 | void PIC_AddEvent(PIC_EventHandler handler,float delay,Bitu val=0); 59 | void PIC_RemoveEvents(PIC_EventHandler handler); 60 | void PIC_RemoveSpecificEvents(PIC_EventHandler handler, Bitu val); 61 | 62 | void PIC_SetIRQMask(Bitu irq, bool masked); 63 | #endif 64 | -------------------------------------------------------------------------------- /include/programs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | 20 | #ifndef DOSBOX_PROGRAMS_H 21 | #define DOSBOX_PROGRAMS_H 22 | 23 | #ifndef DOSBOX_DOSBOX_H 24 | #include "dosbox.h" 25 | #endif 26 | #ifndef DOSBOX_DOS_INC_H 27 | #include "dos_inc.h" 28 | #endif 29 | 30 | #ifndef CH_LIST 31 | #define CH_LIST 32 | #include 33 | #endif 34 | 35 | #ifndef CH_STRING 36 | #define CH_STRING 37 | #include 38 | #endif 39 | 40 | class CommandLine { 41 | public: 42 | CommandLine(int argc,char const * const argv[]); 43 | CommandLine(char const * const name,char const * const cmdline); 44 | const char * GetFileName(){ return file_name.c_str();} 45 | 46 | bool FindExist(char const * const name,bool remove=false); 47 | bool FindHex(char const * const name,unsigned int & value,bool remove=false); 48 | bool FindInt(char const * const name,int & value,bool remove=false); 49 | bool FindString(char const * const name,std::string & value,bool remove=false); 50 | bool FindCommand(unsigned int which,std::string & value); 51 | bool FindStringBegin(char const * const begin,std::string & value, bool remove=false); 52 | bool FindStringRemain(char const * const name,std::string & value); 53 | bool FindStringRemainBegin(char const * const name,std::string & value); 54 | bool GetStringRemain(std::string & value); 55 | int GetParameterFromList(const char* const params[], std::vector & output); 56 | void FillVector(std::vector & vector); 57 | unsigned int GetCount(void); 58 | void Shift(unsigned int amount=1); 59 | Bit16u Get_arglength(); 60 | 61 | private: 62 | typedef std::list::iterator cmd_it; 63 | std::list cmds; 64 | std::string file_name; 65 | bool FindEntry(char const * const name,cmd_it & it,bool neednext=false); 66 | }; 67 | 68 | class Program { 69 | public: 70 | Program(); 71 | virtual ~Program(){ 72 | delete cmd; 73 | delete psp; 74 | } 75 | std::string temp_line; 76 | CommandLine * cmd; 77 | DOS_PSP * psp; 78 | virtual void Run(void)=0; 79 | bool GetEnvStr(const char * entry,std::string & result); 80 | bool GetEnvNum(Bitu num,std::string & result); 81 | Bitu GetEnvCount(void); 82 | bool SetEnv(const char * entry,const char * new_string); 83 | void WriteOut(const char * format,...); /* Write to standard output */ 84 | void WriteOut_NoParsing(const char * format); /* Write to standard output, no parsing */ 85 | void ChangeToLongCmd(); 86 | 87 | }; 88 | 89 | typedef void (PROGRAMS_Main)(Program * * make); 90 | void PROGRAMS_MakeFile(char const * const name,PROGRAMS_Main * main); 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /include/regs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef DOSBOX_REGS_H 20 | #define DOSBOX_REGS_H 21 | 22 | #ifndef DOSBOX_MEM_H 23 | #include "mem.h" 24 | #endif 25 | 26 | #define FLAG_CF 0x00000001 27 | #define FLAG_PF 0x00000004 28 | #define FLAG_AF 0x00000010 29 | #define FLAG_ZF 0x00000040 30 | #define FLAG_SF 0x00000080 31 | #define FLAG_OF 0x00000800 32 | 33 | #define FLAG_TF 0x00000100 34 | #define FLAG_IF 0x00000200 35 | #define FLAG_DF 0x00000400 36 | 37 | #define FLAG_IOPL 0x00003000 38 | #define FLAG_NT 0x00004000 39 | #define FLAG_VM 0x00020000 40 | #define FLAG_AC 0x00040000 41 | #define FLAG_ID 0x00200000 42 | 43 | #define FMASK_TEST (FLAG_CF | FLAG_PF | FLAG_AF | FLAG_ZF | FLAG_SF | FLAG_OF) 44 | #define FMASK_NORMAL (FMASK_TEST | FLAG_DF | FLAG_TF | FLAG_IF ) 45 | #define FMASK_ALL (FMASK_NORMAL | FLAG_IOPL | FLAG_NT) 46 | 47 | #define SETFLAGBIT(TYPE,TEST) if (TEST) reg_flags|=FLAG_ ## TYPE; else reg_flags&=~FLAG_ ## TYPE 48 | 49 | #define GETFLAG(TYPE) (reg_flags & FLAG_ ## TYPE) 50 | #define GETFLAGBOOL(TYPE) ((reg_flags & FLAG_ ## TYPE) ? true : false ) 51 | 52 | #define GETFLAG_IOPL ((reg_flags & FLAG_IOPL) >> 12) 53 | 54 | struct Segment { 55 | Bit16u val; 56 | PhysPt phys; /* The phyiscal address start in emulated machine */ 57 | }; 58 | 59 | enum SegNames { es=0,cs,ss,ds,fs,gs}; 60 | 61 | struct Segments { 62 | Bit16u val[8]; 63 | PhysPt phys[8]; 64 | }; 65 | 66 | union GenReg32 { 67 | Bit32u dword[1]; 68 | Bit16u word[2]; 69 | Bit8u byte[4]; 70 | }; 71 | 72 | #ifdef WORDS_BIGENDIAN 73 | 74 | #define DW_INDEX 0 75 | #define W_INDEX 1 76 | #define BH_INDEX 2 77 | #define BL_INDEX 3 78 | 79 | #else 80 | 81 | #define DW_INDEX 0 82 | #define W_INDEX 0 83 | #define BH_INDEX 1 84 | #define BL_INDEX 0 85 | 86 | #endif 87 | 88 | struct CPU_Regs { 89 | GenReg32 regs[8],ip; 90 | Bitu flags; 91 | }; 92 | 93 | extern Segments Segs; 94 | extern CPU_Regs cpu_regs; 95 | 96 | static INLINE PhysPt SegPhys(SegNames index) { 97 | return Segs.phys[index]; 98 | } 99 | 100 | static INLINE Bit16u SegValue(SegNames index) { 101 | return (Bit16u)Segs.val[index]; 102 | } 103 | 104 | static INLINE RealPt RealMakeSeg(SegNames index,Bit16u off) { 105 | return RealMake(SegValue(index),off); 106 | } 107 | 108 | 109 | static INLINE void SegSet16(Bitu index,Bit16u val) { 110 | Segs.val[index]=val; 111 | Segs.phys[index]=val << 4; 112 | } 113 | 114 | enum { 115 | REGI_AX, REGI_CX, REGI_DX, REGI_BX, 116 | REGI_SP, REGI_BP, REGI_SI, REGI_DI 117 | }; 118 | 119 | enum { 120 | REGI_AL, REGI_CL, REGI_DL, REGI_BL, 121 | REGI_AH, REGI_CH, REGI_DH, REGI_BH 122 | }; 123 | 124 | 125 | //macros to convert a 3-bit register index to the correct register 126 | #define reg_8l(reg) (cpu_regs.regs[(reg)].byte[BL_INDEX]) 127 | #define reg_8h(reg) (cpu_regs.regs[(reg)].byte[BH_INDEX]) 128 | #define reg_8(reg) ((reg) & 4 ? reg_8h((reg) & 3) : reg_8l((reg) & 3)) 129 | #define reg_16(reg) (cpu_regs.regs[(reg)].word[W_INDEX]) 130 | #define reg_32(reg) (cpu_regs.regs[(reg)].dword[DW_INDEX]) 131 | 132 | #define reg_al cpu_regs.regs[REGI_AX].byte[BL_INDEX] 133 | #define reg_ah cpu_regs.regs[REGI_AX].byte[BH_INDEX] 134 | #define reg_ax cpu_regs.regs[REGI_AX].word[W_INDEX] 135 | #define reg_eax cpu_regs.regs[REGI_AX].dword[DW_INDEX] 136 | 137 | #define reg_bl cpu_regs.regs[REGI_BX].byte[BL_INDEX] 138 | #define reg_bh cpu_regs.regs[REGI_BX].byte[BH_INDEX] 139 | #define reg_bx cpu_regs.regs[REGI_BX].word[W_INDEX] 140 | #define reg_ebx cpu_regs.regs[REGI_BX].dword[DW_INDEX] 141 | 142 | #define reg_cl cpu_regs.regs[REGI_CX].byte[BL_INDEX] 143 | #define reg_ch cpu_regs.regs[REGI_CX].byte[BH_INDEX] 144 | #define reg_cx cpu_regs.regs[REGI_CX].word[W_INDEX] 145 | #define reg_ecx cpu_regs.regs[REGI_CX].dword[DW_INDEX] 146 | 147 | #define reg_dl cpu_regs.regs[REGI_DX].byte[BL_INDEX] 148 | #define reg_dh cpu_regs.regs[REGI_DX].byte[BH_INDEX] 149 | #define reg_dx cpu_regs.regs[REGI_DX].word[W_INDEX] 150 | #define reg_edx cpu_regs.regs[REGI_DX].dword[DW_INDEX] 151 | 152 | #define reg_si cpu_regs.regs[REGI_SI].word[W_INDEX] 153 | #define reg_esi cpu_regs.regs[REGI_SI].dword[DW_INDEX] 154 | 155 | #define reg_di cpu_regs.regs[REGI_DI].word[W_INDEX] 156 | #define reg_edi cpu_regs.regs[REGI_DI].dword[DW_INDEX] 157 | 158 | #define reg_sp cpu_regs.regs[REGI_SP].word[W_INDEX] 159 | #define reg_esp cpu_regs.regs[REGI_SP].dword[DW_INDEX] 160 | 161 | #define reg_bp cpu_regs.regs[REGI_BP].word[W_INDEX] 162 | #define reg_ebp cpu_regs.regs[REGI_BP].dword[DW_INDEX] 163 | 164 | #define reg_ip cpu_regs.ip.word[W_INDEX] 165 | #define reg_eip cpu_regs.ip.dword[DW_INDEX] 166 | 167 | #define reg_flags cpu_regs.flags 168 | 169 | #endif 170 | -------------------------------------------------------------------------------- /include/render.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef DOSBOX_RENDER_H 20 | #define DOSBOX_RENDER_H 21 | 22 | // 0: complex scalers off, scaler cache off, some simple scalers off, memory requirements reduced 23 | // 1: complex scalers off, scaler cache off, all simple scalers on 24 | // 2: complex scalers off, scaler cache on 25 | // 3: complex scalers on 26 | #ifdef C_DBP_ENABLE_SCALERS 27 | #define RENDER_USE_ADVANCED_SCALERS 3 28 | #else 29 | #define RENDER_USE_ADVANCED_SCALERS 0 30 | #endif 31 | 32 | #include "../src/gui/render_scalers.h" 33 | 34 | #define RENDER_SKIP_CACHE 16 35 | //Enable this for scalers to support 0 input for empty lines 36 | //#define RENDER_NULL_INPUT 37 | 38 | typedef struct { 39 | struct { 40 | Bit8u red; 41 | Bit8u green; 42 | Bit8u blue; 43 | Bit8u unused; 44 | } rgb[256]; 45 | union { 46 | Bit16u b16[256]; 47 | Bit32u b32[256]; 48 | } lut; 49 | bool changed; 50 | Bit8u modified[256]; 51 | Bitu first; 52 | Bitu last; 53 | } RenderPal_t; 54 | 55 | typedef struct { 56 | struct { 57 | Bitu width, start; 58 | Bitu height; 59 | Bitu bpp; 60 | bool dblw,dblh; 61 | double ratio; 62 | float fps; 63 | } src; 64 | struct { 65 | int count; 66 | int max; 67 | #if 0 68 | Bitu index; 69 | Bit8u hadSkip[RENDER_SKIP_CACHE]; 70 | #endif 71 | } frameskip; 72 | struct { 73 | #ifdef C_DBP_ENABLE_SCALERS 74 | Bitu size; 75 | #endif 76 | scalerMode_t inMode; 77 | scalerMode_t outMode; 78 | #ifdef C_DBP_ENABLE_SCALERS 79 | scalerOperation_t op; 80 | #ifdef C_DBP_ENABLE_SCALERCACHE 81 | bool clearCache; 82 | #endif 83 | bool forced; 84 | #endif 85 | ScalerLineHandler_t lineHandler; 86 | ScalerLineHandler_t linePalHandler; 87 | ScalerComplexHandler_t complexHandler; 88 | Bitu blocks, lastBlock; 89 | Bitu outPitch; 90 | Bit8u *outWrite; 91 | #ifdef C_DBP_ENABLE_SCALERCACHE 92 | Bitu cachePitch; 93 | Bit8u *cacheRead; 94 | #endif 95 | Bitu inHeight, inLine, outLine; 96 | } scale; 97 | #if C_OPENGL 98 | char* shader_src; 99 | #endif 100 | RenderPal_t pal; 101 | bool updating; 102 | bool active; 103 | bool aspect; 104 | #ifdef VGA_KEEP_CHANGES 105 | bool fullFrame; 106 | #endif 107 | #if 0 108 | bool forceUpdate; 109 | #endif 110 | } Render_t; 111 | 112 | extern Render_t render; 113 | extern ScalerLineHandler_t RENDER_DrawLine; 114 | void RENDER_SetSize(Bitu width,Bitu height,Bitu bpp,float fps,double ratio,bool dblw,bool dblh); 115 | bool RENDER_StartUpdate(void); 116 | void RENDER_EndUpdate(bool abort); 117 | void RENDER_SetPal(Bit8u entry,Bit8u red,Bit8u green,Bit8u blue); 118 | #if 0 119 | bool RENDER_GetForceUpdate(void); 120 | void RENDER_SetForceUpdate(bool); 121 | #endif 122 | 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /include/shell.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | 20 | #ifndef DOSBOX_SHELL_H 21 | #define DOSBOX_SHELL_H 22 | 23 | #include 24 | #ifndef DOSBOX_DOSBOX_H 25 | #include "dosbox.h" 26 | #endif 27 | #ifndef DOSBOX_PROGRAMS_H 28 | #include "programs.h" 29 | #endif 30 | 31 | #include 32 | #include 33 | 34 | #define CMD_MAXLINE 4096 35 | #define CMD_MAXCMDS 20 36 | #define CMD_OLDSIZE 4096 37 | extern Bitu call_shellstop; 38 | class DOS_Shell; 39 | 40 | /* first_shell is used to add and delete stuff from the shell env 41 | * by "external" programs. (config) */ 42 | extern DOS_Shell * first_shell; 43 | 44 | 45 | class BatchFile { 46 | public: 47 | BatchFile(DOS_Shell * host,char const* const resolved_name,char const* const entered_name, char const * const cmd_line); 48 | virtual ~BatchFile(); 49 | virtual bool ReadLine(char * line); 50 | bool Goto(char * where); 51 | void Shift(void); 52 | Bit16u file_handle; 53 | Bit32u location; 54 | bool echo; 55 | DOS_Shell * shell; 56 | BatchFile * prev; 57 | CommandLine * cmd; 58 | std::string filename; 59 | }; 60 | 61 | class AutoexecEditor; 62 | class DOS_Shell : public Program { 63 | private: 64 | friend class AutoexecEditor; 65 | std::list l_history, l_completion; 66 | 67 | char *completion_start; 68 | Bit16u completion_index; 69 | 70 | public: 71 | 72 | DOS_Shell(); 73 | ~DOS_Shell(); 74 | 75 | void Run(void); 76 | void RunInternal(void); //for command /C 77 | /* A load of subfunctions */ 78 | void ParseLine(char * line); 79 | Bitu GetRedirection(char *s, char **ifn, char **ofn,bool * append); 80 | void InputCommand(char * line); 81 | void ShowPrompt(); 82 | void DoCommand(char * cmd); 83 | bool Execute(char * name,char * args); 84 | /* Checks if it matches a hardware-property */ 85 | bool CheckConfig(char* cmd_in,char*line); 86 | /* Some internal used functions */ 87 | char * Which(char * name); 88 | /* Some supported commands */ 89 | void CMD_HELP(char * args); 90 | void CMD_CLS(char * args); 91 | void CMD_COPY(char * args); 92 | void CMD_DATE(char * args); 93 | void CMD_TIME(char * args); 94 | void CMD_DIR(char * args); 95 | void CMD_DELETE(char * args); 96 | void CMD_ECHO(char * args); 97 | void CMD_EXIT(char * args); 98 | void CMD_MKDIR(char * args); 99 | void CMD_CHDIR(char * args); 100 | void CMD_RMDIR(char * args); 101 | void CMD_SET(char * args); 102 | void CMD_IF(char * args); 103 | void CMD_GOTO(char * args); 104 | void CMD_TYPE(char * args); 105 | void CMD_REM(char * args); 106 | void CMD_RENAME(char * args); 107 | void CMD_CALL(char * args); 108 | void SyntaxError(void); 109 | void CMD_PAUSE(char * args); 110 | void CMD_SUBST(char* args); 111 | void CMD_LOADHIGH(char* args); 112 | void CMD_CHOICE(char * args); 113 | void CMD_ATTRIB(char * args); 114 | void CMD_PATH(char * args); 115 | void CMD_SHIFT(char * args); 116 | void CMD_VER(char * args); 117 | /* The shell's variables */ 118 | Bit16u input_handle; 119 | BatchFile * bf; 120 | bool echo; 121 | bool exit; 122 | bool call; 123 | }; 124 | 125 | struct SHELL_Cmd { 126 | const char * name; /* Command name*/ 127 | Bit32u flags; /* Flags about the command */ 128 | void (DOS_Shell::*handler)(char * args); /* Handler for this command */ 129 | const char * help; /* String with command help */ 130 | }; 131 | 132 | /* Object to manage lines in the autoexec.bat The lines get removed from 133 | * the file if the object gets destroyed. The environment is updated 134 | * as well if the line set a a variable */ 135 | class AutoexecObject{ 136 | private: 137 | bool installed; 138 | std::string buf; 139 | public: 140 | AutoexecObject():installed(false){ }; 141 | void Install(std::string const &in); 142 | void InstallBefore(std::string const &in); 143 | ~AutoexecObject(); 144 | private: 145 | void CreateAutoexec(void); 146 | }; 147 | 148 | #endif 149 | -------------------------------------------------------------------------------- /include/support.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | 20 | #ifndef DOSBOX_SUPPORT_H 21 | #define DOSBOX_SUPPORT_H 22 | 23 | #include 24 | #include 25 | #include 26 | #ifndef DOSBOX_DOSBOX_H 27 | #include "dosbox.h" 28 | #endif 29 | 30 | #if defined (_MSC_VER) /* MS Visual C++ */ 31 | #define strcasecmp(a,b) stricmp(a,b) 32 | #define strncasecmp(a,b,n) _strnicmp(a,b,n) 33 | #endif 34 | 35 | #define safe_strncpy(a,b,n) do { strncpy((a),(b),(n)-1); (a)[(n)-1] = 0; } while (0) 36 | 37 | #ifdef HAVE_STRINGS_H 38 | #include 39 | #endif 40 | 41 | void strreplace(char * str,char o,char n); 42 | char *ltrim(char *str); 43 | char *rtrim(char *str); 44 | char *trim(char * str); 45 | char * upcase(char * str); 46 | char * lowcase(char * str); 47 | 48 | bool ScanCMDBool(char * cmd,char const * const check); 49 | char * ScanCMDRemain(char * cmd); 50 | char * StripWord(char *&cmd); 51 | bool IsDecWord(char * word); 52 | bool IsHexWord(char * word); 53 | Bits ConvDecWord(char * word); 54 | Bits ConvHexWord(char * word); 55 | 56 | void trim(std::string& str); 57 | void upcase(std::string &str); 58 | void lowcase(std::string &str); 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /include/timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef DOSBOX_TIMER_H 20 | #define DOSBOX_TIMER_H 21 | 22 | /* underlying clock rate in HZ */ 23 | #ifdef C_DBP_USE_SDL 24 | #include 25 | #endif 26 | 27 | #define PIT_TICK_RATE 1193182 28 | 29 | #ifdef C_DBP_USE_SDL 30 | #define GetTicks() SDL_GetTicks() 31 | #else 32 | #define GetTicks() DBP_GetTicks() 33 | extern Bit32u DBP_GetTicks(); 34 | #endif 35 | 36 | typedef void (*TIMER_TickHandler)(void); 37 | 38 | /* Register a function that gets called everytime if 1 or more ticks pass */ 39 | void TIMER_AddTickHandler(TIMER_TickHandler handler); 40 | void TIMER_DelTickHandler(TIMER_TickHandler handler); 41 | 42 | /* This will add 1 milliscond to all timers */ 43 | void TIMER_AddTick(void); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /include/video.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2021 The DOSBox Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | 20 | #ifndef DOSBOX_VIDEO_H 21 | #define DOSBOX_VIDEO_H 22 | 23 | #define REDUCE_JOYSTICK_POLLING 24 | 25 | typedef enum { 26 | GFX_CallBackReset, 27 | GFX_CallBackStop, 28 | GFX_CallBackRedraw 29 | } GFX_CallBackFunctions_t; 30 | 31 | typedef void (*GFX_CallBack_t)( GFX_CallBackFunctions_t function ); 32 | 33 | struct GFX_PalEntry { 34 | Bit8u r; 35 | Bit8u g; 36 | Bit8u b; 37 | Bit8u unused; 38 | }; 39 | 40 | #define GFX_CAN_8 0x0001 41 | #define GFX_CAN_15 0x0002 42 | #define GFX_CAN_16 0x0004 43 | #define GFX_CAN_32 0x0008 44 | 45 | #define GFX_LOVE_8 0x0010 46 | #define GFX_LOVE_15 0x0020 47 | #define GFX_LOVE_16 0x0040 48 | #define GFX_LOVE_32 0x0080 49 | 50 | #define GFX_RGBONLY 0x0100 51 | 52 | #define GFX_SCALING 0x1000 53 | #define GFX_HARDWARE 0x2000 54 | 55 | #define GFX_CAN_RANDOM 0x4000 //If the interface can also do random access surface 56 | 57 | void GFX_Events(void); 58 | void GFX_SetPalette(Bitu start,Bitu count,GFX_PalEntry * entries); 59 | Bitu GFX_GetBestMode(Bitu flags); 60 | Bitu GFX_GetRGB(Bit8u red,Bit8u green,Bit8u blue); 61 | Bitu GFX_SetSize(Bitu width,Bitu height,Bitu flags,double scalex,double scaley,GFX_CallBack_t cb); 62 | void GFX_SetShader(const char* src); 63 | 64 | void GFX_ResetScreen(void); 65 | void GFX_Start(void); 66 | void GFX_Stop(void); 67 | void GFX_SwitchFullScreen(void); 68 | bool GFX_StartUpdate(Bit8u * & pixels,Bitu & pitch); 69 | void GFX_EndUpdate( const Bit16u *changedLines ); 70 | void GFX_GetSize(int &width, int &height, bool &fullscreen); 71 | void GFX_LosingFocus(void); 72 | 73 | #ifdef C_DBP_USE_SDL 74 | #if defined (WIN32) 75 | bool GFX_SDLUsingWinDIB(void); 76 | #endif 77 | #endif 78 | 79 | #ifdef C_DBP_ENABLE_MAPPER 80 | #if defined (REDUCE_JOYSTICK_POLLING) 81 | void MAPPER_UpdateJoysticks(void); 82 | #endif 83 | #endif 84 | 85 | /* Mouse related */ 86 | void GFX_CaptureMouse(void); 87 | extern bool mouselocked; //true if mouse is confined to window 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /jni/Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2020-2021 Bernhard Schelling 3 | # 4 | # This program is free software; you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation; either version 2 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License along 15 | # with this program; if not, write to the Free Software Foundation, Inc., 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | # 18 | 19 | LOCAL_PATH := $(call my-dir) 20 | CORE_DIR := $(LOCAL_PATH)/.. 21 | 22 | SOURCES := \ 23 | $(CORE_DIR)/*.cpp \ 24 | $(CORE_DIR)/src/*.cpp \ 25 | $(CORE_DIR)/src/*/*.cpp \ 26 | $(CORE_DIR)/src/*/*/*.cpp 27 | SOURCES := $(wildcard $(SOURCES)) 28 | 29 | LDFLAGS := 30 | 31 | CPUFLAGS := 32 | 33 | ifeq ($(BUILD),DEBUG) 34 | BUILDDIR := debug 35 | CFLAGS := -DDEBUG -D_DEBUG -g -O0 36 | else ifeq ($(BUILD),PROFILE) 37 | BUILDDIR := profile 38 | CFLAGS := -DNDEBUG -O2 39 | else ifeq ($(BUILD),RELEASEDBG) 40 | BUILDDIR := releasedbg 41 | CFLAGS := -DNDEBUG -ggdb -O2 42 | LDFLAGS += -ggdb -O2 43 | else ifeq ($(BUILD),ASAN) 44 | BUILDDIR := asan 45 | CFLAGS := -DDEBUG -D_DEBUG -g -O0 -fsanitize=address -fno-omit-frame-pointer 46 | LDFLAGS += -fsanitize=address -g -O0 47 | else 48 | BUILD := RELEASE 49 | BUILDDIR := release 50 | CFLAGS := -DNDEBUG -O2 -fno-ident 51 | LDFLAGS += -O2 52 | endif 53 | 54 | CFLAGS += $(CPUFLAGS) -std=c++11 -fpic -fomit-frame-pointer -fexceptions -Wno-address-of-packed-member -Wno-format -Wno-switch 55 | CFLAGS += -fvisibility=hidden -ffunction-sections -fdata-sections 56 | CFLAGS += -pthread -D__LIBRETRO__ -Iinclude 57 | 58 | LDFLAGS += $(CPUFLAGS) -shared 59 | 60 | WITH_DYNAREC := 61 | ifeq ($(TARGET_ARCH_ABI), armeabi) 62 | WITH_DYNAREC := oldarm 63 | else ifeq ($(TARGET_ARCH_ABI), armeabi-v7a) 64 | WITH_DYNAREC := arm 65 | else ifeq ($(TARGET_ARCH_ABI), arm64-v8a) 66 | WITH_DYNAREC := arm64 67 | else ifeq ($(TARGET_ARCH_ABI), x86) 68 | WITH_DYNAREC := x86_new 69 | else ifeq ($(TARGET_ARCH_ABI), x86_64) 70 | WITH_DYNAREC := x86_64 71 | else ifeq ($(TARGET_ARCH_ABI), mips) 72 | WITH_DYNAREC := mips 73 | else ifeq ($(TARGET_ARCH_ABI), mips64) 74 | WITH_DYNAREC := mips64 75 | endif 76 | 77 | include $(CLEAR_VARS) 78 | LOCAL_MODULE := retro 79 | LOCAL_SRC_FILES := $(SOURCES) 80 | LOCAL_C_INCLUDES := $(CORE_DIR)/include 81 | LOCAL_CFLAGS := $(CFLAGS) 82 | LOCAL_CPPFLAGS := $(CFLAGS) 83 | LOCAL_LDFLAGS := $(LDFLAGS) #-Wl,-version-script=$(CORE_DIR)/libretro/link.T 84 | LOCAL_LDLIBS := -llog 85 | LOCAL_CPP_FEATURES := rtti 86 | LOCAL_ARM_MODE := arm 87 | include $(BUILD_SHARED_LIBRARY) 88 | -------------------------------------------------------------------------------- /jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_PLATFORM := android-16 2 | APP_STL := c++_static 3 | APP_ABI := armeabi-v7a arm64-v8a 4 | NDK_TOOLCHAIN_VERSION := clang 5 | -------------------------------------------------------------------------------- /keyb2joypad.h: -------------------------------------------------------------------------------- 1 | // Automatically generated from the Keyb2Joypad Project (by Jemy Murphy and bigjim) 2 | 3 | #include "include/config.h" 4 | 5 | struct MAPBucket 6 | { 7 | const Bit8u* idents_compressed; 8 | Bit32u idents_size_compressed; 9 | Bit32u idents_size_uncompressed; 10 | const Bit8u* mappings_compressed; 11 | Bit32u mappings_size_compressed; 12 | Bit32u mappings_size_uncompressed; 13 | Bit32u mappings_action_offset; 14 | }; 15 | 16 | enum { MAP_TABLE_SIZE = 4240, MAP_BUCKETS = 4 }; 17 | extern const Bit32u map_keys[MAP_TABLE_SIZE]; 18 | extern const MAPBucket map_buckets[MAP_BUCKETS]; 19 | -------------------------------------------------------------------------------- /libretro-common/features/features_cpu.c: -------------------------------------------------------------------------------- 1 | #include "features_cpu.inl" 2 | -------------------------------------------------------------------------------- /libretro-common/include/retro_timers.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (retro_timers.h). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __LIBRETRO_COMMON_TIMERS_H 24 | #define __LIBRETRO_COMMON_TIMERS_H 25 | 26 | #if defined(XENON) 27 | #include