├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.am ├── Makefile.in ├── NEWS ├── README ├── README.md ├── THANKS ├── acinclude.m4 ├── aclocal.m4 ├── autogen.sh ├── compile ├── config.guess ├── config.h.in ├── config.sub ├── configure ├── configure.ac ├── depcomp ├── docs ├── Makefile.am ├── Makefile.in ├── PORTING ├── README.video └── dosbox.1 ├── include ├── Makefile.am ├── Makefile.in ├── bios.h ├── bios_disk.h ├── callback.h ├── control.h ├── cpu.h ├── cross.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 ├── mixer.h ├── modules.h ├── mouse.h ├── paging.h ├── pic.h ├── programs.h ├── regs.h ├── render.h ├── serialport.h ├── setup.h ├── shell.h ├── support.h ├── timer.h ├── vga.h └── video.h ├── install-sh ├── kolibrios_build.sh ├── missing ├── src ├── Makefile.am ├── Makefile.in ├── cpu │ ├── Makefile.am │ ├── Makefile.in │ ├── callback.cpp │ ├── core_dyn_x86.cpp │ ├── core_dyn_x86 │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── cache.h │ │ ├── decoder.h │ │ ├── dyn_fpu.h │ │ ├── dyn_fpu_dh.h │ │ ├── helpers.h │ │ ├── risc_x86.h │ │ └── string.h │ ├── core_dynrec.cpp │ ├── core_dynrec │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── cache.h │ │ ├── decoder.h │ │ ├── decoder_basic.h │ │ ├── decoder_opcodes.h │ │ ├── dyn_fpu.h │ │ ├── operators.h │ │ ├── risc_armv4le-common.h │ │ ├── risc_armv4le-o3.h │ │ ├── risc_armv4le-s3.h │ │ ├── risc_armv4le-thumb-iw.h │ │ ├── risc_armv4le-thumb-niw.h │ │ ├── risc_armv4le-thumb.h │ │ ├── risc_armv4le.h │ │ ├── risc_mipsel32.h │ │ ├── risc_x64.h │ │ └── risc_x86.h │ ├── core_full.cpp │ ├── core_full │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── ea_lookup.h │ │ ├── load.h │ │ ├── loadwrite.h │ │ ├── op.h │ │ ├── optable.h │ │ ├── save.h │ │ ├── string.h │ │ └── support.h │ ├── core_normal.cpp │ ├── core_normal │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── 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 │ ├── flags.cpp │ ├── instructions.h │ ├── lazyflags.h │ ├── modrm.cpp │ ├── modrm.h │ └── paging.cpp ├── debug │ ├── Makefile.am │ ├── Makefile.in │ ├── debug.cpp │ ├── debug_disasm.cpp │ ├── debug_gui.cpp │ ├── debug_inc.h │ ├── debug_win32.cpp │ └── disasm_tables.h ├── dos │ ├── Makefile.am │ ├── Makefile.in │ ├── cdrom.cpp │ ├── cdrom.h │ ├── cdrom_aspi_win32.cpp │ ├── cdrom_image.cpp │ ├── cdrom_ioctl_linux.cpp │ ├── cdrom_ioctl_os2.cpp │ ├── cdrom_ioctl_win32.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_virtual.cpp │ ├── drives.cpp │ ├── drives.h │ ├── scsidefs.h │ └── wnaspi32.h ├── dosbox.cpp ├── dosbox.ico ├── fpu │ ├── Makefile.am │ ├── Makefile.in │ ├── fpu.cpp │ ├── fpu_instructions.h │ └── fpu_instructions_x86.h ├── gui │ ├── Makefile.am │ ├── Makefile.in │ ├── dosbox_logo.h │ ├── dosbox_splash.h │ ├── midi.cpp │ ├── midi_alsa.h │ ├── midi_coreaudio.h │ ├── midi_coremidi.h │ ├── midi_oss.h │ ├── midi_win32.h │ ├── render.cpp │ ├── 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 │ ├── sdl_gui.cpp │ ├── sdl_mapper.cpp │ └── sdlmain.cpp ├── hardware │ ├── Makefile.am │ ├── Makefile.in │ ├── adlib.cpp │ ├── adlib.h │ ├── cmos.cpp │ ├── dbopl.cpp │ ├── dbopl.h │ ├── disney.cpp │ ├── dma.cpp │ ├── gameblaster.cpp │ ├── gus.cpp │ ├── hardware.cpp │ ├── iohandler.cpp │ ├── ipx.cpp │ ├── ipxserver.cpp │ ├── joystick.cpp │ ├── keyboard.cpp │ ├── mame │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── emu.h │ │ ├── saa1099.cpp │ │ ├── saa1099.h │ │ ├── sn76496.cpp │ │ └── sn76496.h │ ├── memory.cpp │ ├── mixer.cpp │ ├── mpu401.cpp │ ├── opl.cpp │ ├── opl.h │ ├── pcspeaker.cpp │ ├── pic.cpp │ ├── sblaster.cpp │ ├── serialport │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── directserial.cpp │ │ ├── directserial.h │ │ ├── libserial.cpp │ │ ├── libserial.h │ │ ├── misc_util.cpp │ │ ├── misc_util.h │ │ ├── nullmodem.cpp │ │ ├── nullmodem.h │ │ ├── serialdummy.cpp │ │ ├── serialdummy.h │ │ ├── serialport.cpp │ │ ├── softmodem.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 ├── ints │ ├── Makefile.am │ ├── Makefile.in │ ├── 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 ├── libs │ ├── Makefile.am │ ├── Makefile.in │ ├── gui_tk │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── gui_tk.cpp │ │ └── gui_tk.h │ └── zmbv │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── zmbv.cpp │ │ └── zmbv.h ├── misc │ ├── Makefile.am │ ├── Makefile.in │ ├── cross.cpp │ ├── messages.cpp │ ├── programs.cpp │ ├── setup.cpp │ └── support.cpp ├── platform │ ├── Makefile.am │ ├── Makefile.in │ ├── sdl-win32.diff │ └── visualc │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── config.h │ │ ├── ntddcdrm.h │ │ ├── ntddscsi.h │ │ └── unistd.h ├── shell │ ├── Makefile.am │ ├── Makefile.in │ ├── shell.cpp │ ├── shell_batch.cpp │ ├── shell_cmds.cpp │ └── shell_misc.cpp └── winres.rc ├── visualc_net ├── Makefile.am ├── Makefile.in ├── dosbox.sln └── dosbox.vcproj └── warcraft.jpeg /AUTHORS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KolibriOS/DOSBox/27a8b89892d90c301ad80173a3347ed3af55d750/AUTHORS -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Things needed for compilation. 2 | 3 | SDL 4 | The Simple DirectMedia Library available at http://www.libsdl.org 5 | The dll distributed with the windows version of DOSBox is slightly 6 | modified. You can find the changes in the sourcepackage of DOSBox 7 | (src/platform/sdl-win32.diff). If you want the patched sourcetree 8 | send us an email. (see README) 9 | Licensed under LGPL 10 | Note that only version 1.2 and its subversions (1.2.8, 1.2.13 etc.) 11 | are currently supported. 12 | 13 | Curses (optional) 14 | If you want to enable the debugger you need a curses library. 15 | ncurses should be installed on just about every unix distro. 16 | For win32 get pdcurses at http://pdcurses.sourceforge.net 17 | License: Open source 18 | 19 | Libpng (optional) 20 | Needed for the screenshots. 21 | For win32 get libpng from http://gnuwin32.sourceforge.net/packages.html 22 | See http://www.libpng.org/pub/png/ for more details. 23 | License: Open Source 24 | 25 | Zlib (optional) 26 | Needed by libpng. 27 | For win32 get libz (rename to zlib) from http://gnuwin32.sourceforge.net/packages.html 28 | See http://www.zlib.net for more details. 29 | License: Open Source 30 | 31 | SDL_Net (optional) 32 | For modem/ipx support. Get it from http://www.libsdl.org/projects/SDL_net/ 33 | Licensed under LGPL 34 | 35 | SDL_Sound 36 | For compressed audio on diskimages. (optional) 37 | This is for cue/bin cdrom images with compressed (mp3/ogg) audio tracks. 38 | Get it from http://icculus.org/SDL_sound 39 | Licenced under LGPL 40 | 41 | ALSA_Headers 42 | (optional) 43 | for Alsa support under linux. Part of the linux kernel sources 44 | Licensed under LGPL 45 | 46 | If you want compile from the CVS under a unix system, you'll also need 47 | automake (>=1.6), autoconf(>=2.50). Should be available at http://www.gnu.org 48 | 49 | For building on unix systems. 50 | If you are building from the cvs run ./autogen.sh first before doing the following. 51 | 52 | 1. ./configure 53 | 2. make 54 | 55 | In step 1 you could add the following switches: 56 | --enable-debug 57 | enables the internal debugger. --enable-debug=heavy enables even more 58 | debug options. DOSBox should then be run from a xterm and when the sdl- 59 | window is active press alt-pause to enter the debugger. 60 | 61 | --enable-core-inline 62 | enables some memory increasing inlines. This greatly increases 63 | compiletime for maybe a increase in speed. 64 | 65 | --disable-fpu 66 | disables the emulated fpu. Although the fpu emulation code isn't 67 | finished and isn't entirely accurate it's advised to leave it on. 68 | 69 | --disable-fpu-x86 70 | disables the assembly fpu core. Although relatively new the x86 fpu 71 | core has more accuracy then the regular fpu core. 72 | 73 | --disable-dynamic-x86 74 | disables the dynamic x86 specific cpu core. Although it might be 75 | be a bit unstable, it can greatly improve the speed of dosbox on x86 76 | hosts. 77 | Please note that this option on x86 will result in a different 78 | dynamic/recompiling cpu core being compiled then the default. 79 | For more information see the option --disable-dynrec 80 | 81 | --disable-dynrec 82 | disables the recompiling cpu core. Currently x86 and x86_64 only. 83 | You can activate this core on x86 by disabling the dynamic-x86 core. 84 | 85 | --disable-dynamic-core 86 | disables all dynamic cores. (same effect as 87 | --disable-dynamic-x86 --disable-dynrec) 88 | 89 | --disable-opengl 90 | disables OpenGL-support (output mode that can be selected in the 91 | DOSBox configuration file). 92 | 93 | --disable-unaligned-memory 94 | disables unaligned memory access. 95 | 96 | Check the src subdir for the binary. 97 | 98 | NOTE: If capslock and numlock appear to be broken. open 99 | src/ints/bios_keyboard.cpp and go to line 30 and read there how to fix it. 100 | 101 | 102 | Build instructions for VC++6 103 | Don't use VC++ 6: it creates faulty code in core_normal.cpp 104 | Later Visual Studio versions work fine (vs2003/.net, vs2005, vs2008) 105 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | # Main Makefile for DOSBox 2 | 3 | EXTRA_DIST = autogen.sh 4 | SUBDIRS = src include docs visualc_net 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DOSBox 0.74-3 port for KolibriOS 2 | 3 | This repository contains a port of __DOSBox__ version __0.74-3__ for __KolibriOS__.\ 4 | __DOSBox__ is a free and open-source emulator which runs software for __MS-DOS__ compatible disk operating systems—primarily video games. 5 | Official site: https://www.dosbox.com/ 6 | 7 | The original `README` can be found [here](./README). 8 | 9 | ## Building 10 | 11 | - Download the __KolibriOS__ project repository from [SVN](https://wiki.kolibrios.org/wiki/How_to_use_the_KolibriOS_Team_SVN_server); 12 | - Set up __GCC__ cross compiler for __KolibriOS__; 13 | - Set up the __Tup__ build system or build the necessary libraries (listed in `kolibrios_build.sh`) manually; 14 | - Go to the root of the DOSBox repository; 15 | - Export the KOS_SDK_DIR variable: 16 | ``` 17 | export KOS_SDK_DIR=//contrib/sdk 18 | ``` 19 | - Run the build: 20 | ``` 21 | ./kolibrios_build.sh 22 | ``` 23 | 24 | The resulting `dosbox` binary file will be available in the root of the repository. 25 | 26 | ## Usage 27 | 28 | Please check out the official [DOSBox Wiki](https://www.dosbox.com/wiki/) as well as the [KolibriOS Wiki](https://wiki.kolibrios.org/wiki/DosBox/) 29 | 30 | Example of launching the game __Warcraft: Orcs & Humans__: 31 | ![Alt text](warcraft.jpeg) 32 | 33 | ## Known issues 34 | 35 | Not yet). But if you have any problems, create an issue on this page, forum or Telegram KolibriOS chat. 36 | 37 | ## Authors 38 | 39 | Author of the port: __Maxim Logaev (turbocat)__ \ 40 | The authors of the original DOSBox are listed [here](./AUTHORS) 41 | 42 | ## License 43 | 44 | This project licensed under the terms of __GNU GPL 2.0__ license. See [this](./COPYING) for details 45 | -------------------------------------------------------------------------------- /THANKS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KolibriOS/DOSBox/27a8b89892d90c301ad80173a3347ed3af55d750/THANKS -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Generating build information using aclocal, autoheader, automake and autoconf" 4 | echo "This may take a while ..." 5 | 6 | # Regenerate configuration files. 7 | 8 | aclocal 9 | autoheader 10 | automake --include-deps --add-missing --copy 11 | autoconf 12 | 13 | echo "Now you are ready to run ./configure." 14 | echo "You can also run ./configure --help for extra features to enable/disable." 15 | -------------------------------------------------------------------------------- /docs/Makefile.am: -------------------------------------------------------------------------------- 1 | # Main Makefile for DOSBox 2 | 3 | man_MANS = dosbox.1 4 | EXTRA_DIST = $(man_MANS) README.video PORTING 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/PORTING: -------------------------------------------------------------------------------- 1 | Some notes about porting DOSBox to systems with certain restrictions, 2 | like handheld devices. 3 | 4 | General: 5 | - depending on where you start off with the port, assure that the 6 | config.h entries are correct/exhausting, like GCC_ATTRIBUTE is 7 | required (struct packing) but is undefined if you base the port 8 | on msvc sources which have a special config.h 9 | 10 | If memory is a constraint: 11 | - in paging.h out-comment the USE_FULL_TLB define to enable special 12 | TLB linking code that uses less memory 13 | drawback: none (the code is not heavily tested though) 14 | gain: reduces memory requirements about ~15mb 15 | - in render.h lower the scaler integration: 16 | #define RENDER_USE_ADVANCED_SCALERS 1 17 | or 18 | #define RENDER_USE_ADVANCED_SCALERS 0 19 | drawback: complex scalers and the scaler cache are disabled, 20 | be sure to test if this affects speed! 21 | with define RENDER_USE_ADVANCED_SCALERS==0 most simple 22 | scalers are disabled as well, some graphics modes won't 23 | work due to reduced cache sizes 24 | gain: ~2mb with RENDER_USE_ADVANCED_SCALERS==1 25 | ~5mb with RENDER_USE_ADVANCED_SCALERS==0 26 | - in dos_system.h reduce the drive cache entries: 27 | #define MAX_OPENDIRS 256 28 | drawback: some apps might not work with large directory trees 29 | gain: ~1mb per mounted drive 30 | - remove the GUS emulation (gus.cpp, especially GUSRam[1024*1024] ) 31 | drawback: no gravis ultrasound 32 | gain: reduces memory requirements about 1mb 33 | - reduce the size of the emulated graphics memory: 34 | see the memory sizing in SVGA_Setup_*, especially the defaults 35 | in vga_s3.cpp's SVGA_Setup_S3Trio 36 | drawback: some graphics modes won't work then 37 | gain: reduces memory requirements 38 | TODO: fully check this, introduce hard limits 39 | 40 | If speed is a constraint: 41 | - see if the simple core is faster, possibly remove the normal core 42 | set the simple core as default 43 | drawback: one game is known to not work with the simple core; 44 | the simple core does only work for games which don't use paging 45 | (when paging is requested the normal core is used automatically) 46 | gain: the simple core should be somewhat faster 47 | TODO: add possibility to easily remove the normal core, use fullcore fallback 48 | - raise the default frameskip value 49 | drawback: minor graphics smoothness loss for some games (video playback) 50 | gain: reduces graphics load 51 | -------------------------------------------------------------------------------- /docs/README.video: -------------------------------------------------------------------------------- 1 | Starting with version 0.65, DOSBox allows you to create movies out of screen 2 | output. 3 | 4 | To record a movie, you have to press CTRL-ALT-F5. 5 | To stop/end the recording, you have to press CTRL-ALT-F5 again. 6 | 7 | To play the recorded movie, you need a movie player which can handle the 8 | ZMBV codec. MS Windows users can find this codec in the start menu entry of 9 | DOSBox. Users of Linux and other OSes should look for a movie player that 10 | uses the ffmpeg libary (you may need to update or ask your distribution to 11 | upgrade). 12 | 13 | FAQ: 14 | Q: During the display of the movies the sound is lagging. 15 | A: Check your display properties to see whether your refresh rate is set to 16 | at least 70 hz. Try playing the movie in virtualdub (http://virtualdub.sf.net) 17 | 18 | Q: Why does the resulting movie consist of multiple files? 19 | A: Each time the game changes resolution, DOSBox creates a new movie file, 20 | because a movie file can only contain one resolution. 21 | 22 | Q: Can I set the cycles higher than my PC can handle during recording? 23 | A: Yes. During recording, the game might play slowly and stuttering, but the 24 | resulting movie should play at the intended speed and have no stuttering. 25 | 26 | Q: CTRL-ALT-F5 switches to the console under linux. 27 | A: 1. Start DOSBox like this: dosbox -startmapper 28 | 2. Click on Video, click on Add 29 | 3. Press the key you want (for example scroll lock or printscreen) 30 | 4. Click exit. 31 | 5. You can make movies by pressing scroll lock or whichever key you 32 | selected. 33 | 34 | Q: The colours are wrong and I'm using 64 bit windows 35 | A: Look here: http://vogons.zetafleet.com/viewtopic.php?t=12133 36 | -------------------------------------------------------------------------------- /include/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_HEADERS = \ 2 | bios.h \ 3 | bios_disk.h \ 4 | callback.h \ 5 | cpu.h \ 6 | cross.h \ 7 | control.h \ 8 | debug.h \ 9 | dma.h \ 10 | dos_inc.h \ 11 | dos_system.h \ 12 | dosbox.h \ 13 | fpu.h \ 14 | hardware.h \ 15 | inout.h \ 16 | joystick.h \ 17 | ipx.h \ 18 | ipxserver.h \ 19 | keyboard.h \ 20 | logging.h \ 21 | mapper.h \ 22 | mem.h \ 23 | mixer.h \ 24 | modules.h \ 25 | mouse.h \ 26 | paging.h \ 27 | pic.h \ 28 | programs.h \ 29 | render.h \ 30 | regs.h \ 31 | render.h \ 32 | serialport.h \ 33 | setup.h \ 34 | shell.h \ 35 | support.h \ 36 | timer.h \ 37 | vga.h \ 38 | video.h 39 | 40 | -------------------------------------------------------------------------------- /include/bios_disk.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 | #define MAX_SWAPPABLE_DISKS 20 37 | struct diskGeo { 38 | Bit32u ksize; /* Size in kilobytes */ 39 | Bit16u secttrack; /* Sectors per track */ 40 | Bit16u headscyl; /* Heads per cylinder */ 41 | Bit16u cylcount; /* Cylinders per side */ 42 | Bit16u biosval; /* Type to return from BIOS */ 43 | }; 44 | extern diskGeo DiskGeometryList[]; 45 | 46 | class imageDisk { 47 | public: 48 | Bit8u Read_Sector(Bit32u head,Bit32u cylinder,Bit32u sector,void * data); 49 | Bit8u Write_Sector(Bit32u head,Bit32u cylinder,Bit32u sector,void * data); 50 | Bit8u Read_AbsoluteSector(Bit32u sectnum, void * data); 51 | Bit8u Write_AbsoluteSector(Bit32u sectnum, void * data); 52 | 53 | void Set_Geometry(Bit32u setHeads, Bit32u setCyl, Bit32u setSect, Bit32u setSectSize); 54 | void Get_Geometry(Bit32u * getHeads, Bit32u *getCyl, Bit32u *getSect, Bit32u *getSectSize); 55 | Bit8u GetBiosType(void); 56 | Bit32u getSectSize(void); 57 | imageDisk(FILE *imgFile, Bit8u *imgName, Bit32u imgSizeK, bool isHardDisk); 58 | ~imageDisk() { if(diskimg != NULL) { fclose(diskimg); } }; 59 | 60 | bool hardDrive; 61 | bool active; 62 | FILE *diskimg; 63 | Bit8u diskname[512]; 64 | Bit8u floppytype; 65 | 66 | Bit32u sector_size; 67 | Bit32u heads,cylinders,sectors; 68 | }; 69 | 70 | void updateDPT(void); 71 | 72 | #define MAX_HDD_IMAGES 2 73 | #define MAX_DISK_IMAGES (2 + MAX_HDD_IMAGES) 74 | 75 | extern imageDisk *imageDiskList[MAX_DISK_IMAGES]; 76 | extern imageDisk *diskSwap[MAX_SWAPPABLE_DISKS]; 77 | 78 | extern Bits swapPosition; 79 | extern Bit16u imgDTASeg; /* Real memory location of temporary DTA pointer for fat image disk access */ 80 | extern RealPt imgDTAPtr; /* Real memory location of temporary DTA pointer for fat image disk access */ 81 | extern DOS_DTA *imgDTA; 82 | 83 | void swapInDisks(void); 84 | void swapInNextDisk(void); 85 | bool getSwapRequest(void); 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /include/callback.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: callback.h,v 1.26 2009-08-23 17:24:54 c2woody Exp $ */ 20 | 21 | #ifndef DOSBOX_CALLBACK_H 22 | #define DOSBOX_CALLBACK_H 23 | 24 | #ifndef DOSBOX_MEM_H 25 | #include "mem.h" 26 | #endif 27 | 28 | typedef Bitu (*CallBack_Handler)(void); 29 | extern CallBack_Handler CallBack_Handlers[]; 30 | 31 | enum { CB_RETN,CB_RETF,CB_RETF8,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 }; 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 | 99 | //Only allocate a callback number 100 | void Allocate(CallBack_Handler handler,const char* description=0); 101 | Bit16u Get_callback() { 102 | return (Bit16u)m_callback; 103 | } 104 | RealPt Get_RealPointer() { 105 | return CALLBACK_RealPointer(m_callback); 106 | } 107 | void Set_RealVec(Bit8u vec); 108 | }; 109 | #endif 110 | -------------------------------------------------------------------------------- /include/control.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: control.h,v 1.2 2009-05-27 09:15:40 qbix79 Exp $ */ 20 | 21 | #ifndef DOSBOX_CONTROL_H 22 | #define DOSBOX_CONTROL_H 23 | 24 | #ifdef _MSC_VER 25 | #pragma warning ( disable : 4786 ) 26 | #pragma warning ( disable : 4290 ) 27 | #endif 28 | 29 | #ifndef DOSBOX_PROGRAMS_H 30 | #include "programs.h" 31 | #endif 32 | #ifndef DOSBOX_SETUP_H 33 | #include "setup.h" 34 | #endif 35 | 36 | #ifndef CH_LIST 37 | #define CH_LIST 38 | #include 39 | #endif 40 | 41 | #ifndef CH_VECTOR 42 | #define CH_VECTOR 43 | #include 44 | #endif 45 | 46 | #ifndef CH_STRING 47 | #define CH_STRING 48 | #include 49 | #endif 50 | 51 | 52 | 53 | 54 | class Config{ 55 | public: 56 | CommandLine * cmdline; 57 | private: 58 | std::list sectionlist; 59 | typedef std::list::iterator it; 60 | typedef std::list::reverse_iterator reverse_it; 61 | typedef std::list::const_iterator const_it; 62 | typedef std::list::const_reverse_iterator const_reverse_it; 63 | void (* _start_function)(void); 64 | bool secure_mode; //Sandbox mode 65 | public: 66 | Config(CommandLine * cmd):cmdline(cmd),secure_mode(false){} 67 | ~Config(); 68 | 69 | Section_line * AddSection_line(char const * const _name,void (*_initfunction)(Section*)); 70 | Section_prop * AddSection_prop(char const * const _name,void (*_initfunction)(Section*),bool canchange=false); 71 | 72 | Section* GetSection(int index); 73 | Section* GetSection(std::string const&_sectionname) const; 74 | Section* GetSectionFromProperty(char const * const prop) const; 75 | 76 | void SetStartUp(void (*_function)(void)); 77 | void Init(); 78 | void ShutDown(); 79 | void StartUp(); 80 | bool PrintConfig(char const * const configfilename) const; 81 | bool ParseConfigFile(char const * const configfilename); 82 | void ParseEnv(char ** envp); 83 | bool SecureMode() const { return secure_mode; } 84 | void SwitchToSecureMode() { secure_mode = true; }//can't be undone 85 | }; 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /include/cross.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: cross.h,v 1.21 2009-03-14 18:02:34 qbix79 Exp $ */ 20 | 21 | #ifndef DOSBOX_CROSS_H 22 | #define DOSBOX_CROSS_H 23 | 24 | #ifndef DOSBOX_DOSBOX_H 25 | #include "dosbox.h" 26 | #endif 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #if defined (_MSC_VER) /* MS Visual C++ */ 34 | #include 35 | #include 36 | #define LONGTYPE(a) a##i64 37 | #define snprintf _snprintf 38 | #define vsnprintf _vsnprintf 39 | #else /* LINUX / GCC */ 40 | #include 41 | #include 42 | #define LONGTYPE(a) a##LL 43 | #endif 44 | 45 | #define CROSS_LEN 512 /* Maximum filename size */ 46 | 47 | 48 | #if defined (WIN32) || defined (OS2) /* Win 32 & OS/2*/ 49 | #define CROSS_FILENAME(blah) 50 | #define CROSS_FILESPLIT '\\' 51 | #define F_OK 0 52 | #else 53 | #define CROSS_FILENAME(blah) strreplace(blah,'\\','/') 54 | #define CROSS_FILESPLIT '/' 55 | #endif 56 | 57 | #define CROSS_NONE 0 58 | #define CROSS_FILE 1 59 | #define CROSS_DIR 2 60 | #if defined (WIN32) 61 | #define ftruncate(blah,blah2) chsize(blah,blah2) 62 | #endif 63 | 64 | //Solaris maybe others 65 | #if defined (DB_HAVE_NO_POWF) && !defined (KOLIBRI) 66 | #include 67 | static inline float powf (float x, float y) { return (float) pow (x,y); } 68 | #endif 69 | 70 | class Cross { 71 | public: 72 | static void GetPlatformConfigDir(std::string& in); 73 | static void GetPlatformConfigName(std::string& in); 74 | static void CreatePlatformConfigDir(std::string& in); 75 | static void ResolveHomedir(std::string & temp_line); 76 | static void CreateDir(std::string const& temp); 77 | }; 78 | 79 | 80 | #if defined (WIN32) 81 | 82 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from 83 | #include 84 | 85 | typedef struct dir_struct { 86 | HANDLE handle; 87 | char base_path[MAX_PATH+4]; 88 | WIN32_FIND_DATA search_data; 89 | } dir_information; 90 | 91 | #else 92 | 93 | //#include //Included above 94 | #include 95 | 96 | typedef struct dir_struct { 97 | DIR* dir; 98 | char base_path[CROSS_LEN]; 99 | } dir_information; 100 | 101 | #endif 102 | 103 | dir_information* open_directory(const char* dirname); 104 | bool read_directory_first(dir_information* dirp, char* entry_name, bool& is_directory); 105 | bool read_directory_next(dir_information* dirp, char* entry_name, bool& is_directory); 106 | void close_directory(dir_information* dirp); 107 | 108 | FILE *fopen_wrap(const char *path, const char *mode); 109 | #endif 110 | -------------------------------------------------------------------------------- /include/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: dma.h,v 1.20 2009-07-24 09:56:14 c2woody Exp $ */ 20 | 21 | #ifndef DOSBOX_DMA_H 22 | #define DOSBOX_DMA_H 23 | 24 | enum DMAEvent { 25 | DMA_REACHED_TC, 26 | DMA_MASKED, 27 | DMA_UNMASKED, 28 | DMA_TRANSFEREND 29 | }; 30 | 31 | class DmaChannel; 32 | typedef void (* DMA_CallBack)(DmaChannel * chan,DMAEvent event); 33 | 34 | class DmaChannel { 35 | public: 36 | Bit32u pagebase; 37 | Bit16u baseaddr; 38 | Bit32u curraddr; 39 | Bit16u basecnt; 40 | Bit16u currcnt; 41 | Bit8u channum; 42 | Bit8u pagenum; 43 | Bit8u DMA16; 44 | bool increment; 45 | bool autoinit; 46 | Bit8u trantype; 47 | bool masked; 48 | bool tcount; 49 | bool request; 50 | DMA_CallBack callback; 51 | 52 | DmaChannel(Bit8u num, bool dma16); 53 | void DoCallBack(DMAEvent event) { 54 | if (callback) (*callback)(this,event); 55 | } 56 | void SetMask(bool _mask) { 57 | masked=_mask; 58 | DoCallBack(masked ? DMA_MASKED : DMA_UNMASKED); 59 | } 60 | void Register_Callback(DMA_CallBack _cb) { 61 | callback = _cb; 62 | SetMask(masked); 63 | if (callback) Raise_Request(); 64 | else Clear_Request(); 65 | } 66 | void ReachedTC(void) { 67 | tcount=true; 68 | DoCallBack(DMA_REACHED_TC); 69 | } 70 | void SetPage(Bit8u val) { 71 | pagenum=val; 72 | pagebase=(pagenum >> DMA16) << (16+DMA16); 73 | } 74 | void Raise_Request(void) { 75 | request=true; 76 | } 77 | void Clear_Request(void) { 78 | request=false; 79 | } 80 | Bitu Read(Bitu size, Bit8u * buffer); 81 | Bitu Write(Bitu size, Bit8u * buffer); 82 | }; 83 | 84 | class DmaController { 85 | private: 86 | Bit8u ctrlnum; 87 | bool flipflop; 88 | DmaChannel *DmaChannels[4]; 89 | public: 90 | IO_ReadHandleObject DMA_ReadHandler[0x11]; 91 | IO_WriteHandleObject DMA_WriteHandler[0x11]; 92 | DmaController(Bit8u num) { 93 | flipflop = false; 94 | ctrlnum = num; /* first or second DMA controller */ 95 | for(Bit8u i=0;i<4;i++) { 96 | DmaChannels[i] = new DmaChannel(i+ctrlnum*4,ctrlnum==1); 97 | } 98 | } 99 | ~DmaController(void) { 100 | for(Bit8u i=0;i<4;i++) { 101 | delete DmaChannels[i]; 102 | } 103 | } 104 | DmaChannel * GetChannel(Bit8u chan) { 105 | if (chan<4) return DmaChannels[chan]; 106 | else return NULL; 107 | } 108 | void WriteControllerReg(Bitu reg,Bitu val,Bitu len); 109 | Bitu ReadControllerReg(Bitu reg,Bitu len); 110 | }; 111 | 112 | DmaChannel * GetDMAChannel(Bit8u chan); 113 | 114 | void CloseSecondDMAController(void); 115 | bool SecondDMAControllerAvailable(void); 116 | 117 | static Bit32u dma_wrapping = 0xffff; 118 | 119 | #endif 120 | -------------------------------------------------------------------------------- /include/dosbox.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: dosbox.h,v 1.32 2009-05-27 09:15:41 qbix79 Exp $ */ 20 | 21 | #ifndef DOSBOX_DOSBOX_H 22 | #define DOSBOX_DOSBOX_H 23 | 24 | #include "config.h" 25 | 26 | GCC_ATTRIBUTE(noreturn) void E_Exit(const char * message,...) GCC_ATTRIBUTE( __format__(__printf__, 1, 2)); 27 | 28 | void MSG_Add(const char*,const char*); //add messages to the internal langaugefile 29 | const char* MSG_Get(char const *); //get messages from the internal langaugafile 30 | 31 | class Section; 32 | 33 | typedef Bitu (LoopHandler)(void); 34 | 35 | void DOSBOX_RunMachine(); 36 | void DOSBOX_SetLoop(LoopHandler * handler); 37 | void DOSBOX_SetNormalLoop(); 38 | 39 | void DOSBOX_Init(void); 40 | 41 | class Config; 42 | extern Config * control; 43 | 44 | enum MachineType { 45 | MCH_HERC, 46 | MCH_CGA, 47 | MCH_TANDY, 48 | MCH_PCJR, 49 | MCH_EGA, 50 | MCH_VGA 51 | }; 52 | 53 | enum SVGACards { 54 | SVGA_None, 55 | SVGA_S3Trio, 56 | SVGA_TsengET4K, 57 | SVGA_TsengET3K, 58 | SVGA_ParadisePVGA1A 59 | }; 60 | 61 | extern SVGACards svgaCard; 62 | extern MachineType machine; 63 | extern bool SDLNetInited; 64 | 65 | #define IS_TANDY_ARCH ((machine==MCH_TANDY) || (machine==MCH_PCJR)) 66 | #define IS_EGAVGA_ARCH ((machine==MCH_EGA) || (machine==MCH_VGA)) 67 | #define IS_VGA_ARCH (machine==MCH_VGA) 68 | #define TANDY_ARCH_CASE MCH_TANDY: case MCH_PCJR 69 | #define EGAVGA_ARCH_CASE MCH_EGA: case MCH_VGA 70 | #define VGA_ARCH_CASE MCH_VGA 71 | 72 | #ifndef DOSBOX_LOGGING_H 73 | #include "logging.h" 74 | #endif // the logging system. 75 | 76 | #endif /* DOSBOX_DOSBOX_H */ 77 | -------------------------------------------------------------------------------- /include/fpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | #ifndef DOSBOX_FPU_H 20 | #define DOSBOX_FPU_H 21 | 22 | #ifndef DOSBOX_MEM_H 23 | #include "mem.h" 24 | #endif 25 | 26 | void FPU_ESC0_Normal(Bitu rm); 27 | void FPU_ESC0_EA(Bitu func,PhysPt ea); 28 | void FPU_ESC1_Normal(Bitu rm); 29 | void FPU_ESC1_EA(Bitu func,PhysPt ea); 30 | void FPU_ESC2_Normal(Bitu rm); 31 | void FPU_ESC2_EA(Bitu func,PhysPt ea); 32 | void FPU_ESC3_Normal(Bitu rm); 33 | void FPU_ESC3_EA(Bitu func,PhysPt ea); 34 | void FPU_ESC4_Normal(Bitu rm); 35 | void FPU_ESC4_EA(Bitu func,PhysPt ea); 36 | void FPU_ESC5_Normal(Bitu rm); 37 | void FPU_ESC5_EA(Bitu func,PhysPt ea); 38 | void FPU_ESC6_Normal(Bitu rm); 39 | void FPU_ESC6_EA(Bitu func,PhysPt ea); 40 | void FPU_ESC7_Normal(Bitu rm); 41 | void FPU_ESC7_EA(Bitu func,PhysPt ea); 42 | 43 | 44 | typedef union { 45 | double d; 46 | #ifndef WORDS_BIGENDIAN 47 | struct { 48 | Bit32u lower; 49 | Bit32s upper; 50 | } l; 51 | #else 52 | struct { 53 | Bit32s upper; 54 | Bit32u lower; 55 | } l; 56 | #endif 57 | Bit64s ll; 58 | } FPU_Reg; 59 | 60 | typedef struct { 61 | Bit32u m1; 62 | Bit32u m2; 63 | Bit16u m3; 64 | 65 | Bit16u d1; 66 | Bit32u d2; 67 | } FPU_P_Reg; 68 | 69 | enum FPU_Tag { 70 | TAG_Valid = 0, 71 | TAG_Zero = 1, 72 | TAG_Weird = 2, 73 | TAG_Empty = 3 74 | }; 75 | 76 | enum FPU_Round { 77 | ROUND_Nearest = 0, 78 | ROUND_Down = 1, 79 | ROUND_Up = 2, 80 | ROUND_Chop = 3 81 | }; 82 | 83 | typedef struct { 84 | FPU_Reg regs[9]; 85 | FPU_P_Reg p_regs[9]; 86 | FPU_Tag tags[9]; 87 | Bit16u cw,cw_mask_all; 88 | Bit16u sw; 89 | Bit32u top; 90 | FPU_Round round; 91 | } FPU_rec; 92 | 93 | 94 | //get pi from a real library 95 | #define PI 3.14159265358979323846 96 | #define L2E 1.4426950408889634 97 | #define L2T 3.3219280948873623 98 | #define LN2 0.69314718055994531 99 | #define LG2 0.3010299956639812 100 | 101 | 102 | extern FPU_rec fpu; 103 | 104 | #define TOP fpu.top 105 | #define STV(i) ( (fpu.top+ (i) ) & 7 ) 106 | 107 | 108 | Bit16u FPU_GetTag(void); 109 | void FPU_FLDCW(PhysPt addr); 110 | 111 | static INLINE void FPU_SetTag(Bit16u tag){ 112 | for(Bitu i=0;i<8;i++) 113 | fpu.tags[i] = static_cast((tag >>(2*i))&3); 114 | } 115 | 116 | static INLINE void FPU_SetCW(Bitu word){ 117 | fpu.cw = (Bit16u)word; 118 | fpu.cw_mask_all = (Bit16u)(word | 0x3f); 119 | fpu.round = (FPU_Round)((word >> 10) & 3); 120 | } 121 | 122 | 123 | static INLINE Bitu FPU_GET_TOP(void) { 124 | return (fpu.sw & 0x3800)>>11; 125 | } 126 | 127 | static INLINE void FPU_SET_TOP(Bitu val){ 128 | fpu.sw &= ~0x3800; 129 | fpu.sw |= (val&7)<<11; 130 | } 131 | 132 | 133 | static INLINE void FPU_SET_C0(Bitu C){ 134 | fpu.sw &= ~0x0100; 135 | if(C) fpu.sw |= 0x0100; 136 | } 137 | 138 | static INLINE void FPU_SET_C1(Bitu C){ 139 | fpu.sw &= ~0x0200; 140 | if(C) fpu.sw |= 0x0200; 141 | } 142 | 143 | static INLINE void FPU_SET_C2(Bitu C){ 144 | fpu.sw &= ~0x0400; 145 | if(C) fpu.sw |= 0x0400; 146 | } 147 | 148 | static INLINE void FPU_SET_C3(Bitu C){ 149 | fpu.sw &= ~0x4000; 150 | if(C) fpu.sw |= 0x4000; 151 | } 152 | 153 | 154 | #endif 155 | -------------------------------------------------------------------------------- /include/hardware.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: hardware.h,v 1.17 2009-06-23 17:46:05 c2woody Exp $ */ 20 | 21 | #ifndef DOSBOX_HARDWARE_H 22 | #define DOSBOX_HARDWARE_H 23 | 24 | #include 25 | 26 | class Section; 27 | enum OPL_Mode { 28 | OPL_none,OPL_cms,OPL_opl2,OPL_dualopl2,OPL_opl3 29 | }; 30 | #define CAPTURE_WAVE 0x01 31 | #define CAPTURE_OPL 0x02 32 | #define CAPTURE_MIDI 0x04 33 | #define CAPTURE_IMAGE 0x08 34 | #define CAPTURE_VIDEO 0x10 35 | 36 | extern Bitu CaptureState; 37 | 38 | void OPL_Init(Section* sec,OPL_Mode mode); 39 | void CMS_Init(Section* sec); 40 | void OPL_ShutDown(Section* sec); 41 | void CMS_ShutDown(Section* sec); 42 | 43 | bool SB_Get_Address(Bitu& sbaddr, Bitu& sbirq, Bitu& sbdma); 44 | bool TS_Get_Address(Bitu& tsaddr, Bitu& tsirq, Bitu& tsdma); 45 | 46 | extern Bit8u adlib_commandreg; 47 | FILE * OpenCaptureFile(const char * type,const char * ext); 48 | 49 | void CAPTURE_AddWave(Bit32u freq, Bit32u len, Bit16s * data); 50 | #define CAPTURE_FLAG_DBLW 0x1 51 | #define CAPTURE_FLAG_DBLH 0x2 52 | void CAPTURE_AddImage(Bitu width, Bitu height, Bitu bpp, Bitu pitch, Bitu flags, float fps, Bit8u * data, Bit8u * pal); 53 | void CAPTURE_AddMidi(bool sysex, Bitu len, Bit8u * data); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /include/inout.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: inout.h,v 1.13 2009-05-27 09:15:41 qbix79 Exp $ */ 20 | 21 | #ifndef DOSBOX_INOUT_H 22 | #define DOSBOX_INOUT_H 23 | 24 | #define IO_MAX (64*1024+3) 25 | 26 | #define IO_MB 0x1 27 | #define IO_MW 0x2 28 | #define IO_MD 0x4 29 | #define IO_MA (IO_MB | IO_MW | IO_MD ) 30 | 31 | typedef Bitu IO_ReadHandler(Bitu port,Bitu iolen); 32 | typedef void IO_WriteHandler(Bitu port,Bitu val,Bitu iolen); 33 | 34 | extern IO_WriteHandler * io_writehandlers[3][IO_MAX]; 35 | extern IO_ReadHandler * io_readhandlers[3][IO_MAX]; 36 | 37 | void IO_RegisterReadHandler(Bitu port,IO_ReadHandler * handler,Bitu mask,Bitu range=1); 38 | void IO_RegisterWriteHandler(Bitu port,IO_WriteHandler * handler,Bitu mask,Bitu range=1); 39 | 40 | void IO_FreeReadHandler(Bitu port,Bitu mask,Bitu range=1); 41 | void IO_FreeWriteHandler(Bitu port,Bitu mask,Bitu range=1); 42 | 43 | void IO_WriteB(Bitu port,Bitu val); 44 | void IO_WriteW(Bitu port,Bitu val); 45 | void IO_WriteD(Bitu port,Bitu val); 46 | 47 | Bitu IO_ReadB(Bitu port); 48 | Bitu IO_ReadW(Bitu port); 49 | Bitu IO_ReadD(Bitu port); 50 | 51 | /* Classes to manage the IO objects created by the various devices. 52 | * The io objects will remove itself on destruction.*/ 53 | class IO_Base{ 54 | protected: 55 | bool installed; 56 | Bitu m_port, m_mask,m_range; 57 | public: 58 | IO_Base():installed(false){}; 59 | }; 60 | class IO_ReadHandleObject: private IO_Base{ 61 | public: 62 | void Install(Bitu port,IO_ReadHandler * handler,Bitu mask,Bitu range=1); 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 | ~IO_WriteHandleObject(); 69 | }; 70 | 71 | static INLINE void IO_Write(Bitu port,Bit8u val) { 72 | IO_WriteB(port,val); 73 | } 74 | static INLINE Bit8u IO_Read(Bitu port){ 75 | return (Bit8u)IO_ReadB(port); 76 | } 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /include/ipx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: ipx.h,v 1.13 2009-05-27 09:15:41 qbix79 Exp $ */ 20 | 21 | #ifndef DOSBOX_IPX_H 22 | #define DOSBOX_IPX_H 23 | 24 | // Uncomment this for a lot of debug messages: 25 | //#define IPX_DEBUGMSG 26 | 27 | #ifdef IPX_DEBUGMSG 28 | #define LOG_IPX LOG_MSG 29 | #else 30 | #if defined (_MSC_VER) 31 | #define LOG_IPX 32 | #else 33 | #define LOG_IPX(...) 34 | #endif 35 | #endif 36 | 37 | #ifndef DOSBOX_DOSBOX_H 38 | #include "dosbox.h" 39 | #endif 40 | #ifndef DOSBOX_MEM_H 41 | #include "mem.h" 42 | #endif 43 | 44 | // In Use Flag codes 45 | #define USEFLAG_AVAILABLE 0x00 46 | #define USEFLAG_AESTEMP 0xe0 47 | #define USEFLAG_IPXCRIT 0xf8 48 | #define USEFLAG_SPXLISTEN 0xf9 49 | #define USEFLAG_PROCESSING 0xfa 50 | #define USEFLAG_HOLDING 0xfb 51 | #define USEFLAG_AESWAITING 0xfc 52 | #define USEFLAG_AESCOUNT 0xfd 53 | #define USEFLAG_LISTENING 0xfe 54 | #define USEFLAG_SENDING 0xff 55 | 56 | // Completion codes 57 | #define COMP_SUCCESS 0x00 58 | #define COMP_REMOTETERM 0xec 59 | #define COMP_DISCONNECT 0xed 60 | #define COMP_INVALIDID 0xee 61 | #define COMP_SPXTABLEFULL 0xef 62 | #define COMP_EVENTNOTCANCELED 0xf9 63 | #define COMP_NOCONNECTION 0xfa 64 | #define COMP_CANCELLED 0xfc 65 | #define COMP_MALFORMED 0xfd 66 | #define COMP_UNDELIVERABLE 0xfe 67 | #define COMP_HARDWAREERROR 0xff 68 | 69 | #ifdef _MSC_VER 70 | #pragma pack(1) 71 | #endif 72 | 73 | // For Uint8 type 74 | #include "SDL_net.h" 75 | 76 | struct PackedIP { 77 | Uint32 host; 78 | Uint16 port; 79 | } GCC_ATTRIBUTE(packed); 80 | 81 | struct nodeType { 82 | Uint8 node[6]; 83 | } GCC_ATTRIBUTE(packed) ; 84 | 85 | struct IPXHeader { 86 | Uint8 checkSum[2]; 87 | Uint8 length[2]; 88 | Uint8 transControl; // Transport control 89 | Uint8 pType; // Packet type 90 | 91 | struct transport { 92 | Uint8 network[4]; 93 | union addrtype { 94 | nodeType byNode; 95 | PackedIP byIP ; 96 | } GCC_ATTRIBUTE(packed) addr; 97 | Uint8 socket[2]; 98 | } dest, src; 99 | } GCC_ATTRIBUTE(packed); 100 | 101 | struct fragmentDescriptor { 102 | Bit16u offset; 103 | Bit16u segment; 104 | Bit16u size; 105 | }; 106 | 107 | #define IPXBUFFERSIZE 1424 108 | 109 | class ECBClass { 110 | public: 111 | RealPt ECBAddr; 112 | bool isInESRList; 113 | ECBClass *prevECB; // Linked List 114 | ECBClass *nextECB; 115 | 116 | Bit8u iuflag; // Need to save data since we are not always in 117 | Bit16u mysocket; // real mode 118 | 119 | Bit8u* databuffer; // received data is stored here until we get called 120 | Bitu buflen; // by Interrupt 121 | 122 | #ifdef IPX_DEBUGMSG 123 | Bitu SerialNumber; 124 | #endif 125 | 126 | ECBClass(Bit16u segment, Bit16u offset); 127 | Bit16u getSocket(void); 128 | 129 | Bit8u getInUseFlag(void); 130 | 131 | void setInUseFlag(Bit8u flagval); 132 | 133 | void setCompletionFlag(Bit8u flagval); 134 | 135 | Bit16u getFragCount(void); 136 | 137 | bool writeData(); 138 | void writeDataBuffer(Bit8u* buffer, Bit16u length); 139 | 140 | void getFragDesc(Bit16u descNum, fragmentDescriptor *fragDesc); 141 | RealPt getESRAddr(void); 142 | 143 | void NotifyESR(void); 144 | 145 | void setImmAddress(Bit8u *immAddr); 146 | void getImmAddress(Bit8u* immAddr); 147 | 148 | ~ECBClass(); 149 | }; 150 | 151 | // The following routines may not be needed on all systems. On my build of SDL the IPaddress structure is 8 octects 152 | // and therefore screws up my IPXheader structure since it needs to be packed. 153 | 154 | void UnpackIP(PackedIP ipPack, IPaddress * ipAddr); 155 | void PackIP(IPaddress ipAddr, PackedIP *ipPack); 156 | 157 | #ifdef _MSC_VER 158 | #pragma pack() 159 | #endif 160 | 161 | #endif 162 | -------------------------------------------------------------------------------- /include/ipxserver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: joystick.h,v 1.13 2009-05-27 09:15:41 qbix79 Exp $ */ 20 | #ifndef DOSBOX_JOYSTICK_H 21 | #define DOSBOX_JOYSTICK_H 22 | void JOYSTICK_Enable(Bitu which,bool enabled); 23 | 24 | void JOYSTICK_Button(Bitu which,Bitu num,bool pressed); 25 | 26 | void JOYSTICK_Move_X(Bitu which,float x); 27 | 28 | void JOYSTICK_Move_Y(Bitu which,float y); 29 | 30 | bool JOYSTICK_IsEnabled(Bitu which); 31 | 32 | bool JOYSTICK_GetButton(Bitu which, Bitu num); 33 | 34 | float JOYSTICK_GetMove_X(Bitu which); 35 | 36 | float JOYSTICK_GetMove_Y(Bitu which); 37 | 38 | enum JoystickType { 39 | JOY_NONE, 40 | JOY_AUTO, 41 | JOY_2AXIS, 42 | JOY_4AXIS, 43 | JOY_4AXIS_2, 44 | JOY_FCS, 45 | JOY_CH 46 | }; 47 | 48 | extern JoystickType joytype; 49 | extern bool button_wrapping_enabled; 50 | #endif 51 | -------------------------------------------------------------------------------- /include/keyboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 | void KEYBOARD_ClrBuffer(void); 51 | void KEYBOARD_AddKey(KBD_KEYS keytype,bool pressed); 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /include/logging.h: -------------------------------------------------------------------------------- 1 | #ifndef DOSBOX_LOGGING_H 2 | #define DOSBOX_LOGGING_H 3 | enum LOG_TYPES { 4 | LOG_ALL, 5 | LOG_VGA, LOG_VGAGFX,LOG_VGAMISC,LOG_INT10, 6 | LOG_SB,LOG_DMACONTROL, 7 | LOG_FPU,LOG_CPU,LOG_PAGING, 8 | LOG_FCB,LOG_FILES,LOG_IOCTL,LOG_EXEC,LOG_DOSMISC, 9 | LOG_PIT,LOG_KEYBOARD,LOG_PIC, 10 | LOG_MOUSE,LOG_BIOS,LOG_GUI,LOG_MISC, 11 | LOG_IO, 12 | LOG_MAX 13 | }; 14 | 15 | enum LOG_SEVERITIES { 16 | LOG_NORMAL, 17 | LOG_WARN, 18 | LOG_ERROR 19 | }; 20 | 21 | #if C_DEBUG 22 | class LOG 23 | { 24 | LOG_TYPES d_type; 25 | LOG_SEVERITIES d_severity; 26 | public: 27 | 28 | LOG (LOG_TYPES type , LOG_SEVERITIES severity): 29 | d_type(type), 30 | d_severity(severity) 31 | {} 32 | void operator() (char const* buf, ...) GCC_ATTRIBUTE(__format__(__printf__, 2, 3)); //../src/debug/debug_gui.cpp 33 | 34 | }; 35 | 36 | void DEBUG_ShowMsg(char const* format,...) GCC_ATTRIBUTE(__format__(__printf__, 1, 2)); 37 | #define LOG_MSG DEBUG_ShowMsg 38 | 39 | #else //C_DEBUG 40 | 41 | struct LOG 42 | { 43 | LOG(LOG_TYPES , LOG_SEVERITIES ) { } 44 | void operator()(char const* ) { } 45 | void operator()(char const* , double ) { } 46 | void operator()(char const* , double , double ) { } 47 | void operator()(char const* , double , double , double ) { } 48 | void operator()(char const* , double , double , double , double ) { } 49 | void operator()(char const* , double , double , double , double , double ) { } 50 | 51 | void operator()(char const* , char const* ) { } 52 | void operator()(char const* , char const* , double ) { } 53 | void operator()(char const* , char const* , double ,double ) { } 54 | void operator()(char const* , double , char const* ) { } 55 | void operator()(char const* , double , double, char const* ) { } 56 | void operator()(char const* , char const*, char const*) { } 57 | 58 | 59 | }; //add missing operators to here 60 | //try to avoid anything smaller than bit32... 61 | void GFX_ShowMsg(char const* format,...) GCC_ATTRIBUTE(__format__(__printf__, 1, 2)); 62 | #define LOG_MSG GFX_ShowMsg 63 | 64 | #endif //C_DEBUG 65 | 66 | 67 | #endif //DOSBOX_LOGGING_H 68 | -------------------------------------------------------------------------------- /include/mapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | #ifndef DOSBOX_MAPPER_H 20 | #define DOSBOX_MAPPER_H 21 | 22 | enum MapKeys { 23 | MK_f1,MK_f2,MK_f3,MK_f4,MK_f5,MK_f6,MK_f7,MK_f8,MK_f9,MK_f10,MK_f11,MK_f12, 24 | MK_return,MK_kpminus,MK_scrolllock,MK_printscreen,MK_pause 25 | 26 | }; 27 | 28 | typedef void (MAPPER_Handler)(bool pressed); 29 | void MAPPER_AddHandler(MAPPER_Handler * handler,MapKeys key,Bitu mods,char const * const eventname,char const * const buttonname); 30 | void MAPPER_Init(void); 31 | void MAPPER_StartUp(Section * sec); 32 | void MAPPER_Run(bool pressed); 33 | void MAPPER_RunInternal(); 34 | void MAPPER_LosingFocus(void); 35 | 36 | 37 | #define MMOD1 0x1 38 | #define MMOD2 0x2 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /include/mixer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: mixer.h,v 1.19 2009-04-28 21:48:24 harekiet Exp $ */ 20 | 21 | #ifndef DOSBOX_MIXER_H 22 | #define DOSBOX_MIXER_H 23 | 24 | #ifndef DOSBOX_DOSBOX_H 25 | #include "dosbox.h" 26 | #endif 27 | 28 | typedef void (*MIXER_MixHandler)(Bit8u * sampdate,Bit32u len); 29 | typedef void (*MIXER_Handler)(Bitu len); 30 | 31 | enum BlahModes { 32 | MIXER_8MONO,MIXER_8STEREO, 33 | MIXER_16MONO,MIXER_16STEREO 34 | }; 35 | 36 | enum MixerModes { 37 | M_8M,M_8S, 38 | M_16M,M_16S 39 | }; 40 | 41 | #define MIXER_BUFSIZE (16*1024) 42 | #define MIXER_BUFMASK (MIXER_BUFSIZE-1) 43 | extern Bit8u MixTemp[MIXER_BUFSIZE]; 44 | 45 | #define MAX_AUDIO ((1<<(16-1))-1) 46 | #define MIN_AUDIO -(1<<(16-1)) 47 | 48 | class MixerChannel { 49 | public: 50 | void SetVolume(float _left,float _right); 51 | void SetScale( float f ); 52 | void UpdateVolume(void); 53 | void SetFreq(Bitu _freq); 54 | void Mix(Bitu _needed); 55 | void AddSilence(void); //Fill up until needed 56 | 57 | template 58 | void AddSamples(Bitu len, const Type* data); 59 | 60 | void AddSamples_m8(Bitu len, const Bit8u * data); 61 | void AddSamples_s8(Bitu len, const Bit8u * data); 62 | void AddSamples_m8s(Bitu len, const Bit8s * data); 63 | void AddSamples_s8s(Bitu len, const Bit8s * data); 64 | void AddSamples_m16(Bitu len, const Bit16s * data); 65 | void AddSamples_s16(Bitu len, const Bit16s * data); 66 | void AddSamples_m16u(Bitu len, const Bit16u * data); 67 | void AddSamples_s16u(Bitu len, const Bit16u * data); 68 | void AddSamples_m32(Bitu len, const Bit32s * data); 69 | void AddSamples_s32(Bitu len, const Bit32s * data); 70 | void AddSamples_m16_nonnative(Bitu len, const Bit16s * data); 71 | void AddSamples_s16_nonnative(Bitu len, const Bit16s * data); 72 | void AddSamples_m16u_nonnative(Bitu len, const Bit16u * data); 73 | void AddSamples_s16u_nonnative(Bitu len, const Bit16u * data); 74 | void AddSamples_m32_nonnative(Bitu len, const Bit32s * data); 75 | void AddSamples_s32_nonnative(Bitu len, const Bit32s * data); 76 | 77 | void AddStretched(Bitu len,Bit16s * data); //Strech block up into needed data 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 | Bitu freq_add,freq_index; 85 | Bitu done,needed; 86 | Bits last[2]; 87 | const char * name; 88 | bool enabled; 89 | MixerChannel * next; 90 | }; 91 | 92 | MixerChannel * MIXER_AddChannel(MIXER_Handler handler,Bitu freq,const char * name); 93 | MixerChannel * MIXER_FindChannel(const char * name); 94 | /* Find the device you want to delete with findchannel "delchan gets deleted" */ 95 | void MIXER_DelChannel(MixerChannel* delchan); 96 | 97 | /* Object to maintain a mixerchannel; As all objects it registers itself with create 98 | * and removes itself when destroyed. */ 99 | class MixerObject{ 100 | private: 101 | bool installed; 102 | char m_name[32]; 103 | public: 104 | MixerObject():installed(false){}; 105 | MixerChannel* Install(MIXER_Handler handler,Bitu freq,const char * name); 106 | ~MixerObject(); 107 | }; 108 | 109 | 110 | /* PC Speakers functions, tightly related to the timer functions */ 111 | void PCSPEAKER_SetCounter(Bitu cntr,Bitu mode); 112 | void PCSPEAKER_SetType(Bitu mode); 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /include/modules.h: -------------------------------------------------------------------------------- 1 | /* Standard data types used */ 2 | 3 | typedef unsigned char Bit8u; 4 | typedef signed char Bit8s; 5 | typedef unsigned short Bit16u; 6 | typedef signed short Bit16s; 7 | typedef unsigned long Bit32u; 8 | typedef signed long Bit32s; 9 | #if defined(_MSC_VER) 10 | typedef unsigned __int64 Bit64u; 11 | typedef signed __int64 Bit64s; 12 | #else 13 | typedef unsigned long long int Bit64u; 14 | typedef signed long long int Bit64s; 15 | #endif 16 | 17 | 18 | 19 | /* Setting up pointers to all subfunctions */ 20 | #ifdef MODULE_WANT_IO_READ 21 | typedef Bit8u (* IO_ReadHandler)(Bit32u port); 22 | static void (* IO_RegisterReadHandler)(Bit32u port,IO_ReadHandler handler,char * name); 23 | static void (* IO_FreeReadHandler)(Bit32u port); 24 | #endif 25 | 26 | #ifdef MODULE_WANT_IO_WRITE 27 | typedef void (* IO_WriteHandler)(Bit32u port,Bit8u value); 28 | static void (* IO_RegisterWriteHandler)(Bit32u port,IO_WriteHandler handler,char * name); 29 | static void (* IO_FreeWriteHandler)(Bit32u port); 30 | #endif 31 | 32 | #ifdef MODULE_WANT_IRQ_EOI 33 | typedef void (* IRQ_EOIHandler)(void); 34 | static void (* IRQ_RegisterEOIHandler)(Bit32u irq,IRQ_EOIHandler handler,char * name); 35 | static void (* IRQ_FreeEOIHandler)(Bit32u irq); 36 | #endif 37 | 38 | #ifdef MODULE_WANT_IRQ 39 | static void (* IRQ_Activate)(Bit32u irq); 40 | static void (* IRQ_Deactivate)(Bit32u irq); 41 | #endif 42 | 43 | #ifdef MODULE_WANT_TIMER 44 | typedef void (* TIMER_MicroHandler)(void); 45 | static void (* TIMER_RegisterMicroHandler)(TIMER_MicroHandler handler,Bit32u micro); 46 | #endif 47 | 48 | #ifdef MODULE_WANT_TIMER_TICK 49 | typedef void (* TIMER_TickHandler)(Bit32u ticks); 50 | static void (* TIMER_RegisterTickHandler)(TIMER_TickHandler handler); 51 | #endif 52 | 53 | /* 54 | 4 8-bit and 4 16-bit channels you can read data from 55 | 16-bit reads are word sized 56 | */ 57 | 58 | #ifdef MODULE_WANT_DMA_READ 59 | static void (* DMA_8_Read)(Bit32u chan,Bit8u * data,Bit16u size); 60 | static void (* DMA_16_Read)(Bit32u chan,Bit8u * data,Bit16u size); 61 | #endif 62 | 63 | /* 64 | 4 8-bit and 4 16-bit channels you can write data from 65 | 16-bit writes are word sized 66 | */ 67 | 68 | #ifdef MODULE_WANT_DMA_READ 69 | static void (* DMA_8_Write)(Bit32u chan,Bit8u * data,Bit16u size); 70 | static void (* DMA_16_Write)(Bit32u chan,Bit8u * data,Bit16u size); 71 | #endif 72 | 73 | 74 | #ifdef MODULE_WANT_MIXER 75 | /* The len here means the amount of samples needed not the buffersize it needed to fill */ 76 | typedef void (* MIXER_MixHandler)(Bit8u * sampdate,Bit32u len); 77 | 78 | /* Different types if modes a mixer channel can work in */ 79 | #define MIXER_8MONO 0 80 | #define MIXER_8STEREO 1 81 | #define MIXER_16MONO 2 82 | #define MIXER_16STEREO 3 83 | struct MIXER_Channel; 84 | 85 | #define MAX_AUDIO ((1<<(16-1))-1) 86 | #define MIN_AUDIO -(1<<(16-1)) 87 | 88 | MIXER_Channel *(* MIXER_AddChannel)(MIXER_MixHandler handler,Bit32u freq,char * name); 89 | void (* MIXER_SetVolume)(MIXER_Channel * chan,Bit8u vol); 90 | void (* MIXER_SetFreq)(MIXER_Channel * chan,Bit32u freq); 91 | void (* MIXER_SetMode)(MIXER_Channel * chan,Bit8u mode); 92 | void (* MIXER_Enable)(MIXER_Channel * chan,bool enable); 93 | #endif 94 | 95 | typedef bool (* MODULE_FindHandler)(char * name,void * * function); 96 | typedef char *(* MODULE_StartHandler)(MODULE_FindHandler find_handler); 97 | 98 | #define MODULE_START_PROC "ModuleStart" 99 | 100 | #ifdef MODULE_START_FUNCTION 101 | #include 102 | 103 | #define GET_FUNCTION(a) \ 104 | if (!find_handler(#a ,(void * *) &a)) { \ 105 | return "Can't find requested function"; \ 106 | }; 107 | 108 | 109 | #if defined (WIN32) 110 | #include 111 | BOOL APIENTRY DllMain( HANDLE hModule, 112 | DWORD ul_reason_for_call, 113 | LPVOID lpReserved 114 | ) 115 | { 116 | return TRUE; 117 | } 118 | 119 | extern "C" { 120 | __declspec(dllexport) 121 | #endif 122 | char * ModuleStart (MODULE_FindHandler find_handler) { 123 | 124 | #ifdef MODULE_WANT_IRQ_EOI 125 | GET_FUNCTION(IRQ_RegisterEOIHandler); 126 | GET_FUNCTION(IRQ_FreeEOIHandler); 127 | #endif 128 | 129 | #ifdef MODULE_WANT_IRQ 130 | GET_FUNCTION(IRQ_Activate); 131 | GET_FUNCTION(IRQ_Deactivate); 132 | #endif 133 | 134 | #ifdef MODULE_WANT_IO_READ 135 | GET_FUNCTION(IO_RegisterReadHandler); 136 | GET_FUNCTION(IO_FreeReadHandler); 137 | #endif 138 | 139 | #ifdef MODULE_WANT_IO_WRITE 140 | GET_FUNCTION(IO_RegisterWriteHandler); 141 | GET_FUNCTION(IO_FreeWriteHandler); 142 | #endif 143 | 144 | #ifdef MODULE_WANT_TIMER 145 | GET_FUNCTION(TIMER_RegisterMicroHandler); 146 | #endif 147 | 148 | #ifdef MODULE_WANT_TIMER_TICKS 149 | GET_FUNCTION(TIMER_RegisterTickHandler); 150 | #endif 151 | 152 | #ifdef MODULE_WANT_DMA_READ 153 | GET_FUNCTION(DMA_8_Read); 154 | GET_FUNCTION(DMA_16_Read); 155 | #endif 156 | 157 | #ifdef MODULE_WANT_DMA_WRITE 158 | GET_FUNCTION(DMA_8_Write); 159 | GET_FUNCTION(DMA_16_Write); 160 | #endif 161 | 162 | #ifdef MODULE_WANT_MIXER 163 | GET_FUNCTION(MIXER_AddChannel); 164 | GET_FUNCTION(MIXER_SetVolume); 165 | GET_FUNCTION(MIXER_SetFreq); 166 | GET_FUNCTION(MIXER_SetMode); 167 | GET_FUNCTION(MIXER_Enable); 168 | #endif 169 | 170 | return MODULE_START_FUNCTION; 171 | 172 | } 173 | #if defined (WIN32) 174 | } 175 | #endif 176 | 177 | 178 | 179 | #endif 180 | 181 | -------------------------------------------------------------------------------- /include/mouse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: mouse.h,v 1.15 2009-05-27 09:15:41 qbix79 Exp $ */ 20 | 21 | 22 | #ifndef DOSBOX_MOUSE_H 23 | #define DOSBOX_MOUSE_H 24 | 25 | 26 | void Mouse_ShowCursor(void); 27 | void Mouse_HideCursor(void); 28 | 29 | bool Mouse_SetPS2State(bool use); 30 | 31 | void Mouse_ChangePS2Callback(Bit16u pseg, Bit16u pofs); 32 | 33 | 34 | void Mouse_CursorMoved(float xrel,float yrel,float x,float y,bool emulate); 35 | void Mouse_CursorSet(float x,float y); 36 | void Mouse_ButtonPressed(Bit8u button); 37 | void Mouse_ButtonReleased(Bit8u button); 38 | 39 | void Mouse_AutoLock(bool enable); 40 | void Mouse_NewVideoMode(void); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /include/pic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 | #define PIC_MAXIRQ 15 33 | #define PIC_NOIRQ 0xFF 34 | 35 | extern Bitu PIC_IRQCheck; 36 | extern Bitu PIC_IRQActive; 37 | extern Bitu PIC_Ticks; 38 | 39 | static INLINE float PIC_TickIndex(void) { 40 | return (CPU_CycleMax-CPU_CycleLeft-CPU_Cycles)/(float)CPU_CycleMax; 41 | } 42 | 43 | static INLINE Bits PIC_TickIndexND(void) { 44 | return CPU_CycleMax-CPU_CycleLeft-CPU_Cycles; 45 | } 46 | 47 | static INLINE Bits PIC_MakeCycles(double amount) { 48 | return (Bits)(CPU_CycleMax*amount); 49 | } 50 | 51 | static INLINE double PIC_FullIndex(void) { 52 | return PIC_Ticks+(double)PIC_TickIndex(); 53 | } 54 | 55 | void PIC_ActivateIRQ(Bitu irq); 56 | void PIC_DeActivateIRQ(Bitu irq); 57 | 58 | void PIC_runIRQs(void); 59 | bool PIC_RunQueue(void); 60 | 61 | //Delay in milliseconds 62 | void PIC_AddEvent(PIC_EventHandler handler,float delay,Bitu val=0); 63 | void PIC_RemoveEvents(PIC_EventHandler handler); 64 | void PIC_RemoveSpecificEvents(PIC_EventHandler handler, Bitu val); 65 | 66 | void PIC_SetIRQMask(Bitu irq, bool masked); 67 | #endif 68 | -------------------------------------------------------------------------------- /include/programs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: programs.h,v 1.19 2009-05-27 09:15:41 qbix79 Exp $ */ 20 | 21 | #ifndef DOSBOX_PROGRAMS_H 22 | #define DOSBOX_PROGRAMS_H 23 | 24 | #ifndef DOSBOX_DOSBOX_H 25 | #include "dosbox.h" 26 | #endif 27 | #ifndef DOSBOX_DOS_INC_H 28 | #include "dos_inc.h" 29 | #endif 30 | 31 | #ifndef CH_LIST 32 | #define CH_LIST 33 | #include 34 | #endif 35 | 36 | #ifndef CH_STRING 37 | #define CH_STRING 38 | #include 39 | #endif 40 | 41 | class CommandLine { 42 | public: 43 | CommandLine(int argc,char const * const argv[]); 44 | CommandLine(char const * const name,char const * const cmdline); 45 | const char * GetFileName(){ return file_name.c_str();} 46 | 47 | bool FindExist(char const * const name,bool remove=false); 48 | bool FindHex(char const * const name,int & value,bool remove=false); 49 | bool FindInt(char const * const name,int & value,bool remove=false); 50 | bool FindString(char const * const name,std::string & value,bool remove=false); 51 | bool FindCommand(unsigned int which,std::string & value); 52 | bool FindStringBegin(char const * const begin,std::string & value, bool remove=false); 53 | bool FindStringRemain(char const * const name,std::string & value); 54 | bool GetStringRemain(std::string & value); 55 | unsigned int GetCount(void); 56 | void Shift(unsigned int amount=1); 57 | Bit16u Get_arglength(); 58 | 59 | private: 60 | typedef std::list::iterator cmd_it; 61 | std::list cmds; 62 | std::string file_name; 63 | bool FindEntry(char const * const name,cmd_it & it,bool neednext=false); 64 | }; 65 | 66 | class Program { 67 | public: 68 | Program(); 69 | virtual ~Program(){ 70 | delete cmd; 71 | delete psp; 72 | } 73 | std::string temp_line; 74 | CommandLine * cmd; 75 | DOS_PSP * psp; 76 | virtual void Run(void)=0; 77 | bool GetEnvStr(const char * entry,std::string & result); 78 | bool GetEnvNum(Bitu num,std::string & result); 79 | Bitu GetEnvCount(void); 80 | bool SetEnv(const char * entry,const char * new_string); 81 | void WriteOut(const char * format,...); /* Write to standard output */ 82 | void WriteOut_NoParsing(const char * format); /* Write to standard output, no parsing */ 83 | void ChangeToLongCmd(); 84 | 85 | }; 86 | 87 | typedef void (PROGRAMS_Main)(Program * * make); 88 | void PROGRAMS_MakeFile(char const * const name,PROGRAMS_Main * main); 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /include/regs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 | FLAG_AC ) 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-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 | #define RENDER_USE_ADVANCED_SCALERS 3 27 | 28 | #include "../src/gui/render_scalers.h" 29 | 30 | #define RENDER_SKIP_CACHE 16 31 | //Enable this for scalers to support 0 input for empty lines 32 | //#define RENDER_NULL_INPUT 33 | 34 | typedef struct { 35 | struct { 36 | Bit8u red; 37 | Bit8u green; 38 | Bit8u blue; 39 | Bit8u unused; 40 | } rgb[256]; 41 | union { 42 | Bit16u b16[256]; 43 | Bit32u b32[256]; 44 | } lut; 45 | bool changed; 46 | Bit8u modified[256]; 47 | Bitu first; 48 | Bitu last; 49 | } RenderPal_t; 50 | 51 | typedef struct { 52 | struct { 53 | Bitu width, start; 54 | Bitu height; 55 | Bitu bpp; 56 | bool dblw,dblh; 57 | double ratio; 58 | float fps; 59 | } src; 60 | struct { 61 | Bitu count; 62 | Bitu max; 63 | Bitu index; 64 | Bit8u hadSkip[RENDER_SKIP_CACHE]; 65 | } frameskip; 66 | struct { 67 | Bitu size; 68 | scalerMode_t inMode; 69 | scalerMode_t outMode; 70 | scalerOperation_t op; 71 | bool clearCache; 72 | bool forced; 73 | ScalerLineHandler_t lineHandler; 74 | ScalerLineHandler_t linePalHandler; 75 | ScalerComplexHandler_t complexHandler; 76 | Bitu blocks, lastBlock; 77 | Bitu outPitch; 78 | Bit8u *outWrite; 79 | Bitu cachePitch; 80 | Bit8u *cacheRead; 81 | Bitu inHeight, inLine, outLine; 82 | } scale; 83 | RenderPal_t pal; 84 | bool updating; 85 | bool active; 86 | bool aspect; 87 | bool fullFrame; 88 | } Render_t; 89 | 90 | extern Render_t render; 91 | extern ScalerLineHandler_t RENDER_DrawLine; 92 | void RENDER_SetSize(Bitu width,Bitu height,Bitu bpp,float fps,double ratio,bool dblw,bool dblh); 93 | bool RENDER_StartUpdate(void); 94 | void RENDER_EndUpdate(bool abort); 95 | void RENDER_SetPal(Bit8u entry,Bit8u red,Bit8u green,Bit8u blue); 96 | 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /include/shell.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: shell.h,v 1.28 2009-07-03 19:36:57 qbix79 Exp $ */ 20 | 21 | #ifndef DOSBOX_SHELL_H 22 | #define DOSBOX_SHELL_H 23 | 24 | #include 25 | #ifndef DOSBOX_DOSBOX_H 26 | #include "dosbox.h" 27 | #endif 28 | #ifndef DOSBOX_PROGRAMS_H 29 | #include "programs.h" 30 | #endif 31 | 32 | #include 33 | #include 34 | 35 | #define CMD_MAXLINE 4096 36 | #define CMD_MAXCMDS 20 37 | #define CMD_OLDSIZE 4096 38 | extern Bitu call_shellstop; 39 | /* first_shell is used to add and delete stuff from the shell env 40 | * by "external" programs. (config) */ 41 | extern Program * first_shell; 42 | 43 | class DOS_Shell; 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 | 74 | void Run(void); 75 | void RunInternal(void); //for command /C 76 | /* A load of subfunctions */ 77 | void ParseLine(char * line); 78 | Bitu GetRedirection(char *s, char **ifn, char **ofn,bool * append); 79 | void InputCommand(char * line); 80 | void ShowPrompt(); 81 | void DoCommand(char * cmd); 82 | bool Execute(char * name,char * args); 83 | /* Checks if it matches a hardware-property */ 84 | bool CheckConfig(char* cmd_in,char*line); 85 | /* Some internal used functions */ 86 | char * Which(char * name); 87 | /* Some supported commands */ 88 | void CMD_HELP(char * args); 89 | void CMD_CLS(char * args); 90 | void CMD_COPY(char * args); 91 | void CMD_DIR(char * args); 92 | void CMD_DELETE(char * args); 93 | void CMD_ECHO(char * args); 94 | void CMD_EXIT(char * args); 95 | void CMD_MKDIR(char * args); 96 | void CMD_CHDIR(char * args); 97 | void CMD_RMDIR(char * args); 98 | void CMD_SET(char * args); 99 | void CMD_IF(char * args); 100 | void CMD_GOTO(char * args); 101 | void CMD_TYPE(char * args); 102 | void CMD_REM(char * args); 103 | void CMD_RENAME(char * args); 104 | void CMD_CALL(char * args); 105 | void SyntaxError(void); 106 | void CMD_PAUSE(char * args); 107 | void CMD_SUBST(char* args); 108 | void CMD_LOADHIGH(char* args); 109 | void CMD_CHOICE(char * args); 110 | void CMD_ATTRIB(char * args); 111 | void CMD_PATH(char * args); 112 | void CMD_SHIFT(char * args); 113 | void CMD_VER(char * args); 114 | /* The shell's variables */ 115 | Bit16u input_handle; 116 | BatchFile * bf; 117 | bool echo; 118 | bool exit; 119 | bool call; 120 | }; 121 | 122 | struct SHELL_Cmd { 123 | const char * name; /* Command name*/ 124 | Bit32u flags; /* Flags about the command */ 125 | void (DOS_Shell::*handler)(char * args); /* Handler for this command */ 126 | const char * help; /* String with command help */ 127 | }; 128 | 129 | /* Object to manage lines in the autoexec.bat The lines get removed from 130 | * the file if the object gets destroyed. The environment is updated 131 | * as well if the line set a a variable */ 132 | class AutoexecObject{ 133 | private: 134 | bool installed; 135 | std::string buf; 136 | public: 137 | AutoexecObject():installed(false){ }; 138 | void Install(std::string const &in); 139 | void InstallBefore(std::string const &in); 140 | ~AutoexecObject(); 141 | private: 142 | void CreateAutoexec(void); 143 | }; 144 | 145 | #endif 146 | -------------------------------------------------------------------------------- /include/support.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: support.h,v 1.18 2009-05-27 09:15:41 qbix79 Exp $ */ 20 | 21 | #ifndef DOSBOX_SUPPORT_H 22 | #define DOSBOX_SUPPORT_H 23 | 24 | #include 25 | #include 26 | #include 27 | #ifndef DOSBOX_DOSBOX_H 28 | #include "dosbox.h" 29 | #endif 30 | 31 | #if defined (_MSC_VER) /* MS Visual C++ */ 32 | #define strcasecmp(a,b) stricmp(a,b) 33 | #define strncasecmp(a,b,n) _strnicmp(a,b,n) 34 | #endif 35 | 36 | #define safe_strncpy(a,b,n) do { strncpy((a),(b),(n)-1); (a)[(n)-1] = 0; } while (0) 37 | 38 | #ifdef HAVE_STRINGS_H 39 | #include 40 | #endif 41 | 42 | void strreplace(char * str,char o,char n); 43 | char *ltrim(char *str); 44 | char *rtrim(char *str); 45 | char *trim(char * str); 46 | char * upcase(char * str); 47 | char * lowcase(char * str); 48 | 49 | bool ScanCMDBool(char * cmd,char const * const check); 50 | char * ScanCMDRemain(char * cmd); 51 | char * StripWord(char *&cmd); 52 | bool IsDecWord(char * word); 53 | bool IsHexWord(char * word); 54 | Bits ConvDecWord(char * word); 55 | Bits ConvHexWord(char * word); 56 | 57 | void upcase(std::string &str); 58 | void lowcase(std::string &str); 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /include/timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | #ifndef DOSBOX_TIMER_H 20 | #define DOSBOX_TIMER_H 21 | 22 | /* underlying clock rate in HZ */ 23 | #include 24 | 25 | #define PIT_TICK_RATE 1193182 26 | 27 | #define GetTicks() SDL_GetTicks() 28 | 29 | typedef void (*TIMER_TickHandler)(void); 30 | 31 | /* Register a function that gets called everytime if 1 or more ticks pass */ 32 | void TIMER_AddTickHandler(TIMER_TickHandler handler); 33 | void TIMER_DelTickHandler(TIMER_TickHandler handler); 34 | 35 | /* This will add 1 milliscond to all timers */ 36 | void TIMER_AddTick(void); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /include/video.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: video.h,v 1.26 2009-05-27 09:15:41 qbix79 Exp $ */ 20 | 21 | #ifndef DOSBOX_VIDEO_H 22 | #define DOSBOX_VIDEO_H 23 | 24 | #ifndef KOLIBRI 25 | #define REDUCE_JOYSTICK_POLLING 26 | #endif 27 | 28 | typedef enum { 29 | GFX_CallBackReset, 30 | GFX_CallBackStop, 31 | GFX_CallBackRedraw 32 | } GFX_CallBackFunctions_t; 33 | 34 | typedef void (*GFX_CallBack_t)( GFX_CallBackFunctions_t function ); 35 | 36 | struct GFX_PalEntry { 37 | Bit8u r; 38 | Bit8u g; 39 | Bit8u b; 40 | Bit8u unused; 41 | }; 42 | 43 | #define GFX_CAN_8 0x0001 44 | #define GFX_CAN_15 0x0002 45 | #define GFX_CAN_16 0x0004 46 | #define GFX_CAN_32 0x0008 47 | 48 | #define GFX_LOVE_8 0x0010 49 | #define GFX_LOVE_15 0x0020 50 | #define GFX_LOVE_16 0x0040 51 | #define GFX_LOVE_32 0x0080 52 | 53 | #define GFX_RGBONLY 0x0100 54 | 55 | #define GFX_SCALING 0x1000 56 | #define GFX_HARDWARE 0x2000 57 | 58 | #define GFX_CAN_RANDOM 0x4000 //If the interface can also do random access surface 59 | 60 | void GFX_Events(void); 61 | void GFX_SetPalette(Bitu start,Bitu count,GFX_PalEntry * entries); 62 | Bitu GFX_GetBestMode(Bitu flags); 63 | Bitu GFX_GetRGB(Bit8u red,Bit8u green,Bit8u blue); 64 | Bitu GFX_SetSize(Bitu width,Bitu height,Bitu flags,double scalex,double scaley,GFX_CallBack_t cb); 65 | 66 | void GFX_ResetScreen(void); 67 | void GFX_Start(void); 68 | void GFX_Stop(void); 69 | void GFX_SwitchFullScreen(void); 70 | bool GFX_StartUpdate(Bit8u * & pixels,Bitu & pitch); 71 | void GFX_EndUpdate( const Bit16u *changedLines ); 72 | void GFX_GetSize(int &width, int &height, bool &fullscreen); 73 | void GFX_LosingFocus(void); 74 | 75 | #if defined (WIN32) 76 | bool GFX_SDLUsingWinDIB(void); 77 | #endif 78 | 79 | #if defined (REDUCE_JOYSTICK_POLLING) 80 | void MAPPER_UpdateJoysticks(void); 81 | #endif 82 | 83 | /* Mouse related */ 84 | void GFX_CaptureMouse(void); 85 | extern bool mouselocked; //true if mouse is confined to window 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /kolibrios_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | if [[ -z "$KOS_SDK_DIR" ]]; then 5 | echo "Please set KOS_SDK_DIR. Typically this is /contrib/sdk" 6 | exit 1 7 | fi 8 | 9 | CFLAGS="-O2 -fno-ident -fomit-frame-pointer -fno-stack-check -fno-stack-protector \ 10 | -mno-stack-arg-probe -fno-asynchronous-unwind-tables -ffast-math \ 11 | -mno-ms-bitfields -march=pentium-mmx \ 12 | -U__WIN32__ -U_Win32 -U_WIN32 -U__MINGW32__ -UWIN32 -DKOLIBRI=1 \ 13 | -I $KOS_SDK_DIR/sources/newlib/libc/include \ 14 | -I $KOS_SDK_DIR/sources/SDL-1.2.2_newlib/include \ 15 | -I $KOS_SDK_DIR/sources/libstdc++-v3/include/" 16 | 17 | LDFLAGS="-static -nostdlib -T $KOS_SDK_DIR/sources/newlib/app-dynamic.lds \ 18 | -Wl,--image-base=0,--subsystem=native,--file-alignment=16,--section-alignment=16 \ 19 | -L $KOS_SDK_DIR/lib \ 20 | -L /home/autobuild/tools/win32/mingw32/lib" 21 | 22 | ./configure \ 23 | --host=i686-kolibri \ 24 | --enable-core-inline \ 25 | --disable-opengl \ 26 | --with-sdl-prefix="$KOS_SDK_DIR/sources/SDL-1.2.2_newlib" \ 27 | CC=kos32-gcc \ 28 | CXX=kos32-g++ \ 29 | CPP="kos32-gcc -E $CFLAGS" \ 30 | CFLAGS="$CFLAGS" \ 31 | CXXFLAGS="$CFLAGS" \ 32 | LDFLAGS="$LDFLAGS" \ 33 | LIBS="-lSDLn -lsound -lstdc++ -lsupc++ -lgcc -lc.dll" \ 34 | ac_cv_header_pwd_h=no 35 | 36 | make -j 8 37 | kos32-strip -s src/dosbox.exe 38 | kos32-objcopy -Obinary src/dosbox.exe dosbox 39 | 40 | if command -v kpack > /dev/null; then 41 | kpack dosbox 42 | fi -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I$(top_srcdir)/include 2 | 3 | SUBDIRS = cpu debug dos fpu gui hardware libs ints misc shell platform 4 | 5 | bin_PROGRAMS = dosbox 6 | 7 | if HAVE_WINDRES 8 | ico_stuff = winres.rc 9 | endif 10 | 11 | .rc.o: 12 | $(WINDRES) -o $@ $< 13 | 14 | dosbox_SOURCES = dosbox.cpp $(ico_stuff) 15 | dosbox_LDADD = cpu/libcpu.a debug/libdebug.a dos/libdos.a fpu/libfpu.a hardware/libhardware.a gui/libgui.a \ 16 | ints/libints.a misc/libmisc.a shell/libshell.a hardware/mame/libmame.a \ 17 | hardware/serialport/libserial.a libs/gui_tk/libgui_tk.a 18 | 19 | EXTRA_DIST = winres.rc dosbox.ico 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/cpu/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = core_full core_normal core_dyn_x86 core_dynrec 2 | AM_CPPFLAGS = -I$(top_srcdir)/include 3 | 4 | noinst_LIBRARIES = libcpu.a 5 | libcpu_a_SOURCES = callback.cpp cpu.cpp flags.cpp modrm.cpp modrm.h core_full.cpp instructions.h \ 6 | paging.cpp lazyflags.h core_normal.cpp core_simple.cpp core_prefetch.cpp \ 7 | core_dyn_x86.cpp core_dynrec.cpp 8 | -------------------------------------------------------------------------------- /src/cpu/core_dyn_x86/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_HEADERS = cache.h helpers.h decoder.h risc_x86.h string.h \ 2 | dyn_fpu.h dyn_fpu_dh.h -------------------------------------------------------------------------------- /src/cpu/core_dyn_x86/helpers.h: -------------------------------------------------------------------------------- 1 | static bool dyn_helper_divb(Bit8u val) { 2 | if (!val) return CPU_PrepareException(0,0); 3 | Bitu quo=reg_ax / val; 4 | Bit8u rem=(Bit8u)(reg_ax % val); 5 | Bit8u quo8=(Bit8u)(quo&0xff); 6 | if (quo>0xff) return CPU_PrepareException(0,0); 7 | reg_ah=rem; 8 | reg_al=quo8; 9 | return false; 10 | } 11 | 12 | static bool dyn_helper_idivb(Bit8s val) { 13 | if (!val) return CPU_PrepareException(0,0); 14 | Bits quo=(Bit16s)reg_ax / val; 15 | Bit8s rem=(Bit8s)((Bit16s)reg_ax % val); 16 | Bit8s quo8s=(Bit8s)(quo&0xff); 17 | if (quo!=(Bit16s)quo8s) return CPU_PrepareException(0,0); 18 | reg_ah=rem; 19 | reg_al=quo8s; 20 | return false; 21 | } 22 | 23 | static bool dyn_helper_divw(Bit16u val) { 24 | if (!val) return CPU_PrepareException(0,0); 25 | Bitu num=(reg_dx<<16)|reg_ax; 26 | Bitu quo=num/val; 27 | Bit16u rem=(Bit16u)(num % val); 28 | Bit16u quo16=(Bit16u)(quo&0xffff); 29 | if (quo!=(Bit32u)quo16) return CPU_PrepareException(0,0); 30 | reg_dx=rem; 31 | reg_ax=quo16; 32 | return false; 33 | } 34 | 35 | static bool dyn_helper_idivw(Bit16s val) { 36 | if (!val) return CPU_PrepareException(0,0); 37 | Bits num=(reg_dx<<16)|reg_ax; 38 | Bits quo=num/val; 39 | Bit16s rem=(Bit16s)(num % val); 40 | Bit16s quo16s=(Bit16s)quo; 41 | if (quo!=(Bit32s)quo16s) return CPU_PrepareException(0,0); 42 | reg_dx=rem; 43 | reg_ax=quo16s; 44 | return false; 45 | } 46 | 47 | static bool dyn_helper_divd(Bit32u val) { 48 | if (!val) return CPU_PrepareException(0,0); 49 | Bit64u num=(((Bit64u)reg_edx)<<32)|reg_eax; 50 | Bit64u quo=num/val; 51 | Bit32u rem=(Bit32u)(num % val); 52 | Bit32u quo32=(Bit32u)(quo&0xffffffff); 53 | if (quo!=(Bit64u)quo32) return CPU_PrepareException(0,0); 54 | reg_edx=rem; 55 | reg_eax=quo32; 56 | return false; 57 | } 58 | 59 | static bool dyn_helper_idivd(Bit32s val) { 60 | if (!val) return CPU_PrepareException(0,0); 61 | Bit64s num=(((Bit64u)reg_edx)<<32)|reg_eax; 62 | Bit64s quo=num/val; 63 | Bit32s rem=(Bit32s)(num % val); 64 | Bit32s quo32s=(Bit32s)(quo&0xffffffff); 65 | if (quo!=(Bit64s)quo32s) return CPU_PrepareException(0,0); 66 | reg_edx=rem; 67 | reg_eax=quo32s; 68 | return false; 69 | } 70 | -------------------------------------------------------------------------------- /src/cpu/core_dynrec/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_HEADERS = cache.h decoder.h decoder_basic.h decoder_opcodes.h \ 2 | dyn_fpu.h operators.h risc_x64.h risc_x86.h risc_mipsel32.h \ 3 | risc_armv4le.h risc_armv4le-common.h \ 4 | risc_armv4le-s3.h risc_armv4le-o3.h risc_armv4le-thumb.h \ 5 | risc_armv4le-thumb-iw.h risc_armv4le-thumb-niw.h 6 | -------------------------------------------------------------------------------- /src/cpu/core_dynrec/risc_armv4le-common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: risc_armv4le-common.h,v 1.3 2009-05-16 21:52:47 c2woody Exp $ */ 20 | 21 | 22 | /* ARMv4 (little endian) backend by M-HT (common data/functions) */ 23 | 24 | 25 | // some configuring defines that specify the capabilities of this architecture 26 | // or aspects of the recompiling 27 | 28 | // protect FC_ADDR over function calls if necessaray 29 | // #define DRC_PROTECT_ADDR_REG 30 | 31 | // try to use non-flags generating functions if possible 32 | #define DRC_FLAGS_INVALIDATION 33 | // try to replace _simple functions by code 34 | #define DRC_FLAGS_INVALIDATION_DCODE 35 | 36 | // type with the same size as a pointer 37 | #define DRC_PTR_SIZE_IM Bit32u 38 | 39 | // calling convention modifier 40 | #define DRC_CALL_CONV /* nothing */ 41 | #define DRC_FC /* nothing */ 42 | 43 | // use FC_REGS_ADDR to hold the address of "cpu_regs" and to access it using FC_REGS_ADDR 44 | #define DRC_USE_REGS_ADDR 45 | // use FC_SEGS_ADDR to hold the address of "Segs" and to access it using FC_SEGS_ADDR 46 | #define DRC_USE_SEGS_ADDR 47 | 48 | // register mapping 49 | typedef Bit8u HostReg; 50 | 51 | // "lo" registers 52 | #define HOST_r0 0 53 | #define HOST_r1 1 54 | #define HOST_r2 2 55 | #define HOST_r3 3 56 | #define HOST_r4 4 57 | #define HOST_r5 5 58 | #define HOST_r6 6 59 | #define HOST_r7 7 60 | // "hi" registers 61 | #define HOST_r8 8 62 | #define HOST_r9 9 63 | #define HOST_r10 10 64 | #define HOST_r11 11 65 | #define HOST_r12 12 66 | #define HOST_r13 13 67 | #define HOST_r14 14 68 | #define HOST_r15 15 69 | 70 | // register aliases 71 | // "lo" registers 72 | #define HOST_a1 HOST_r0 73 | #define HOST_a2 HOST_r1 74 | #define HOST_a3 HOST_r2 75 | #define HOST_a4 HOST_r3 76 | #define HOST_v1 HOST_r4 77 | #define HOST_v2 HOST_r5 78 | #define HOST_v3 HOST_r6 79 | #define HOST_v4 HOST_r7 80 | // "hi" registers 81 | #define HOST_v5 HOST_r8 82 | #define HOST_v6 HOST_r9 83 | #define HOST_v7 HOST_r10 84 | #define HOST_v8 HOST_r11 85 | #define HOST_ip HOST_r12 86 | #define HOST_sp HOST_r13 87 | #define HOST_lr HOST_r14 88 | #define HOST_pc HOST_r15 89 | 90 | 91 | static void cache_block_closing(Bit8u* block_start,Bitu block_size) { 92 | #if (__ARM_EABI__) 93 | //flush cache - eabi 94 | register unsigned long _beg __asm ("a1") = (unsigned long)(block_start); // block start 95 | register unsigned long _end __asm ("a2") = (unsigned long)(block_start+block_size); // block end 96 | register unsigned long _flg __asm ("a3") = 0; 97 | register unsigned long _par __asm ("r7") = 0xf0002; // sys_cacheflush 98 | __asm __volatile ("swi 0x0" 99 | : // no outputs 100 | : "r" (_beg), "r" (_end), "r" (_flg), "r" (_par) 101 | ); 102 | #else 103 | // GP2X BEGIN 104 | //flush cache - old abi 105 | register unsigned long _beg __asm ("a1") = (unsigned long)(block_start); // block start 106 | register unsigned long _end __asm ("a2") = (unsigned long)(block_start+block_size); // block end 107 | register unsigned long _flg __asm ("a3") = 0; 108 | __asm __volatile ("swi 0x9f0002 @ sys_cacheflush" 109 | : // no outputs 110 | : "r" (_beg), "r" (_end), "r" (_flg) 111 | ); 112 | // GP2X END 113 | #endif 114 | } 115 | -------------------------------------------------------------------------------- /src/cpu/core_dynrec/risc_armv4le.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: risc_armv4le.h,v 1.3 2009-05-27 09:15:41 qbix79 Exp $ */ 20 | 21 | 22 | /* ARMv4 (little endian) backend (switcher) by M-HT */ 23 | 24 | #include "risc_armv4le-common.h" 25 | 26 | // choose your destiny: 27 | #include "risc_armv4le-thumb-niw.h" 28 | //#include "risc_armv4le-thumb-iw.h" 29 | //#include "risc_armv4le-thumb.h" 30 | //#include "risc_armv4le-s3.h" 31 | //#include "risc_armv4le-o3.h" 32 | -------------------------------------------------------------------------------- /src/cpu/core_full.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | #include "dosbox.h" 20 | 21 | #include "pic.h" 22 | #include "regs.h" 23 | #include "cpu.h" 24 | #include "lazyflags.h" 25 | #include "paging.h" 26 | #include "fpu.h" 27 | #include "debug.h" 28 | #include "inout.h" 29 | #include "callback.h" 30 | 31 | 32 | typedef PhysPt EAPoint; 33 | #define SegBase(c) SegPhys(c) 34 | 35 | #define LoadMb(off) mem_readb_inline(off) 36 | #define LoadMw(off) mem_readw_inline(off) 37 | #define LoadMd(off) mem_readd_inline(off) 38 | 39 | #define LoadMbs(off) (Bit8s)(LoadMb(off)) 40 | #define LoadMws(off) (Bit16s)(LoadMw(off)) 41 | #define LoadMds(off) (Bit32s)(LoadMd(off)) 42 | 43 | #define SaveMb(off,val) mem_writeb_inline(off,val) 44 | #define SaveMw(off,val) mem_writew_inline(off,val) 45 | #define SaveMd(off,val) mem_writed_inline(off,val) 46 | 47 | #define LoadD(reg) reg 48 | #define SaveD(reg,val) reg=val 49 | 50 | 51 | 52 | #include "core_full/loadwrite.h" 53 | #include "core_full/support.h" 54 | #include "core_full/optable.h" 55 | #include "instructions.h" 56 | 57 | #define EXCEPTION(blah) \ 58 | { \ 59 | Bit8u new_num=blah; \ 60 | CPU_Exception(new_num,0); \ 61 | continue; \ 62 | } 63 | 64 | Bits CPU_Core_Full_Run(void) { 65 | FullData inst; 66 | while (CPU_Cycles-->0) { 67 | #if C_DEBUG 68 | cycle_count++; 69 | #if C_HEAVY_DEBUG 70 | if (DEBUG_HeavyIsBreakpoint()) { 71 | FillFlags(); 72 | return debugCallback; 73 | }; 74 | #endif 75 | #endif 76 | LoadIP(); 77 | inst.entry=cpu.code.big*0x200; 78 | inst.prefix=cpu.code.big; 79 | restartopcode: 80 | inst.entry=(inst.entry & 0xffffff00) | Fetchb(); 81 | inst.code=OpCodeTable[inst.entry]; 82 | #include "core_full/load.h" 83 | #include "core_full/op.h" 84 | #include "core_full/save.h" 85 | nextopcode:; 86 | SaveIP(); 87 | continue; 88 | illegalopcode: 89 | LOG(LOG_CPU,LOG_NORMAL)("Illegal opcode"); 90 | CPU_Exception(0x6,0); 91 | } 92 | FillFlags(); 93 | return CBRET_NONE; 94 | } 95 | 96 | 97 | void CPU_Core_Full_Init(void) { 98 | 99 | } 100 | -------------------------------------------------------------------------------- /src/cpu/core_full/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | noinst_HEADERS = ea_lookup.h load.h loadwrite.h op.h optable.h save.h \ 3 | string.h support.h 4 | -------------------------------------------------------------------------------- /src/cpu/core_full/loadwrite.h: -------------------------------------------------------------------------------- 1 | #define SaveIP() reg_eip=(Bit32u)(inst.cseip-SegBase(cs)); 2 | #define LoadIP() inst.cseip=SegBase(cs)+reg_eip; 3 | #define GetIP() (inst.cseip-SegBase(cs)) 4 | 5 | #define RunException() { \ 6 | CPU_Exception(cpu.exception.which,cpu.exception.error); \ 7 | continue; \ 8 | } 9 | 10 | static INLINE Bit8u the_Fetchb(EAPoint & loc) { 11 | Bit8u temp=LoadMb(loc); 12 | loc+=1; 13 | return temp; 14 | } 15 | 16 | static INLINE Bit16u the_Fetchw(EAPoint & loc) { 17 | Bit16u temp=LoadMw(loc); 18 | loc+=2; 19 | return temp; 20 | } 21 | static INLINE Bit32u the_Fetchd(EAPoint & loc) { 22 | Bit32u temp=LoadMd(loc); 23 | loc+=4; 24 | return temp; 25 | } 26 | 27 | #define Fetchb() the_Fetchb(inst.cseip) 28 | #define Fetchw() the_Fetchw(inst.cseip) 29 | #define Fetchd() the_Fetchd(inst.cseip) 30 | 31 | #define Fetchbs() (Bit8s)the_Fetchb(inst.cseip) 32 | #define Fetchws() (Bit16s)the_Fetchw(inst.cseip) 33 | #define Fetchds() (Bit32s)the_Fetchd(inst.cseip) 34 | 35 | #define Push_16 CPU_Push16 36 | #define Push_32 CPU_Push32 37 | #define Pop_16 CPU_Pop16 38 | #define Pop_32 CPU_Pop32 39 | 40 | -------------------------------------------------------------------------------- /src/cpu/core_full/save.h: -------------------------------------------------------------------------------- 1 | /* Write the data from the opcode */ 2 | switch (inst.code.save) { 3 | /* Byte */ 4 | case S_C_Eb: 5 | inst_op1_b=inst.cond ? 1 : 0; 6 | case S_Eb: 7 | if (inst.rm<0xc0) SaveMb(inst.rm_eaa,inst_op1_b); 8 | else reg_8(inst.rm_eai)=inst_op1_b; 9 | break; 10 | case S_Gb: 11 | reg_8(inst.rm_index)=inst_op1_b; 12 | break; 13 | case S_EbGb: 14 | if (inst.rm<0xc0) SaveMb(inst.rm_eaa,inst_op1_b); 15 | else reg_8(inst.rm_eai)=inst_op1_b; 16 | reg_8(inst.rm_index)=inst_op2_b; 17 | break; 18 | /* Word */ 19 | case S_Ew: 20 | if (inst.rm<0xc0) SaveMw(inst.rm_eaa,inst_op1_w); 21 | else reg_16(inst.rm_eai)=inst_op1_w; 22 | break; 23 | case S_Gw: 24 | reg_16(inst.rm_index)=inst_op1_w; 25 | break; 26 | case S_EwGw: 27 | if (inst.rm<0xc0) SaveMw(inst.rm_eaa,inst_op1_w); 28 | else reg_16(inst.rm_eai)=inst_op1_w; 29 | reg_16(inst.rm_index)=inst_op2_w; 30 | break; 31 | /* Dword */ 32 | case S_Ed: 33 | if (inst.rm<0xc0) SaveMd(inst.rm_eaa,inst_op1_d); 34 | else reg_32(inst.rm_eai)=inst_op1_d; 35 | break; 36 | case S_EdMw: /* Special one 16 to memory, 32 zero extend to reg */ 37 | if (inst.rm<0xc0) SaveMw(inst.rm_eaa,inst_op1_w); 38 | else reg_32(inst.rm_eai)=inst_op1_d; 39 | break; 40 | case S_Gd: 41 | reg_32(inst.rm_index)=inst_op1_d; 42 | break; 43 | case S_EdGd: 44 | if (inst.rm<0xc0) SaveMd(inst.rm_eaa,inst_op1_d); 45 | else reg_32(inst.rm_eai)=inst_op1_d; 46 | reg_32(inst.rm_index)=inst_op2_d; 47 | break; 48 | 49 | case S_REGb: 50 | reg_8(inst.code.extra)=inst_op1_b; 51 | break; 52 | case S_REGw: 53 | reg_16(inst.code.extra)=inst_op1_w; 54 | break; 55 | case S_REGd: 56 | reg_32(inst.code.extra)=inst_op1_d; 57 | break; 58 | case S_SEGm: 59 | if (CPU_SetSegGeneral((SegNames)inst.rm_index,inst_op1_w)) RunException(); 60 | break; 61 | case S_SEGGw: 62 | if (CPU_SetSegGeneral((SegNames)inst.code.extra,inst_op2_w)) RunException(); 63 | reg_16(inst.rm_index)=inst_op1_w; 64 | break; 65 | case S_SEGGd: 66 | if (CPU_SetSegGeneral((SegNames)inst.code.extra,inst_op2_w)) RunException(); 67 | reg_32(inst.rm_index)=inst_op1_d; 68 | break; 69 | case S_PUSHw: 70 | Push_16(inst_op1_w); 71 | break; 72 | case S_PUSHd: 73 | Push_32(inst_op1_d); 74 | break; 75 | 76 | case S_C_AIPw: 77 | if (!inst.cond) goto nextopcode; 78 | case S_AIPw: 79 | SaveIP(); 80 | reg_eip+=inst_op1_d; 81 | reg_eip&=0xffff; 82 | continue; 83 | case S_C_AIPd: 84 | if (!inst.cond) goto nextopcode; 85 | case S_AIPd: 86 | SaveIP(); 87 | reg_eip+=inst_op1_d; 88 | continue; 89 | case S_IPIw: 90 | reg_esp+=Fetchw(); 91 | case S_IP: 92 | SaveIP(); 93 | reg_eip=inst_op1_d; 94 | continue; 95 | case 0: 96 | break; 97 | default: 98 | LOG(LOG_CPU,LOG_ERROR)("SAVE:Unhandled code %d entry %X",inst.code.save,inst.entry); 99 | } 100 | -------------------------------------------------------------------------------- /src/cpu/core_normal/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | noinst_HEADERS = helpers.h prefix_none.h prefix_66.h prefix_0f.h support.h table_ea.h \ 3 | prefix_66_0f.h string.h 4 | -------------------------------------------------------------------------------- /src/cpu/core_normal/support.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | 20 | #define LoadMbs(off) (Bit8s)(LoadMb(off)) 21 | #define LoadMws(off) (Bit16s)(LoadMw(off)) 22 | #define LoadMds(off) (Bit32s)(LoadMd(off)) 23 | 24 | #define LoadRb(reg) reg 25 | #define LoadRw(reg) reg 26 | #define LoadRd(reg) reg 27 | 28 | #define SaveRb(reg,val) reg=val 29 | #define SaveRw(reg,val) reg=val 30 | #define SaveRd(reg,val) reg=val 31 | 32 | static INLINE Bit8s Fetchbs() { 33 | return Fetchb(); 34 | } 35 | static INLINE Bit16s Fetchws() { 36 | return Fetchw(); 37 | } 38 | 39 | static INLINE Bit32s Fetchds() { 40 | return Fetchd(); 41 | } 42 | 43 | 44 | #define RUNEXCEPTION() { \ 45 | CPU_Exception(cpu.exception.which,cpu.exception.error); \ 46 | continue; \ 47 | } 48 | 49 | #define EXCEPTION(blah) \ 50 | { \ 51 | CPU_Exception(blah); \ 52 | continue; \ 53 | } 54 | 55 | //TODO Could probably make all byte operands fast? 56 | #define JumpCond16_b(COND) { \ 57 | SAVEIP; \ 58 | if (COND) reg_ip+=Fetchbs(); \ 59 | reg_ip+=1; \ 60 | continue; \ 61 | } 62 | 63 | #define JumpCond16_w(COND) { \ 64 | SAVEIP; \ 65 | if (COND) reg_ip+=Fetchws(); \ 66 | reg_ip+=2; \ 67 | continue; \ 68 | } 69 | 70 | #define JumpCond32_b(COND) { \ 71 | SAVEIP; \ 72 | if (COND) reg_eip+=Fetchbs(); \ 73 | reg_eip+=1; \ 74 | continue; \ 75 | } 76 | 77 | #define JumpCond32_d(COND) { \ 78 | SAVEIP; \ 79 | if (COND) reg_eip+=Fetchds(); \ 80 | reg_eip+=4; \ 81 | continue; \ 82 | } 83 | 84 | 85 | #define SETcc(cc) \ 86 | { \ 87 | GetRM; \ 88 | if (rm >= 0xc0 ) {GetEArb;*earb=(cc) ? 1 : 0;} \ 89 | else {GetEAa;SaveMb(eaa,(cc) ? 1 : 0);} \ 90 | } 91 | 92 | #include "helpers.h" 93 | #include "table_ea.h" 94 | #include "../modrm.h" 95 | 96 | 97 | -------------------------------------------------------------------------------- /src/cpu/lazyflags.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | #if !defined __LAZYFLAGS_H 20 | #define __LAZYFLAGS_H 21 | 22 | //Flag Handling 23 | Bit32u get_CF(void); 24 | Bit32u get_AF(void); 25 | Bit32u get_ZF(void); 26 | Bit32u get_SF(void); 27 | Bit32u get_OF(void); 28 | Bit32u get_PF(void); 29 | 30 | Bitu FillFlags(void); 31 | void FillFlagsNoCFOF(void); 32 | void DestroyConditionFlags(void); 33 | 34 | #include "regs.h" 35 | 36 | struct LazyFlags { 37 | GenReg32 var1,var2,res; 38 | Bitu type; 39 | Bitu prev_type; 40 | Bitu oldcf; 41 | }; 42 | 43 | extern LazyFlags lfags; 44 | 45 | #define lf_var1b lflags.var1.byte[BL_INDEX] 46 | #define lf_var2b lflags.var2.byte[BL_INDEX] 47 | #define lf_resb lflags.res.byte[BL_INDEX] 48 | 49 | #define lf_var1w lflags.var1.word[W_INDEX] 50 | #define lf_var2w lflags.var2.word[W_INDEX] 51 | #define lf_resw lflags.res.word[W_INDEX] 52 | 53 | #define lf_var1d lflags.var1.dword[DW_INDEX] 54 | #define lf_var2d lflags.var2.dword[DW_INDEX] 55 | #define lf_resd lflags.res.dword[DW_INDEX] 56 | 57 | 58 | extern LazyFlags lflags; 59 | 60 | #define SETFLAGSb(FLAGB) \ 61 | { \ 62 | SETFLAGBIT(OF,get_OF()); \ 63 | lflags.type=t_UNKNOWN; \ 64 | CPU_SetFlags(FLAGB,FMASK_NORMAL & 0xff); \ 65 | } 66 | 67 | #define SETFLAGSw(FLAGW) \ 68 | { \ 69 | lflags.type=t_UNKNOWN; \ 70 | CPU_SetFlagsw(FLAGW); \ 71 | } 72 | 73 | #define SETFLAGSd(FLAGD) \ 74 | { \ 75 | lflags.type=t_UNKNOWN; \ 76 | CPU_SetFlagsd(FLAGD); \ 77 | } 78 | 79 | #define LoadCF SETFLAGBIT(CF,get_CF()); 80 | #define LoadZF SETFLAGBIT(ZF,get_ZF()); 81 | #define LoadSF SETFLAGBIT(SF,get_SF()); 82 | #define LoadOF SETFLAGBIT(OF,get_OF()); 83 | #define LoadAF SETFLAGBIT(AF,get_AF()); 84 | 85 | #define TFLG_O (get_OF()) 86 | #define TFLG_NO (!get_OF()) 87 | #define TFLG_B (get_CF()) 88 | #define TFLG_NB (!get_CF()) 89 | #define TFLG_Z (get_ZF()) 90 | #define TFLG_NZ (!get_ZF()) 91 | #define TFLG_BE (get_CF() || get_ZF()) 92 | #define TFLG_NBE (!get_CF() && !get_ZF()) 93 | #define TFLG_S (get_SF()) 94 | #define TFLG_NS (!get_SF()) 95 | #define TFLG_P (get_PF()) 96 | #define TFLG_NP (!get_PF()) 97 | #define TFLG_L ((get_SF()!=0) != (get_OF()!=0)) 98 | #define TFLG_NL ((get_SF()!=0) == (get_OF()!=0)) 99 | #define TFLG_LE (get_ZF() || ((get_SF()!=0) != (get_OF()!=0))) 100 | #define TFLG_NLE (!get_ZF() && ((get_SF()!=0) == (get_OF()!=0))) 101 | 102 | //Types of Flag changing instructions 103 | enum { 104 | t_UNKNOWN=0, 105 | t_ADDb,t_ADDw,t_ADDd, 106 | t_ORb,t_ORw,t_ORd, 107 | t_ADCb,t_ADCw,t_ADCd, 108 | t_SBBb,t_SBBw,t_SBBd, 109 | t_ANDb,t_ANDw,t_ANDd, 110 | t_SUBb,t_SUBw,t_SUBd, 111 | t_XORb,t_XORw,t_XORd, 112 | t_CMPb,t_CMPw,t_CMPd, 113 | t_INCb,t_INCw,t_INCd, 114 | t_DECb,t_DECw,t_DECd, 115 | t_TESTb,t_TESTw,t_TESTd, 116 | t_SHLb,t_SHLw,t_SHLd, 117 | t_SHRb,t_SHRw,t_SHRd, 118 | t_SARb,t_SARw,t_SARd, 119 | t_ROLb,t_ROLw,t_ROLd, 120 | t_RORb,t_RORw,t_RORd, 121 | t_RCLb,t_RCLw,t_RCLd, 122 | t_RCRb,t_RCRw,t_RCRd, 123 | t_NEGb,t_NEGw,t_NEGd, 124 | 125 | t_DSHLw,t_DSHLd, 126 | t_DSHRw,t_DSHRd, 127 | t_MUL,t_DIV, 128 | t_NOTDONE, 129 | t_LASTFLAG 130 | }; 131 | 132 | #endif 133 | -------------------------------------------------------------------------------- /src/cpu/modrm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | extern Bit8u * lookupRMregb[]; 20 | extern Bit16u * lookupRMregw[]; 21 | extern Bit32u * lookupRMregd[]; 22 | extern Bit8u * lookupRMEAregb[256]; 23 | extern Bit16u * lookupRMEAregw[256]; 24 | extern Bit32u * lookupRMEAregd[256]; 25 | 26 | #define GetRM \ 27 | Bit8u rm=Fetchb(); 28 | 29 | #define Getrb \ 30 | Bit8u * rmrb; \ 31 | rmrb=lookupRMregb[rm]; 32 | 33 | #define Getrw \ 34 | Bit16u * rmrw; \ 35 | rmrw=lookupRMregw[rm]; 36 | 37 | #define Getrd \ 38 | Bit32u * rmrd; \ 39 | rmrd=lookupRMregd[rm]; 40 | 41 | 42 | #define GetRMrb \ 43 | GetRM; \ 44 | Getrb; 45 | 46 | #define GetRMrw \ 47 | GetRM; \ 48 | Getrw; 49 | 50 | #define GetRMrd \ 51 | GetRM; \ 52 | Getrd; 53 | 54 | 55 | #define GetEArb \ 56 | Bit8u * earb=lookupRMEAregb[rm]; 57 | 58 | #define GetEArw \ 59 | Bit16u * earw=lookupRMEAregw[rm]; 60 | 61 | #define GetEArd \ 62 | Bit32u * eard=lookupRMEAregd[rm]; 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/debug/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I$(top_srcdir)/include 2 | 3 | noinst_LIBRARIES = libdebug.a 4 | libdebug_a_SOURCES = debug.cpp debug_gui.cpp debug_disasm.cpp debug_inc.h disasm_tables.h debug_win32.cpp -------------------------------------------------------------------------------- /src/debug/debug_inc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* Local Debug Function */ 20 | 21 | /* $Id: debug_inc.h,v 1.12 2009-05-27 09:15:41 qbix79 Exp $ */ 22 | 23 | #include 24 | #include "mem.h" 25 | 26 | #define PAIR_BLACK_BLUE 1 27 | #define PAIR_BYELLOW_BLACK 2 28 | #define PAIR_GREEN_BLACK 3 29 | #define PAIR_BLACK_GREY 4 30 | #define PAIR_GREY_RED 5 31 | 32 | 33 | void DBGUI_StartUp(void); 34 | 35 | struct DBGBlock { 36 | WINDOW * win_main; /* The Main Window */ 37 | WINDOW * win_reg; /* Register Window */ 38 | WINDOW * win_data; /* Data Output window */ 39 | WINDOW * win_code; /* Disassembly/Debug point Window */ 40 | WINDOW * win_var; /* Variable Window */ 41 | WINDOW * win_out; /* Text Output Window */ 42 | Bit32u active_win; /* Current active window */ 43 | Bit32u input_y; 44 | Bit32u global_mask; /* Current msgmask */ 45 | }; 46 | 47 | 48 | struct DASMLine { 49 | Bit32u pc; 50 | char dasm[80]; 51 | PhysPt ea; 52 | Bit16u easeg; 53 | Bit32u eaoff; 54 | }; 55 | 56 | extern DBGBlock dbg; 57 | 58 | /* Local Debug Stuff */ 59 | Bitu DasmI386(char* buffer, PhysPt pc, Bitu cur_ip, bool bit32); 60 | int DasmLastOperandSize(void); 61 | 62 | -------------------------------------------------------------------------------- /src/debug/debug_win32.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | #ifdef WIN32 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #ifndef min 26 | #define min(a,b) ((a)<(b)?(a):(b)) 27 | #endif 28 | 29 | /* 30 | Have to remember where i ripped this code sometime ago. 31 | 32 | */ 33 | static void ResizeConsole( HANDLE hConsole, SHORT xSize, SHORT ySize ) { 34 | CONSOLE_SCREEN_BUFFER_INFO csbi; // Hold Current Console Buffer Info 35 | BOOL bSuccess; 36 | SMALL_RECT srWindowRect; // Hold the New Console Size 37 | COORD coordScreen; 38 | 39 | bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi ); 40 | 41 | // Get the Largest Size we can size the Console Window to 42 | coordScreen = GetLargestConsoleWindowSize( hConsole ); 43 | 44 | // Define the New Console Window Size and Scroll Position 45 | srWindowRect.Right = (SHORT)(min(xSize, coordScreen.X) - 1); 46 | srWindowRect.Bottom = (SHORT)(min(ySize, coordScreen.Y) - 1); 47 | srWindowRect.Left = srWindowRect.Top = (SHORT)0; 48 | 49 | // Define the New Console Buffer Size 50 | coordScreen.X = xSize; 51 | coordScreen.Y = ySize; 52 | 53 | // If the Current Buffer is Larger than what we want, Resize the 54 | // Console Window First, then the Buffer 55 | if( (DWORD)csbi.dwSize.X * csbi.dwSize.Y > (DWORD) xSize * ySize) 56 | { 57 | bSuccess = SetConsoleWindowInfo( hConsole, TRUE, &srWindowRect ); 58 | bSuccess = SetConsoleScreenBufferSize( hConsole, coordScreen ); 59 | } 60 | 61 | // If the Current Buffer is Smaller than what we want, Resize the 62 | // Buffer First, then the Console Window 63 | if( (DWORD)csbi.dwSize.X * csbi.dwSize.Y < (DWORD) xSize * ySize ) 64 | { 65 | bSuccess = SetConsoleScreenBufferSize( hConsole, coordScreen ); 66 | bSuccess = SetConsoleWindowInfo( hConsole, TRUE, &srWindowRect ); 67 | } 68 | 69 | // If the Current Buffer *is* the Size we want, Don't do anything! 70 | return; 71 | } 72 | 73 | 74 | void WIN32_Console() { 75 | AllocConsole(); 76 | SetConsoleTitle("DOSBox Debugger"); 77 | ResizeConsole(GetStdHandle(STD_OUTPUT_HANDLE),80,50); 78 | } 79 | #endif 80 | -------------------------------------------------------------------------------- /src/dos/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I$(top_srcdir)/include 2 | 3 | noinst_LIBRARIES = libdos.a 4 | EXTRA_DIST = scsidefs.h wnaspi32.h dos_codepages.h dos_keyboard_layout_data.h 5 | libdos_a_SOURCES = dos.cpp dos_devices.cpp dos_execute.cpp dos_files.cpp dos_ioctl.cpp dos_memory.cpp \ 6 | dos_misc.cpp dos_classes.cpp dos_programs.cpp dos_tables.cpp \ 7 | drives.cpp drives.h drive_virtual.cpp drive_local.cpp drive_cache.cpp drive_fat.cpp \ 8 | drive_iso.cpp dev_con.h dos_mscdex.cpp dos_keyboard_layout.cpp \ 9 | cdrom.h cdrom.cpp cdrom_ioctl_win32.cpp cdrom_aspi_win32.cpp cdrom_ioctl_linux.cpp cdrom_image.cpp \ 10 | cdrom_ioctl_os2.cpp 11 | -------------------------------------------------------------------------------- /src/dos/cdrom_ioctl_linux.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | 20 | #include 21 | #include "cdrom.h" 22 | #include "support.h" 23 | 24 | #if defined (LINUX) 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | CDROM_Interface_Ioctl::CDROM_Interface_Ioctl(void) : CDROM_Interface_SDL() 33 | { 34 | strcpy(device_name, ""); 35 | } 36 | 37 | bool CDROM_Interface_Ioctl::GetUPC(unsigned char& attr, char* upc) 38 | { 39 | int cdrom_fd = open(device_name, O_RDONLY | O_NONBLOCK); 40 | if (cdrom_fd == -1) return false; 41 | 42 | struct cdrom_mcn cdrom_mcn; 43 | int ret = ioctl(cdrom_fd, CDROM_GET_MCN, &cdrom_mcn); 44 | 45 | close(cdrom_fd); 46 | 47 | if (ret > 0) { 48 | attr = 0; 49 | safe_strncpy(upc, (char*)cdrom_mcn.medium_catalog_number, 14); 50 | } 51 | 52 | return (ret > 0); 53 | } 54 | 55 | bool CDROM_Interface_Ioctl::ReadSectors(PhysPt buffer, bool raw, unsigned long sector, unsigned long num) 56 | { 57 | int cdrom_fd = open(device_name, O_RDONLY | O_NONBLOCK); 58 | if (cdrom_fd == -1) return false; 59 | 60 | Bits buflen = raw ? num * CD_FRAMESIZE_RAW : num * CD_FRAMESIZE; 61 | Bit8u* buf = new Bit8u[buflen]; 62 | int ret; 63 | 64 | if (raw) { 65 | struct cdrom_read cdrom_read; 66 | cdrom_read.cdread_lba = sector; 67 | cdrom_read.cdread_bufaddr = (char*)buf; 68 | cdrom_read.cdread_buflen = buflen; 69 | 70 | ret = ioctl(cdrom_fd, CDROMREADRAW, &cdrom_read); 71 | } else { 72 | ret = lseek(cdrom_fd, sector * CD_FRAMESIZE, SEEK_SET); 73 | if (ret >= 0) ret = read(cdrom_fd, buf, buflen); 74 | if (ret != buflen) ret = -1; 75 | } 76 | close(cdrom_fd); 77 | 78 | MEM_BlockWrite(buffer, buf, buflen); 79 | delete[] buf; 80 | 81 | return (ret > 0); 82 | } 83 | 84 | bool CDROM_Interface_Ioctl::SetDevice(char* path, int forceCD) 85 | { 86 | bool success = CDROM_Interface_SDL::SetDevice(path, forceCD); 87 | 88 | if (success) { 89 | const char* tmp = SDL_CDName(forceCD); 90 | if (tmp) safe_strncpy(device_name, tmp, 512); 91 | else success = false; 92 | } 93 | 94 | return success; 95 | } 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /src/dos/cdrom_ioctl_os2.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: cdrom_ioctl_os2.cpp,v 1.4 2009-05-27 09:15:41 qbix79 Exp $ */ 20 | 21 | #include 22 | #include "dosbox.h" 23 | #include "cdrom.h" 24 | 25 | #if defined (OS2) 26 | #define INCL_DOSFILEMGR 27 | #define INCL_DOSERRORS 28 | #define INCL_DOSDEVICES 29 | #define INCL_DOSDEVIOCTL 30 | #include "os2.h" 31 | 32 | // Ripped from linux/cdrom.h 33 | #define CD_FRAMESIZE_RAW 2352 34 | #define CD_FRAMESIZE 2048 35 | 36 | CDROM_Interface_Ioctl::CDROM_Interface_Ioctl(void) : CDROM_Interface_SDL(){ 37 | strcpy(device_name, ""); 38 | } 39 | 40 | bool CDROM_Interface_Ioctl::GetUPC(unsigned char& attr, char* upc){ 41 | HFILE cdrom_fd = 0; 42 | ULONG ulAction = 0; 43 | APIRET rc = DosOpen((unsigned char*)device_name, &cdrom_fd, &ulAction, 0L, FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS, 44 | OPEN_FLAGS_DASD | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, 0L); 45 | if (rc != NO_ERROR) { 46 | return false; 47 | } 48 | char data[50]; 49 | ULONG len = sizeof(data); 50 | char sig[] = {'C', 'D', '0', '1'}; 51 | ULONG sigsize = 4; 52 | rc = DosDevIOCtl(cdrom_fd, IOCTL_CDROMDISK, CDROMDISK_GETUPC, sig, sigsize, &sigsize, 53 | data, len, &len); 54 | if (rc != NO_ERROR) { 55 | return false; 56 | } 57 | rc = DosClose(cdrom_fd); 58 | return rc == NO_ERROR; 59 | } 60 | 61 | bool CDROM_Interface_Ioctl::ReadSectors(PhysPt buffer, bool raw, unsigned long sector, unsigned long num){ 62 | HFILE cdrom_fd = 0; 63 | ULONG ulAction = 0; 64 | APIRET rc = DosOpen((unsigned char*)device_name, &cdrom_fd, &ulAction, 0L, FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS, 65 | OPEN_FLAGS_DASD | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, 0L); 66 | if (rc != NO_ERROR) { 67 | return false; 68 | } 69 | 70 | Bitu buflen = raw ? num * CD_FRAMESIZE_RAW : num * CD_FRAMESIZE; 71 | Bit8u* buf = new Bit8u[buflen]; 72 | int ret = NO_ERROR; 73 | 74 | if (raw) { 75 | struct paramseek { 76 | UCHAR sig[4]; 77 | UCHAR mode; 78 | ULONG sec; 79 | 80 | paramseek(ULONG sector) 81 | { 82 | sig[0] = 'C'; sig[1] = 'D'; sig[2] = '0'; sig[3] = '1'; 83 | sec = sector; 84 | } 85 | } param_seek(sector); 86 | ULONG paramsize = sizeof (paramseek); 87 | rc = DosDevIOCtl(cdrom_fd, IOCTL_CDROMDISK, CDROMDISK_SEEK, ¶m_seek, paramsize, ¶msize, 88 | 0, 0, 0); 89 | if (rc != NO_ERROR) { 90 | return false; 91 | } 92 | 93 | struct paramread { 94 | UCHAR sig[4]; 95 | UCHAR mode; 96 | USHORT number; 97 | BYTE sec; 98 | BYTE reserved; 99 | BYTE interleave; 100 | 101 | paramread(USHORT num) 102 | { 103 | sig[0] = 'C'; sig[1] = 'D'; sig[2] = '0'; sig[3] = '1'; 104 | mode = 0; number = num; 105 | sec = interleave = 0; 106 | } 107 | } param_read(num); 108 | paramsize = sizeof (paramread); 109 | ULONG len = buflen; 110 | rc = DosDevIOCtl(cdrom_fd, IOCTL_CDROMDISK, CDROMDISK_READLONG, ¶m_read, paramsize, ¶msize, 111 | buf, len, &len); 112 | if (rc != NO_ERROR) { 113 | return false; 114 | } 115 | } else { 116 | ULONG pos = 0; 117 | rc = DosSetFilePtr(cdrom_fd, sector * CD_FRAMESIZE, FILE_BEGIN, &pos); 118 | if (rc != NO_ERROR) { 119 | return false; 120 | } 121 | ULONG read = 0; 122 | rc = DosRead(cdrom_fd, buf, buflen, &read); 123 | if (rc != NO_ERROR || read != buflen) { 124 | return false; 125 | } 126 | } 127 | rc = DosClose(cdrom_fd); 128 | MEM_BlockWrite(buffer, buf, buflen); 129 | delete[] buf; 130 | 131 | return (ret == NO_ERROR); 132 | } 133 | 134 | bool CDROM_Interface_Ioctl::SetDevice(char* path, int forceCD) { 135 | bool success = CDROM_Interface_SDL::SetDevice(path, forceCD); 136 | 137 | if (success) { 138 | char temp[3] = {0, 0, 0}; 139 | if (path[1] == ':') { 140 | temp[0] = path[0]; 141 | temp[1] = path[1]; 142 | temp[2] = 0; 143 | } 144 | strncpy(device_name, temp, 512); 145 | } else { 146 | strcpy(device_name, ""); 147 | success = false; 148 | } 149 | 150 | return success; 151 | } 152 | 153 | #endif 154 | -------------------------------------------------------------------------------- /src/dosbox.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KolibriOS/DOSBox/27a8b89892d90c301ad80173a3347ed3af55d750/src/dosbox.ico -------------------------------------------------------------------------------- /src/fpu/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I$(top_srcdir)/include 2 | 3 | noinst_LIBRARIES = libfpu.a 4 | libfpu_a_SOURCES = fpu.cpp fpu_instructions.h \ 5 | fpu_instructions_x86.h 6 | -------------------------------------------------------------------------------- /src/gui/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I$(top_srcdir)/include 2 | 3 | noinst_LIBRARIES = libgui.a 4 | libgui_a_SOURCES = sdlmain.cpp sdl_mapper.cpp dosbox_logo.h \ 5 | render.cpp render_scalers.cpp render_scalers.h \ 6 | render_templates.h render_loops.h render_simple.h \ 7 | render_templates_sai.h render_templates_hq.h \ 8 | render_templates_hq2x.h render_templates_hq3x.h \ 9 | midi.cpp midi_win32.h midi_oss.h midi_coreaudio.h midi_alsa.h \ 10 | midi_coremidi.h sdl_gui.cpp dosbox_splash.h 11 | 12 | -------------------------------------------------------------------------------- /src/gui/midi_coremidi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software; you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation; either version 2 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program; if not, write to the Free Software 14 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 15 | */ 16 | 17 | #include 18 | 19 | class MidiHandler_coremidi : public MidiHandler { 20 | private: 21 | MIDIPortRef m_port; 22 | MIDIClientRef m_client; 23 | MIDIEndpointRef m_endpoint; 24 | MIDIPacket* m_pCurPacket; 25 | public: 26 | MidiHandler_coremidi() {m_pCurPacket = 0;} 27 | const char * GetName(void) { return "coremidi"; } 28 | bool Open(const char * conf) { 29 | 30 | // Get the MIDIEndPoint 31 | m_endpoint = 0; 32 | OSStatus result; 33 | Bitu numDests = MIDIGetNumberOfDestinations(); 34 | Bitu destId = 0; 35 | if(conf && conf[0]) destId = atoi(conf); 36 | if (destId < numDests) 37 | { 38 | m_endpoint = MIDIGetDestination(destId); 39 | } 40 | 41 | // Create a MIDI client and port 42 | MIDIClientCreate(CFSTR("MyClient"), 0, 0, &m_client); 43 | 44 | if (!m_client) 45 | { 46 | LOG_MSG("MIDI:coremidi: No client created."); 47 | return false; 48 | } 49 | 50 | MIDIOutputPortCreate(m_client, CFSTR("MyOutPort"), &m_port); 51 | 52 | if (!m_port) 53 | { 54 | LOG_MSG("MIDI:coremidi: No port created."); 55 | return false; 56 | } 57 | 58 | 59 | return true; 60 | } 61 | 62 | void Close(void) { 63 | // Dispose the port 64 | MIDIPortDispose(m_port); 65 | 66 | // Dispose the client 67 | MIDIClientDispose(m_client); 68 | 69 | // Dispose the endpoint 70 | MIDIEndpointDispose(m_endpoint); 71 | } 72 | 73 | void PlayMsg(Bit8u * msg) { 74 | // Acquire a MIDIPacketList 75 | Byte packetBuf[128]; 76 | MIDIPacketList *packetList = (MIDIPacketList *)packetBuf; 77 | m_pCurPacket = MIDIPacketListInit(packetList); 78 | 79 | // Determine the length of msg 80 | Bitu len=MIDI_evt_len[*msg]; 81 | 82 | // Add msg to the MIDIPacketList 83 | MIDIPacketListAdd(packetList, (ByteCount)sizeof(packetBuf), m_pCurPacket, (MIDITimeStamp)0, len, msg); 84 | 85 | // Send the MIDIPacketList 86 | MIDISend(m_port,m_endpoint,packetList); 87 | } 88 | 89 | void PlaySysex(Bit8u * sysex, Bitu len) { 90 | // Acquire a MIDIPacketList 91 | Byte packetBuf[SYSEX_SIZE*4]; 92 | Bitu pos=0; 93 | MIDIPacketList *packetList = (MIDIPacketList *)packetBuf; 94 | m_pCurPacket = MIDIPacketListInit(packetList); 95 | 96 | // Add msg to the MIDIPacketList 97 | MIDIPacketListAdd(packetList, (ByteCount)sizeof(packetBuf), m_pCurPacket, (MIDITimeStamp)0, len, sysex); 98 | 99 | // Send the MIDIPacketList 100 | MIDISend(m_port,m_endpoint,packetList); 101 | } 102 | }; 103 | 104 | MidiHandler_coremidi Midi_coremidi; 105 | 106 | -------------------------------------------------------------------------------- /src/gui/midi_oss.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | #include 20 | #define SEQ_MIDIPUTC 5 21 | 22 | class MidiHandler_oss: public MidiHandler { 23 | private: 24 | int device; 25 | Bit8u device_num; 26 | bool isOpen; 27 | public: 28 | MidiHandler_oss() : MidiHandler(),isOpen(false) {}; 29 | const char * GetName(void) { return "oss";}; 30 | bool Open(const char * conf) { 31 | char devname[512]; 32 | if (conf && conf[0]) safe_strncpy(devname,conf,512); 33 | else strcpy(devname,"/dev/sequencer"); 34 | char * devfind=(strrchr(devname,',')); 35 | if (devfind) { 36 | *devfind++=0; 37 | device_num=atoi(devfind); 38 | } else device_num=0; 39 | if (isOpen) return false; 40 | device=open(devname, O_WRONLY, 0); 41 | if (device<0) return false; 42 | return true; 43 | }; 44 | void Close(void) { 45 | if (!isOpen) return; 46 | if (device>0) close(device); 47 | }; 48 | void PlayMsg(Bit8u * msg) { 49 | Bit8u buf[128];Bitu pos=0; 50 | Bitu len=MIDI_evt_len[*msg]; 51 | for (;len>0;len--) { 52 | buf[pos++] = SEQ_MIDIPUTC; 53 | buf[pos++] = *msg; 54 | buf[pos++] = device_num; 55 | buf[pos++] = 0; 56 | msg++; 57 | } 58 | write(device,buf,pos); 59 | }; 60 | void PlaySysex(Bit8u * sysex,Bitu len) { 61 | Bit8u buf[SYSEX_SIZE*4];Bitu pos=0; 62 | for (;len>0;len--) { 63 | buf[pos++] = SEQ_MIDIPUTC; 64 | buf[pos++] = *sysex++; 65 | buf[pos++] = device_num; 66 | buf[pos++] = 0; 67 | } 68 | write(device,buf,pos); 69 | } 70 | }; 71 | 72 | MidiHandler_oss Midi_oss; 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/gui/midi_win32.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: midi_win32.h,v 1.16 2009-05-27 09:15:41 qbix79 Exp $ */ 20 | 21 | #ifndef WIN32_LEAN_AND_MEAN 22 | #define WIN32_LEAN_AND_MEAN 23 | #endif 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | class MidiHandler_win32: public MidiHandler { 30 | private: 31 | HMIDIOUT m_out; 32 | MIDIHDR m_hdr; 33 | HANDLE m_event; 34 | bool isOpen; 35 | public: 36 | MidiHandler_win32() : MidiHandler(),isOpen(false) {}; 37 | const char * GetName(void) { return "win32";}; 38 | bool Open(const char * conf) { 39 | if (isOpen) return false; 40 | m_event = CreateEvent (NULL, true, true, NULL); 41 | MMRESULT res = MMSYSERR_NOERROR; 42 | if(conf && *conf) { 43 | std::string strconf(conf); 44 | std::istringstream configmidi(strconf); 45 | unsigned int nummer = midiOutGetNumDevs(); 46 | configmidi >> nummer; 47 | if(nummer < midiOutGetNumDevs()){ 48 | MIDIOUTCAPS mididev; 49 | midiOutGetDevCaps(nummer, &mididev, sizeof(MIDIOUTCAPS)); 50 | LOG_MSG("MIDI:win32 selected %s",mididev.szPname); 51 | res = midiOutOpen(&m_out, nummer, (DWORD)m_event, 0, CALLBACK_EVENT); 52 | } 53 | } else { 54 | res = midiOutOpen(&m_out, MIDI_MAPPER, (DWORD)m_event, 0, CALLBACK_EVENT); 55 | } 56 | if (res != MMSYSERR_NOERROR) return false; 57 | isOpen=true; 58 | return true; 59 | }; 60 | 61 | void Close(void) { 62 | if (!isOpen) return; 63 | isOpen=false; 64 | midiOutClose(m_out); 65 | CloseHandle (m_event); 66 | }; 67 | void PlayMsg(Bit8u * msg) { 68 | midiOutShortMsg(m_out, *(Bit32u*)msg); 69 | }; 70 | void PlaySysex(Bit8u * sysex,Bitu len) { 71 | if (WaitForSingleObject (m_event, 2000) == WAIT_TIMEOUT) { 72 | LOG(LOG_MISC,LOG_ERROR)("Can't send midi message"); 73 | return; 74 | } 75 | midiOutUnprepareHeader (m_out, &m_hdr, sizeof (m_hdr)); 76 | 77 | m_hdr.lpData = (char *) sysex; 78 | m_hdr.dwBufferLength = len ; 79 | m_hdr.dwBytesRecorded = len ; 80 | m_hdr.dwUser = 0; 81 | 82 | MMRESULT result = midiOutPrepareHeader (m_out, &m_hdr, sizeof (m_hdr)); 83 | if (result != MMSYSERR_NOERROR) return; 84 | ResetEvent (m_event); 85 | result = midiOutLongMsg (m_out,&m_hdr,sizeof(m_hdr)); 86 | if (result != MMSYSERR_NOERROR) { 87 | SetEvent (m_event); 88 | return; 89 | } 90 | } 91 | }; 92 | 93 | MidiHandler_win32 Midi_win32; 94 | 95 | 96 | -------------------------------------------------------------------------------- /src/gui/render_loops.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | #if defined (SCALERLINEAR) 20 | static void conc3d(SCALERNAME,SBPP,L)(void) { 21 | #else 22 | static void conc3d(SCALERNAME,SBPP,R)(void) { 23 | #endif 24 | //Skip the first one for multiline input scalers 25 | if (!render.scale.outLine) { 26 | render.scale.outLine++; 27 | return; 28 | } 29 | lastagain: 30 | if (!CC[render.scale.outLine][0]) { 31 | #if defined(SCALERLINEAR) 32 | Bitu scaleLines = SCALERHEIGHT; 33 | #else 34 | Bitu scaleLines = Scaler_Aspect[ render.scale.outLine ]; 35 | #endif 36 | ScalerAddLines( 0, scaleLines ); 37 | if (++render.scale.outLine == render.scale.inHeight) 38 | goto lastagain; 39 | return; 40 | } 41 | /* Clear the complete line marker */ 42 | CC[render.scale.outLine][0] = 0; 43 | const PTYPE * fc = &FC[render.scale.outLine][1]; 44 | PTYPE * line0=(PTYPE *)(render.scale.outWrite); 45 | Bit8u * changed = &CC[render.scale.outLine][1]; 46 | Bitu b; 47 | for (b=0;b 1) 49 | PTYPE * line1; 50 | #endif 51 | #if (SCALERHEIGHT > 2) 52 | PTYPE * line2; 53 | #endif 54 | /* Clear this block being dirty marker */ 55 | const Bitu changeType = changed[b]; 56 | changed[b] = 0; 57 | switch (changeType) { 58 | case 0: 59 | line0 += SCALERWIDTH * SCALER_BLOCKSIZE; 60 | fc += SCALER_BLOCKSIZE; 61 | continue; 62 | case SCALE_LEFT: 63 | #if (SCALERHEIGHT > 1) 64 | line1 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch); 65 | #endif 66 | #if (SCALERHEIGHT > 2) 67 | line2 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 2); 68 | #endif 69 | SCALERFUNC; 70 | line0 += SCALERWIDTH * SCALER_BLOCKSIZE; 71 | fc += SCALER_BLOCKSIZE; 72 | break; 73 | case SCALE_LEFT | SCALE_RIGHT: 74 | #if (SCALERHEIGHT > 1) 75 | line1 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch); 76 | #endif 77 | #if (SCALERHEIGHT > 2) 78 | line2 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 2); 79 | #endif 80 | SCALERFUNC; 81 | case SCALE_RIGHT: 82 | #if (SCALERHEIGHT > 1) 83 | line1 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch); 84 | #endif 85 | #if (SCALERHEIGHT > 2) 86 | line2 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 2); 87 | #endif 88 | line0 += SCALERWIDTH * (SCALER_BLOCKSIZE -1); 89 | #if (SCALERHEIGHT > 1) 90 | line1 += SCALERWIDTH * (SCALER_BLOCKSIZE -1); 91 | #endif 92 | #if (SCALERHEIGHT > 2) 93 | line2 += SCALERWIDTH * (SCALER_BLOCKSIZE -1); 94 | #endif 95 | fc += SCALER_BLOCKSIZE -1; 96 | SCALERFUNC; 97 | line0 += SCALERWIDTH; 98 | fc++; 99 | break; 100 | default: 101 | #if defined(SCALERLINEAR) 102 | #if (SCALERHEIGHT > 1) 103 | line1 = WC[0]; 104 | #endif 105 | #if (SCALERHEIGHT > 2) 106 | line2 = WC[1]; 107 | #endif 108 | #else 109 | #if (SCALERHEIGHT > 1) 110 | line1 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch); 111 | #endif 112 | #if (SCALERHEIGHT > 2) 113 | line2 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 2); 114 | #endif 115 | #endif //defined(SCALERLINEAR) 116 | for (Bitu i = 0; i 1) 120 | line1 += SCALERWIDTH; 121 | #endif 122 | #if (SCALERHEIGHT > 2) 123 | line2 += SCALERWIDTH; 124 | #endif 125 | fc++; 126 | } 127 | #if defined(SCALERLINEAR) 128 | #if (SCALERHEIGHT > 1) 129 | BituMove((Bit8u*)(&line0[-SCALER_BLOCKSIZE*SCALERWIDTH])+render.scale.outPitch ,WC[0], SCALER_BLOCKSIZE *SCALERWIDTH*PSIZE); 130 | #endif 131 | #if (SCALERHEIGHT > 2) 132 | BituMove((Bit8u*)(&line0[-SCALER_BLOCKSIZE*SCALERWIDTH])+render.scale.outPitch*2,WC[1], SCALER_BLOCKSIZE *SCALERWIDTH*PSIZE); 133 | #endif 134 | #endif //defined(SCALERLINEAR) 135 | break; 136 | } 137 | } 138 | #if defined(SCALERLINEAR) 139 | Bitu scaleLines = SCALERHEIGHT; 140 | #else 141 | Bitu scaleLines = Scaler_Aspect[ render.scale.outLine ]; 142 | if ( ((Bits)(scaleLines - SCALERHEIGHT)) > 0 ) { 143 | BituMove( render.scale.outWrite + render.scale.outPitch * SCALERHEIGHT, 144 | render.scale.outWrite + render.scale.outPitch * (SCALERHEIGHT-1), 145 | render.src.width * SCALERWIDTH * PSIZE); 146 | } 147 | #endif 148 | ScalerAddLines( 1, scaleLines ); 149 | if (++render.scale.outLine == render.scale.inHeight) 150 | goto lastagain; 151 | } 152 | 153 | #if !defined(SCALERLINEAR) 154 | #define SCALERLINEAR 1 155 | #include "render_loops.h" 156 | #undef SCALERLINEAR 157 | #endif 158 | -------------------------------------------------------------------------------- /src/gui/render_scalers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | #ifndef _RENDER_SCALERS_H 20 | #define _RENDER_SCALERS_H 21 | 22 | //#include "render.h" 23 | #include "video.h" 24 | #if RENDER_USE_ADVANCED_SCALERS>0 25 | #define SCALER_MAXWIDTH 1280 26 | #define SCALER_MAXHEIGHT 1024 27 | #else 28 | // reduced to save some memory 29 | #define SCALER_MAXWIDTH 800 30 | #define SCALER_MAXHEIGHT 600 31 | #endif 32 | 33 | #if RENDER_USE_ADVANCED_SCALERS>1 34 | #define SCALER_COMPLEXWIDTH 800 35 | #define SCALER_COMPLEXHEIGHT 600 36 | #endif 37 | 38 | #define SCALER_BLOCKSIZE 16 39 | 40 | typedef enum { 41 | scalerMode8, scalerMode15, scalerMode16, scalerMode32 42 | } scalerMode_t; 43 | 44 | typedef enum scalerOperation { 45 | scalerOpNormal, 46 | #if RENDER_USE_ADVANCED_SCALERS>2 47 | scalerOpAdvMame, 48 | scalerOpAdvInterp, 49 | scalerOpHQ, 50 | scalerOpSaI, 51 | scalerOpSuperSaI, 52 | scalerOpSuperEagle, 53 | #endif 54 | #if RENDER_USE_ADVANCED_SCALERS>0 55 | scalerOpTV, 56 | scalerOpRGB, 57 | scalerOpScan, 58 | #endif 59 | scalerLast 60 | } scalerOperation_t; 61 | 62 | typedef void (*ScalerLineHandler_t)(const void *src); 63 | typedef void (*ScalerComplexHandler_t)(void); 64 | 65 | extern Bit8u Scaler_Aspect[]; 66 | extern Bit8u diff_table[]; 67 | extern Bitu Scaler_ChangedLineIndex; 68 | extern Bit16u Scaler_ChangedLines[]; 69 | #if RENDER_USE_ADVANCED_SCALERS>1 70 | /* Not entirely happy about those +2's since they make a non power of 2, with muls instead of shift */ 71 | typedef Bit8u scalerChangeCache_t [SCALER_COMPLEXHEIGHT][SCALER_COMPLEXWIDTH / SCALER_BLOCKSIZE] ; 72 | typedef union { 73 | Bit32u b32 [SCALER_COMPLEXHEIGHT] [SCALER_COMPLEXWIDTH]; 74 | Bit16u b16 [SCALER_COMPLEXHEIGHT] [SCALER_COMPLEXWIDTH]; 75 | Bit8u b8 [SCALER_COMPLEXHEIGHT] [SCALER_COMPLEXWIDTH]; 76 | } scalerFrameCache_t; 77 | #endif 78 | typedef union { 79 | Bit32u b32 [SCALER_MAXHEIGHT] [SCALER_MAXWIDTH]; 80 | Bit16u b16 [SCALER_MAXHEIGHT] [SCALER_MAXWIDTH]; 81 | Bit8u b8 [SCALER_MAXHEIGHT] [SCALER_MAXWIDTH]; 82 | } scalerSourceCache_t; 83 | extern scalerSourceCache_t scalerSourceCache; 84 | #if RENDER_USE_ADVANCED_SCALERS>1 85 | extern scalerChangeCache_t scalerChangeCache; 86 | #endif 87 | typedef ScalerLineHandler_t ScalerLineBlock_t[5][4]; 88 | 89 | typedef struct { 90 | const char *name; 91 | Bitu gfxFlags; 92 | Bitu xscale,yscale; 93 | ScalerComplexHandler_t Linear[4]; 94 | ScalerComplexHandler_t Random[4]; 95 | } ScalerComplexBlock_t; 96 | 97 | typedef struct { 98 | const char *name; 99 | Bitu gfxFlags; 100 | Bitu xscale,yscale; 101 | ScalerLineBlock_t Linear; 102 | ScalerLineBlock_t Random; 103 | } ScalerSimpleBlock_t; 104 | 105 | 106 | #define SCALE_LEFT 0x1 107 | #define SCALE_RIGHT 0x2 108 | #define SCALE_FULL 0x4 109 | 110 | /* Simple scalers */ 111 | extern ScalerSimpleBlock_t ScaleNormal1x; 112 | extern ScalerSimpleBlock_t ScaleNormalDw; 113 | extern ScalerSimpleBlock_t ScaleNormalDh; 114 | extern ScalerSimpleBlock_t ScaleNormal2x; 115 | extern ScalerSimpleBlock_t ScaleNormal3x; 116 | #if RENDER_USE_ADVANCED_SCALERS>0 117 | extern ScalerSimpleBlock_t ScaleTV2x; 118 | extern ScalerSimpleBlock_t ScaleTV3x; 119 | extern ScalerSimpleBlock_t ScaleRGB2x; 120 | extern ScalerSimpleBlock_t ScaleRGB3x; 121 | extern ScalerSimpleBlock_t ScaleScan2x; 122 | extern ScalerSimpleBlock_t ScaleScan3x; 123 | #endif 124 | /* Complex scalers */ 125 | #if RENDER_USE_ADVANCED_SCALERS>2 126 | extern ScalerComplexBlock_t ScaleHQ2x; 127 | extern ScalerComplexBlock_t ScaleHQ3x; 128 | extern ScalerComplexBlock_t Scale2xSaI; 129 | extern ScalerComplexBlock_t ScaleSuper2xSaI; 130 | extern ScalerComplexBlock_t ScaleSuperEagle; 131 | extern ScalerComplexBlock_t ScaleAdvMame2x; 132 | extern ScalerComplexBlock_t ScaleAdvMame3x; 133 | extern ScalerComplexBlock_t ScaleAdvInterp2x; 134 | extern ScalerComplexBlock_t ScaleAdvInterp3x; 135 | #endif 136 | #if RENDER_USE_ADVANCED_SCALERS>1 137 | extern ScalerLineBlock_t ScalerCache; 138 | #endif 139 | #endif 140 | -------------------------------------------------------------------------------- /src/gui/render_simple.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: render_simple.h,v 1.7 2009-05-27 09:15:41 qbix79 Exp $ */ 20 | 21 | #if defined (SCALERLINEAR) 22 | static void conc4d(SCALERNAME,SBPP,DBPP,L)(const void *s) { 23 | #else 24 | static void conc4d(SCALERNAME,SBPP,DBPP,R)(const void *s) { 25 | #endif 26 | #ifdef RENDER_NULL_INPUT 27 | if (!s) { 28 | render.scale.cacheRead += render.scale.cachePitch; 29 | #if defined(SCALERLINEAR) 30 | Bitu skipLines = SCALERHEIGHT; 31 | #else 32 | Bitu skipLines = Scaler_Aspect[ render.scale.outLine++ ]; 33 | #endif 34 | ScalerAddLines( 0, skipLines ); 35 | return; 36 | } 37 | #endif 38 | /* Clear the complete line marker */ 39 | Bitu hadChange = 0; 40 | const SRCTYPE *src = (SRCTYPE*)s; 41 | SRCTYPE *cache = (SRCTYPE*)(render.scale.cacheRead); 42 | render.scale.cacheRead += render.scale.cachePitch; 43 | PTYPE * line0=(PTYPE *)(render.scale.outWrite); 44 | #if (SBPP == 9) 45 | for (Bits x=render.src.width;x>0;) { 46 | if (*(Bit32u const*)src == *(Bit32u*)cache && !( 47 | render.pal.modified[src[0]] | 48 | render.pal.modified[src[1]] | 49 | render.pal.modified[src[2]] | 50 | render.pal.modified[src[3]] )) { 51 | x-=4; 52 | src+=4; 53 | cache+=4; 54 | line0+=4*SCALERWIDTH; 55 | #else 56 | for (Bits x=render.src.width;x>0;) { 57 | if (*(Bitu const*)src == *(Bitu*)cache) { 58 | x-=(sizeof(Bitu)/sizeof(SRCTYPE)); 59 | src+=(sizeof(Bitu)/sizeof(SRCTYPE)); 60 | cache+=(sizeof(Bitu)/sizeof(SRCTYPE)); 61 | line0+=(sizeof(Bitu)/sizeof(SRCTYPE))*SCALERWIDTH; 62 | #endif 63 | } else { 64 | #if defined(SCALERLINEAR) 65 | #if (SCALERHEIGHT > 1) 66 | PTYPE *line1 = WC[0]; 67 | #endif 68 | #if (SCALERHEIGHT > 2) 69 | PTYPE *line2 = WC[1]; 70 | #endif 71 | #else 72 | #if (SCALERHEIGHT > 1) 73 | PTYPE *line1 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch); 74 | #endif 75 | #if (SCALERHEIGHT > 2) 76 | PTYPE *line2 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 2); 77 | #endif 78 | #endif //defined(SCALERLINEAR) 79 | hadChange = 1; 80 | for (Bitu i = x > 32 ? 32 : x;i>0;i--,x--) { 81 | const SRCTYPE S = *src; 82 | *cache = S; 83 | src++;cache++; 84 | const PTYPE P = PMAKE(S); 85 | SCALERFUNC; 86 | line0 += SCALERWIDTH; 87 | #if (SCALERHEIGHT > 1) 88 | line1 += SCALERWIDTH; 89 | #endif 90 | #if (SCALERHEIGHT > 2) 91 | line2 += SCALERWIDTH; 92 | #endif 93 | } 94 | #if defined(SCALERLINEAR) 95 | #if (SCALERHEIGHT > 1) 96 | Bitu copyLen = (Bitu)((Bit8u*)line1 - (Bit8u*)WC[0]); 97 | BituMove(((Bit8u*)line0)-copyLen+render.scale.outPitch ,WC[0], copyLen ); 98 | #endif 99 | #if (SCALERHEIGHT > 2) 100 | BituMove(((Bit8u*)line0)-copyLen+render.scale.outPitch*2,WC[1], copyLen ); 101 | #endif 102 | #endif //defined(SCALERLINEAR) 103 | } 104 | } 105 | #if defined(SCALERLINEAR) 106 | Bitu scaleLines = SCALERHEIGHT; 107 | #else 108 | Bitu scaleLines = Scaler_Aspect[ render.scale.outLine++ ]; 109 | if ( scaleLines - SCALERHEIGHT && hadChange ) { 110 | BituMove( render.scale.outWrite + render.scale.outPitch * SCALERHEIGHT, 111 | render.scale.outWrite + render.scale.outPitch * (SCALERHEIGHT-1), 112 | render.src.width * SCALERWIDTH * PSIZE); 113 | } 114 | #endif 115 | ScalerAddLines( hadChange, scaleLines ); 116 | } 117 | 118 | #if !defined(SCALERLINEAR) 119 | #define SCALERLINEAR 1 120 | #include "render_simple.h" 121 | #undef SCALERLINEAR 122 | #endif 123 | -------------------------------------------------------------------------------- /src/gui/render_templates_hq.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* 20 | * The HQ3x high quality 3x graphics filter. 21 | * Original author Maxim Stepin (see http://www.hiend3d.com/hq3x.html). 22 | * Adapted for DOSBox from ScummVM and HiEnd3D code by Kronuz. 23 | */ 24 | 25 | #include 26 | 27 | #ifndef RENDER_TEMPLATES_HQNX_TABLE_H 28 | #define RENDER_TEMPLATES_HQNX_TABLE_H 29 | 30 | static Bit32u *_RGBtoYUV = 0; 31 | static inline bool diffYUV(Bit32u yuv1, Bit32u yuv2) 32 | { 33 | static const Bit32u Ymask = 0x00FF0000; 34 | static const Bit32u Umask = 0x0000FF00; 35 | static const Bit32u Vmask = 0x000000FF; 36 | static const Bit32u trY = 0x00300000; 37 | static const Bit32u trU = 0x00000700; 38 | static const Bit32u trV = 0x00000006; 39 | 40 | Bit32u diff; 41 | Bit32u mask; 42 | 43 | diff = ((yuv1 & Ymask) - (yuv2 & Ymask)); 44 | mask = ((Bit32s)diff) >> 31; // ~1/-1 if value < 0, 0 otherwise 45 | diff = (diff ^ mask) - mask; //-1: ~value + 1; 0: value 46 | if (diff > trY) return true; 47 | 48 | diff = ((yuv1 & Umask) - (yuv2 & Umask)); 49 | mask = ((Bit32s)diff)>> 31; // ~1/-1 if value < 0, 0 otherwise 50 | diff = (diff ^ mask) - mask; //-1: ~value + 1; 0: value 51 | if (diff > trU) return true; 52 | 53 | diff = ((yuv1 & Vmask) - (yuv2 & Vmask)); 54 | mask = ((Bit32s)diff) >> 31; // ~1/-1 if value < 0, 0 otherwise 55 | diff = (diff ^ mask) - mask; //-1: ~value + 1; 0: value 56 | if (diff > trV) return true; 57 | 58 | return false; 59 | } 60 | 61 | #endif 62 | 63 | static inline void conc2d(InitLUTs,SBPP)(void) 64 | { 65 | int r, g, b; 66 | int Y, u, v; 67 | 68 | _RGBtoYUV = (Bit32u *)malloc(65536 * sizeof(Bit32u)); 69 | 70 | for (int color = 0; color < 65536; ++color) { 71 | #if SBPP == 32 72 | r = ((color & 0xF800) >> 11) << (8 - 5); 73 | g = ((color & 0x07E0) >> 5) << (8 - 6); 74 | b = ((color & 0x001F) >> 0) << (8 - 5); 75 | #else 76 | r = ((color & redMask) >> redShift) << (8 - redBits); 77 | g = ((color & greenMask) >> greenShift) << (8 - greenBits); 78 | b = ((color & blueMask) >> blueShift) << (8 - blueBits); 79 | #endif 80 | Y = (r + g + b) >> 2; 81 | u = 128 + ((r - b) >> 2); 82 | v = 128 + ((-r + 2 * g - b) >> 3); 83 | _RGBtoYUV[color] = (Y << 16) | (u << 8) | v; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/hardware/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I$(top_srcdir)/include 2 | 3 | SUBDIRS = serialport mame 4 | 5 | EXTRA_DIST = opl.cpp opl.h adlib.h dbopl.h 6 | 7 | noinst_LIBRARIES = libhardware.a 8 | 9 | libhardware_a_SOURCES = adlib.cpp dma.cpp gameblaster.cpp hardware.cpp iohandler.cpp joystick.cpp keyboard.cpp \ 10 | memory.cpp mixer.cpp pcspeaker.cpp pic.cpp sblaster.cpp tandy_sound.cpp timer.cpp \ 11 | vga.cpp vga_attr.cpp vga_crtc.cpp vga_dac.cpp vga_draw.cpp vga_gfx.cpp vga_other.cpp \ 12 | vga_memory.cpp vga_misc.cpp vga_seq.cpp vga_xga.cpp vga_s3.cpp vga_tseng.cpp vga_paradise.cpp \ 13 | cmos.cpp disney.cpp gus.cpp mpu401.cpp ipx.cpp ipxserver.cpp dbopl.cpp 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/hardware/adlib.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: adlib.h,v 1.5 2009-04-28 21:45:43 c2woody Exp $ */ 20 | 21 | #ifndef DOSBOX_ADLIB_H 22 | #define DOSBOX_ADLIB_H 23 | 24 | #include "dosbox.h" 25 | #include "mixer.h" 26 | #include "inout.h" 27 | #include "setup.h" 28 | #include "pic.h" 29 | #include "hardware.h" 30 | 31 | 32 | namespace Adlib { 33 | 34 | struct Timer { 35 | double start; 36 | double delay; 37 | bool enabled, overflow, masked; 38 | Bit8u counter; 39 | Timer() { 40 | masked = false; 41 | overflow = false; 42 | enabled = false; 43 | counter = 0; 44 | delay = 0; 45 | } 46 | //Call update before making any further changes 47 | void Update( double time ) { 48 | if ( !enabled || !delay ) 49 | return; 50 | double deltaStart = time - start; 51 | //Only set the overflow flag when not masked 52 | if ( deltaStart >= 0 && !masked ) { 53 | overflow = 1; 54 | } 55 | } 56 | //On a reset make sure the start is in sync with the next cycle 57 | void Reset(const double& time ) { 58 | overflow = false; 59 | if ( !delay || !enabled ) 60 | return; 61 | double delta = (time - start); 62 | double rem = fmod( delta, delay ); 63 | double next = delay - rem; 64 | start = time + next; 65 | } 66 | void Stop( ) { 67 | enabled = false; 68 | } 69 | void Start( const double& time, Bits scale ) { 70 | //Don't enable again 71 | if ( enabled ) { 72 | return; 73 | } 74 | enabled = true; 75 | delay = 0.001 * (256 - counter ) * scale; 76 | start = time + delay; 77 | } 78 | 79 | }; 80 | 81 | struct Chip { 82 | //Last selected register 83 | Timer timer[2]; 84 | //Check for it being a write to the timer 85 | bool Write( Bit32u addr, Bit8u val ); 86 | //Read the current timer state, will use current double 87 | Bit8u Read( ); 88 | }; 89 | 90 | //The type of handler this is 91 | typedef enum { 92 | MODE_OPL2, 93 | MODE_DUALOPL2, 94 | MODE_OPL3 95 | } Mode; 96 | 97 | class Handler { 98 | public: 99 | //Write an address to a chip, returns the address the chip sets 100 | virtual Bit32u WriteAddr( Bit32u port, Bit8u val ) = 0; 101 | //Write to a specific register in the chip 102 | virtual void WriteReg( Bit32u addr, Bit8u val ) = 0; 103 | //Generate a certain amount of samples 104 | virtual void Generate( MixerChannel* chan, Bitu samples ) = 0; 105 | //Initialize at a specific sample rate and mode 106 | virtual void Init( Bitu rate ) = 0; 107 | virtual ~Handler() { 108 | } 109 | }; 110 | 111 | //The cache for 2 chips or an opl3 112 | typedef Bit8u RegisterCache[512]; 113 | 114 | //Internal class used for dro capturing 115 | class Capture; 116 | 117 | class Module: public Module_base { 118 | IO_ReadHandleObject ReadHandler[3]; 119 | IO_WriteHandleObject WriteHandler[3]; 120 | MixerObject mixerObject; 121 | 122 | //Mode we're running in 123 | Mode mode; 124 | //Last selected address in the chip for the different modes 125 | union { 126 | Bit32u normal; 127 | Bit8u dual[2]; 128 | } reg; 129 | void CacheWrite( Bit32u reg, Bit8u val ); 130 | void DualWrite( Bit8u index, Bit8u reg, Bit8u val ); 131 | public: 132 | static OPL_Mode oplmode; 133 | MixerChannel* mixerChan; 134 | Bit32u lastUsed; //Ticks when adlib was last used to turn of mixing after a few second 135 | 136 | Handler* handler; //Handler that will generate the sound 137 | RegisterCache cache; 138 | Capture* capture; 139 | Chip chip[2]; 140 | 141 | //Handle port writes 142 | void PortWrite( Bitu port, Bitu val, Bitu iolen ); 143 | Bitu PortRead( Bitu port, Bitu iolen ); 144 | void Init( Mode m ); 145 | 146 | Module( Section* configuration); 147 | ~Module(); 148 | }; 149 | 150 | 151 | } //Adlib namespace 152 | 153 | #endif 154 | -------------------------------------------------------------------------------- /src/hardware/gameblaster.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2018 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | #include "dosbox.h" 20 | #include "inout.h" 21 | #include "mixer.h" 22 | #include "mem.h" 23 | #include "hardware.h" 24 | #include "setup.h" 25 | #include "support.h" 26 | #include "pic.h" 27 | #include 28 | #include 29 | 30 | #include "mame/emu.h" 31 | #include "mame/saa1099.h" 32 | 33 | #define MASTER_CLOCK 7159090 34 | 35 | //My mixer channel 36 | static MixerChannel * cms_chan; 37 | //Timer to disable the channel after a while 38 | static Bit32u lastWriteTicks; 39 | static Bit32u cmsBase; 40 | static saa1099_device* device[2]; 41 | 42 | static void write_cms(Bitu port, Bitu val, Bitu /* iolen */) { 43 | if(cms_chan && (!cms_chan->enabled)) cms_chan->Enable(true); 44 | lastWriteTicks = PIC_Ticks; 45 | switch ( port - cmsBase ) { 46 | case 1: 47 | device[0]->control_w(0, 0, val); 48 | break; 49 | case 0: 50 | device[0]->data_w(0, 0, val); 51 | break; 52 | case 3: 53 | device[1]->control_w(0, 0, val); 54 | break; 55 | case 2: 56 | device[1]->data_w(0, 0, val); 57 | break; 58 | } 59 | } 60 | 61 | static void CMS_CallBack(Bitu len) { 62 | enum { 63 | BUFFER_SIZE = 2048 64 | }; 65 | 66 | if ( len > BUFFER_SIZE ) 67 | return; 68 | 69 | if ( cms_chan ) { 70 | 71 | //Have there been 10 seconds of no commands, disable channel 72 | if ( lastWriteTicks + 10000 < PIC_Ticks ) { 73 | cms_chan->Enable( false ); 74 | return; 75 | } 76 | Bit32s result[BUFFER_SIZE][2]; 77 | Bit16s work[2][BUFFER_SIZE]; 78 | Bit16s* buffers[2] = { work[0], work[1] }; 79 | device_sound_interface::sound_stream stream; 80 | device[0]->sound_stream_update(stream, 0, buffers, len); 81 | for (Bitu i = 0; i < len; i++) { 82 | result[i][0] = work[0][i]; 83 | result[i][1] = work[1][i]; 84 | } 85 | device[1]->sound_stream_update(stream, 0, buffers, len); 86 | for (Bitu i = 0; i < len; i++) { 87 | result[i][0] += work[0][i]; 88 | result[i][1] += work[1][i]; 89 | } 90 | cms_chan->AddSamples_s32( len, result[0] ); 91 | } 92 | } 93 | 94 | // The Gameblaster detection 95 | static Bit8u cms_detect_register = 0xff; 96 | 97 | static void write_cms_detect(Bitu port, Bitu val, Bitu /* iolen */) { 98 | switch ( port - cmsBase ) { 99 | case 0x6: 100 | case 0x7: 101 | cms_detect_register = val; 102 | break; 103 | } 104 | } 105 | 106 | static Bitu read_cms_detect(Bitu port, Bitu /* iolen */) { 107 | Bit8u retval = 0xff; 108 | switch ( port - cmsBase ) { 109 | case 0x4: 110 | retval = 0x7f; 111 | break; 112 | case 0xa: 113 | case 0xb: 114 | retval = cms_detect_register; 115 | break; 116 | } 117 | return retval; 118 | } 119 | 120 | 121 | class CMS:public Module_base { 122 | private: 123 | IO_WriteHandleObject WriteHandler; 124 | IO_WriteHandleObject DetWriteHandler; 125 | IO_ReadHandleObject DetReadHandler; 126 | MixerObject MixerChan; 127 | 128 | public: 129 | CMS(Section* configuration):Module_base(configuration) { 130 | Section_prop * section = static_cast(configuration); 131 | Bitu sampleRate = section->Get_int( "oplrate" ); 132 | cmsBase = section->Get_hex("sbbase"); 133 | WriteHandler.Install( cmsBase, write_cms, IO_MB, 4 ); 134 | 135 | // A standalone Gameblaster has a magic chip on it which is 136 | // sometimes used for detection. 137 | const char * sbtype=section->Get_string("sbtype"); 138 | if (!strcasecmp(sbtype,"gb")) { 139 | DetWriteHandler.Install( cmsBase + 4, write_cms_detect, IO_MB, 12 ); 140 | DetReadHandler.Install(cmsBase,read_cms_detect,IO_MB,16); 141 | } 142 | 143 | /* Register the Mixer CallBack */ 144 | cms_chan = MixerChan.Install(CMS_CallBack,sampleRate,"CMS"); 145 | 146 | lastWriteTicks = PIC_Ticks; 147 | 148 | Bit32u freq = 7159000; //14318180 isa clock / 2 149 | 150 | machine_config config; 151 | device[0] = new saa1099_device(config, "", 0, 7159090); 152 | device[1] = new saa1099_device(config, "", 0, 7159090); 153 | 154 | device[0]->device_start(); 155 | device[1]->device_start(); 156 | } 157 | 158 | ~CMS() { 159 | cms_chan = 0; 160 | delete device[0]; 161 | delete device[1]; 162 | } 163 | }; 164 | 165 | 166 | static CMS* test; 167 | 168 | void CMS_Init(Section* sec) { 169 | test = new CMS(sec); 170 | } 171 | void CMS_ShutDown(Section* sec) { 172 | delete test; 173 | } 174 | -------------------------------------------------------------------------------- /src/hardware/mame/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I$(top_srcdir)/include 2 | 3 | noinst_LIBRARIES = libmame.a 4 | libmame_a_SOURCES = emu.h \ 5 | saa1099.cpp saa1099.h \ 6 | sn76496.cpp sn76496.h 7 | -------------------------------------------------------------------------------- /src/hardware/mame/emu.h: -------------------------------------------------------------------------------- 1 | #ifndef DOSBOX_EMU_H 2 | #define DOSBOX_EMU_H 3 | 4 | 5 | #include "dosbox.h" 6 | #if defined(_MSC_VER) && (_MSC_VER <= 1500) 7 | #include 8 | #else 9 | #include 10 | #endif 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #if C_DEBUG 17 | #include 18 | #include 19 | #endif 20 | 21 | #ifndef M_PI 22 | #define M_PI 3.14159265358979323846 23 | #endif 24 | 25 | typedef Bit16s stream_sample_t; 26 | 27 | typedef Bit8u u8; 28 | typedef Bit32u u32; 29 | 30 | class device_t; 31 | struct machine_config; 32 | 33 | #define NAME( _ASDF_ ) 0 34 | #define BIT( _INPUT_, _BIT_ ) ( ( _INPUT_) >> (_BIT_)) & 1 35 | 36 | #define ATTR_UNUSED 37 | #define DECLARE_READ8_MEMBER(name) u8 name( int, int) 38 | #define DECLARE_WRITE8_MEMBER(name) void name( int, int, u8 data) 39 | #define READ8_MEMBER(name) u8 name( int, int) 40 | #define WRITE8_MEMBER(name) void name( int offset, int space, u8 data) 41 | 42 | #define DECLARE_DEVICE_TYPE(Type, Class) \ 43 | extern const device_type Type; \ 44 | class Class; 45 | 46 | #define DEFINE_DEVICE_TYPE(Type, Class, ShortName, FullName) \ 47 | const device_type Type = 0; 48 | 49 | 50 | class device_sound_interface { 51 | public: 52 | struct sound_stream { 53 | void update() { 54 | } 55 | }; 56 | sound_stream temp; 57 | 58 | sound_stream* stream_alloc(int whatever, int channels, int size) { 59 | return &temp; 60 | }; 61 | 62 | 63 | virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) = 0; 64 | 65 | device_sound_interface(const machine_config &mconfig, device_t& _device) { 66 | } 67 | 68 | }; 69 | 70 | struct attotime { 71 | int whatever; 72 | 73 | static attotime from_hz(int hz) { 74 | return attotime(); 75 | } 76 | }; 77 | 78 | struct machine_config { 79 | }; 80 | 81 | typedef int device_type; 82 | 83 | class device_t { 84 | u32 clockRate; 85 | public: 86 | struct machine_t { 87 | int describe_context() const { 88 | return 0; 89 | } 90 | }; 91 | 92 | machine_t machine() const { 93 | return machine_t(); 94 | } 95 | 96 | //int offset, space; 97 | 98 | u32 clock() const { 99 | return clockRate; 100 | } 101 | 102 | void logerror(const char* msg, ...) { 103 | } 104 | 105 | static int tag() { 106 | return 0; 107 | } 108 | 109 | virtual void device_start() { 110 | } 111 | 112 | void save_item(int wtf, int blah= 0) { 113 | } 114 | 115 | device_t(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 _clock) : clockRate( _clock ) { 116 | } 117 | 118 | }; 119 | 120 | 121 | 122 | static void auto_free(const device_t::machine_t& machine, void * buffer) { 123 | free(buffer); 124 | } 125 | 126 | #define auto_alloc_array_clear(m, t, c) calloc(c, sizeof(t) ) 127 | #define auto_alloc_clear(m, t) static_cast( calloc(1, sizeof(t) ) ) 128 | 129 | 130 | 131 | 132 | #endif 133 | -------------------------------------------------------------------------------- /src/hardware/mame/saa1099.h: -------------------------------------------------------------------------------- 1 | // license:BSD-3-Clause 2 | // copyright-holders:Juergen Buchmueller, Manuel Abadia 3 | /********************************************** 4 | Philips SAA1099 Sound driver 5 | **********************************************/ 6 | 7 | #ifndef MAME_SOUND_SAA1099_H 8 | #define MAME_SOUND_SAA1099_H 9 | 10 | #pragma once 11 | 12 | //************************************************************************** 13 | // INTERFACE CONFIGURATION MACROS 14 | //************************************************************************** 15 | 16 | #define MCFG_SAA1099_ADD(_tag, _clock) \ 17 | MCFG_DEVICE_ADD(_tag, SAA1099, _clock) 18 | #define MCFG_SAA1099_REPLACE(_tag, _clock) \ 19 | MCFG_DEVICE_REPLACE(_tag, SAA1099, _clock) 20 | 21 | 22 | //************************************************************************** 23 | // TYPE DEFINITIONS 24 | //************************************************************************** 25 | 26 | //Container class for int that just initalizes to 0 27 | class NullInt { 28 | int value; 29 | public: 30 | operator int& () { 31 | return value; 32 | } 33 | 34 | int& operator= ( int set ) { 35 | value = set; 36 | return value; 37 | } 38 | 39 | NullInt( int set = 0 ) : value( set ) { 40 | } 41 | }; 42 | 43 | // ======================> saa1099_device 44 | 45 | class saa1099_device : public device_t, 46 | public device_sound_interface 47 | { 48 | public: 49 | saa1099_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); 50 | 51 | DECLARE_WRITE8_MEMBER( control_w ); 52 | DECLARE_WRITE8_MEMBER( data_w ); 53 | 54 | DECLARE_WRITE8_MEMBER( write ); 55 | 56 | //protected: 57 | // device-level overrides 58 | virtual void device_start(); 59 | 60 | // sound stream update overrides 61 | virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); 62 | 63 | private: 64 | struct saa1099_channel 65 | { 66 | saa1099_channel() { 67 | //Quite hacky, but let's see how it goes 68 | memset( this, 0, sizeof( *this ) ); 69 | } 70 | 71 | int frequency ; /* frequency (0x00..0xff) */ 72 | int freq_enable ; /* frequency enable */ 73 | int noise_enable ; /* noise enable */ 74 | int octave ; /* octave (0x00..0x07) */ 75 | int amplitude[2]; /* amplitude (0x00..0x0f) */ 76 | int envelope[2]; /* envelope (0x00..0x0f or 0x10 == off) */ 77 | 78 | /* vars to simulate the square wave */ 79 | double counter ; 80 | double freq ; 81 | int level ; 82 | 83 | }; 84 | 85 | struct saa1099_noise 86 | { 87 | saa1099_noise() { 88 | counter = 0; 89 | freq = 0; 90 | level = 0xFFFFFFFF; 91 | } 92 | 93 | /* vars to simulate the noise generator output */ 94 | double counter; 95 | double freq; 96 | uint32_t level; /* noise polynomial shifter */ 97 | }; 98 | 99 | void envelope_w(int ch); 100 | 101 | sound_stream *m_stream; /* our stream */ 102 | int m_noise_params[2]; /* noise generators parameters */ 103 | int m_env_enable[2]; /* envelope generators enable */ 104 | int m_env_reverse_right[2]; /* envelope reversed for right channel */ 105 | int m_env_mode[2]; /* envelope generators mode */ 106 | int m_env_bits[2]; /* non zero = 3 bits resolution */ 107 | int m_env_clock[2]; /* envelope clock mode (non-zero external) */ 108 | int m_env_step[2]; /* current envelope step */ 109 | int m_all_ch_enable; /* all channels enable */ 110 | int m_sync_state; /* sync all channels */ 111 | int m_selected_reg; /* selected register */ 112 | saa1099_channel m_channels[6]; /* channels */ 113 | saa1099_noise m_noise[2]; /* noise generators */ 114 | double m_sample_rate; 115 | int m_master_clock; 116 | }; 117 | 118 | DECLARE_DEVICE_TYPE(SAA1099, saa1099_device) 119 | 120 | #endif // MAME_SOUND_SAA1099_H 121 | -------------------------------------------------------------------------------- /src/hardware/serialport/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I$(top_srcdir)/include 2 | 3 | noinst_LIBRARIES = libserial.a 4 | 5 | libserial_a_SOURCES = directserial.cpp directserial.h \ 6 | libserial.cpp libserial.h \ 7 | serialdummy.cpp serialdummy.h serialport.cpp \ 8 | softmodem.cpp softmodem.h misc_util.cpp misc_util.h \ 9 | nullmodem.cpp nullmodem.h 10 | -------------------------------------------------------------------------------- /src/hardware/serialport/directserial.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: directserial.h,v 1.2 2009-09-26 09:15:19 h-a-l-9000 Exp $ */ 20 | 21 | // include guard 22 | #ifndef DOSBOX_DIRECTSERIAL_WIN32_H 23 | #define DOSBOX_DIRECTSERIAL_WIN32_H 24 | 25 | #include "dosbox.h" 26 | 27 | #if C_DIRECTSERIAL 28 | 29 | #define DIRECTSERIAL_AVAILIBLE 30 | #include "serialport.h" 31 | 32 | #include "libserial.h" 33 | 34 | class CDirectSerial : public CSerial { 35 | public: 36 | CDirectSerial(Bitu id, CommandLine* cmd); 37 | ~CDirectSerial(); 38 | 39 | void updatePortConfig(Bit16u divider, Bit8u lcr); 40 | void updateMSR(); 41 | void transmitByte(Bit8u val, bool first); 42 | void setBreak(bool value); 43 | 44 | void setRTSDTR(bool rts, bool dtr); 45 | void setRTS(bool val); 46 | void setDTR(bool val); 47 | void handleUpperEvent(Bit16u type); 48 | 49 | private: 50 | COMPORT comport; 51 | 52 | Bitu rx_state; 53 | #define D_RX_IDLE 0 54 | #define D_RX_WAIT 1 55 | #define D_RX_BLOCKED 2 56 | #define D_RX_FASTWAIT 3 57 | 58 | Bitu rx_retry; // counter of retries (every millisecond) 59 | Bitu rx_retry_max; // how many POLL_EVENTS to wait before causing 60 | // an overrun error. 61 | bool doReceive(); 62 | 63 | #if SERIAL_DEBUG 64 | bool dbgmsg_poll_block; 65 | bool dbgmsg_rx_block; 66 | #endif 67 | 68 | }; 69 | 70 | #endif // C_DIRECTSERIAL 71 | #endif // include guard 72 | -------------------------------------------------------------------------------- /src/hardware/serialport/libserial.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: libserial.h,v 1.2 2009-09-26 09:15:19 h-a-l-9000 Exp $ */ 20 | 21 | #include 22 | 23 | typedef struct _COMPORT *COMPORT; 24 | 25 | bool SERIAL_open(const char* portname, COMPORT* port); 26 | void SERIAL_close(COMPORT port); 27 | void SERIAL_getErrorString(char* buffer, size_t length); 28 | 29 | #define SERIAL_1STOP 1 30 | #define SERIAL_2STOP 2 31 | #define SERIAL_15STOP 0 32 | 33 | // parity: n, o, e, m, s 34 | 35 | bool SERIAL_setCommParameters(COMPORT port, 36 | int baudrate, char parity, int stopbits, int length); 37 | 38 | void SERIAL_setDTR(COMPORT port, bool value); 39 | void SERIAL_setRTS(COMPORT port, bool value); 40 | void SERIAL_setBREAK(COMPORT port, bool value); 41 | 42 | #define SERIAL_CTS 0x10 43 | #define SERIAL_DSR 0x20 44 | #define SERIAL_RI 0x40 45 | #define SERIAL_CD 0x80 46 | 47 | int SERIAL_getmodemstatus(COMPORT port); 48 | bool SERIAL_setmodemcontrol(COMPORT port, int flags); 49 | 50 | bool SERIAL_sendchar(COMPORT port, char data); 51 | 52 | // 0-7 char data, higher=flags 53 | #define SERIAL_BREAK_ERR 0x10 54 | #define SERIAL_FRAMING_ERR 0x08 55 | #define SERIAL_PARITY_ERR 0x04 56 | #define SERIAL_OVERRUN_ERR 0x02 57 | 58 | int SERIAL_getextchar(COMPORT port); 59 | -------------------------------------------------------------------------------- /src/hardware/serialport/misc_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: misc_util.h,v 1.5 2009-09-25 23:40:47 h-a-l-9000 Exp $ */ 20 | 21 | #ifndef SDLNETWRAPPER_H 22 | #define SDLNETWRAPPER_H 23 | 24 | #ifndef DOSBOX_DOSBOX_H 25 | #include "dosbox.h" 26 | #endif 27 | 28 | #if C_MODEM 29 | 30 | # ifndef DOSBOX_SUPPORT_H 31 | #include "support.h" 32 | #endif 33 | 34 | // Netwrapper Capabilities 35 | #define NETWRAPPER_TCP 1 36 | #define NETWRAPPER_TCP_NATIVESOCKET 2 37 | 38 | #if defined WIN32 39 | #define NATIVESOCKETS 40 | #include 41 | #include //for socklen_t 42 | //typedef int socklen_t; 43 | 44 | //Tests for BSD/OS2/LINUX 45 | #elif defined HAVE_STDLIB_H && defined HAVE_SYS_TYPES_H && defined HAVE_SYS_SOCKET_H && defined HAVE_NETINET_IN_H 46 | #define NATIVESOCKETS 47 | #define SOCKET int 48 | #include //darwin 49 | #include //darwin 50 | #include 51 | #include 52 | #include 53 | //socklen_t should be handled by configure 54 | #endif 55 | 56 | #ifdef NATIVESOCKETS 57 | #define CAPWORD (NETWRAPPER_TCP|NETWRAPPER_TCP_NATIVESOCKET) 58 | #else 59 | #define CAPWORD NETWRAPPER_TCP 60 | #endif 61 | 62 | #include "SDL_net.h" 63 | 64 | 65 | 66 | Bit32u Netwrapper_GetCapabilities(); 67 | 68 | 69 | class TCPClientSocket { 70 | public: 71 | TCPClientSocket(TCPsocket source); 72 | TCPClientSocket(const char* destination, Bit16u port); 73 | #ifdef NATIVESOCKETS 74 | Bit8u* nativetcpstruct; 75 | TCPClientSocket(int platformsocket); 76 | #endif 77 | ~TCPClientSocket(); 78 | 79 | // return: 80 | // -1: no data 81 | // -2: socket closed 82 | // >0: data char 83 | Bits GetcharNonBlock(); 84 | 85 | 86 | bool Putchar(Bit8u data); 87 | bool SendArray(Bit8u* data, Bitu bufsize); 88 | bool ReceiveArray(Bit8u* data, Bitu* size); 89 | bool isopen; 90 | 91 | bool GetRemoteAddressString(Bit8u* buffer); 92 | 93 | void FlushBuffer(); 94 | void SetSendBufferSize(Bitu bufsize); 95 | 96 | // buffered send functions 97 | bool SendByteBuffered(Bit8u data); 98 | bool SendArrayBuffered(Bit8u* data, Bitu bufsize); 99 | 100 | private: 101 | TCPsocket mysock; 102 | SDLNet_SocketSet listensocketset; 103 | 104 | // Items for send buffering 105 | Bitu sendbuffersize; 106 | Bitu sendbufferindex; 107 | 108 | Bit8u* sendbuffer; 109 | }; 110 | 111 | class TCPServerSocket { 112 | public: 113 | bool isopen; 114 | TCPsocket mysock; 115 | TCPServerSocket(Bit16u port); 116 | ~TCPServerSocket(); 117 | TCPClientSocket* Accept(); 118 | }; 119 | 120 | 121 | #endif //C_MODEM 122 | 123 | #endif //# SDLNETWRAPPER_H 124 | -------------------------------------------------------------------------------- /src/hardware/serialport/nullmodem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: nullmodem.h,v 1.4 2009-09-25 23:40:47 h-a-l-9000 Exp $ */ 20 | 21 | // include guard 22 | #ifndef DOSBOX_NULLMODEM_WIN32_H 23 | #define DOSBOX_NULLMODEM_WIN32_H 24 | 25 | #include "dosbox.h" 26 | 27 | #if C_MODEM 28 | 29 | #include "misc_util.h" 30 | #include "serialport.h" 31 | 32 | #define SERIAL_SERVER_POLLING_EVENT SERIAL_BASE_EVENT_COUNT+1 33 | #define SERIAL_TX_REDUCTION SERIAL_BASE_EVENT_COUNT+2 34 | #define SERIAL_NULLMODEM_DTR_EVENT SERIAL_BASE_EVENT_COUNT+3 35 | #define SERIAL_NULLMODEM_EVENT_COUNT SERIAL_BASE_EVENT_COUNT+3 36 | 37 | class CNullModem : public CSerial { 38 | public: 39 | TCPServerSocket* serversocket; 40 | TCPClientSocket* clientsocket; 41 | 42 | CNullModem(Bitu id, CommandLine* cmd); 43 | ~CNullModem(); 44 | bool receiveblock; // It's not a block of data it rather blocks 45 | Bit16u serverport; // we are a server if this is nonzero 46 | Bit16u clientport; 47 | 48 | Bit8u hostnamebuffer[128]; // the name passed to us by the user 49 | 50 | void updatePortConfig(Bit16u divider, Bit8u lcr); 51 | void updateMSR(); 52 | void transmitByte(Bit8u val, bool first); 53 | void setBreak(bool value); 54 | 55 | void setRTSDTR(bool rts, bool dtr); 56 | void setRTS(bool val); 57 | void setDTR(bool val); 58 | void handleUpperEvent(Bit16u type); 59 | 60 | Bitu rx_state; 61 | #define N_RX_IDLE 0 62 | #define N_RX_WAIT 1 63 | #define N_RX_BLOCKED 2 64 | #define N_RX_FASTWAIT 3 65 | #define N_RX_DISC 4 66 | 67 | bool doReceive(); 68 | void ClientConnect(); 69 | void Disconnect(); 70 | Bits readChar(); 71 | void WriteChar(Bit8u data); 72 | 73 | bool tx_block; // true while the SERIAL_TX_REDUCTION event 74 | // is pending 75 | 76 | Bitu rx_retry; // counter of retries 77 | 78 | Bitu rx_retry_max; // how many POLL_EVENTS to wait before causing 79 | // a overrun error. 80 | 81 | Bitu tx_gather; // how long to gather tx data before 82 | // sending all of them [milliseconds] 83 | 84 | 85 | bool dtrrespect; // dtr behavior - only send data to the serial 86 | // port when DTR is on 87 | 88 | bool transparent; // if true, don't send 0xff 0xXX to toggle 89 | // DSR/CTS. 90 | 91 | bool telnet; // Do Telnet parsing. 92 | 93 | // Telnet's brain 94 | #define TEL_CLIENT 0 95 | #define TEL_SERVER 1 96 | 97 | Bits TelnetEmulation(Bit8u data); 98 | 99 | // Telnet's memory 100 | struct { 101 | bool binary[2]; 102 | bool echo[2]; 103 | bool supressGA[2]; 104 | bool timingMark[2]; 105 | 106 | bool inIAC; 107 | bool recCommand; 108 | Bit8u command; 109 | } telClient; 110 | }; 111 | 112 | #endif // C_MODEM 113 | #endif // include guard 114 | -------------------------------------------------------------------------------- /src/hardware/serialport/serialdummy.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: serialdummy.cpp,v 1.5 2009-05-27 09:15:41 qbix79 Exp $ */ 20 | 21 | #include "dosbox.h" 22 | 23 | #include "setup.h" 24 | #include "serialdummy.h" 25 | #include "serialport.h" 26 | 27 | CSerialDummy::CSerialDummy(Bitu id, CommandLine* cmd):CSerial(id, cmd) { 28 | CSerial::Init_Registers(); 29 | setRI(false); 30 | setDSR(false); 31 | setCD(false); 32 | setCTS(false); 33 | InstallationSuccessful=true; 34 | } 35 | 36 | CSerialDummy::~CSerialDummy() { 37 | // clear events 38 | removeEvent(SERIAL_TX_EVENT); 39 | } 40 | 41 | void CSerialDummy::handleUpperEvent(Bit16u type) { 42 | if(type==SERIAL_TX_EVENT) { 43 | //LOG_MSG("SERIAL_TX_EVENT"); 44 | #ifdef CHECKIT_TESTPLUG 45 | receiveByte(loopbackdata); 46 | #endif 47 | ByteTransmitted(); // tx timeout 48 | } 49 | else if(type==SERIAL_THR_EVENT){ 50 | //LOG_MSG("SERIAL_THR_EVENT"); 51 | ByteTransmitting(); 52 | setEvent(SERIAL_TX_EVENT,bytetime); 53 | } 54 | 55 | } 56 | 57 | /*****************************************************************************/ 58 | /* updatePortConfig is called when emulated app changes the serial port **/ 59 | /* parameters baudrate, stopbits, number of databits, parity. **/ 60 | /*****************************************************************************/ 61 | void CSerialDummy::updatePortConfig(Bit16u divider, Bit8u lcr) { 62 | //LOG_MSG("Serial port at 0x%x: Port params changed: %d Baud", base,dcb.BaudRate); 63 | } 64 | 65 | void CSerialDummy::updateMSR() { 66 | } 67 | void CSerialDummy::transmitByte(Bit8u val, bool first) { 68 | 69 | if(first) setEvent(SERIAL_THR_EVENT, bytetime/10); 70 | else setEvent(SERIAL_TX_EVENT, bytetime); 71 | 72 | #ifdef CHECKIT_TESTPLUG 73 | loopbackdata=val; 74 | #endif 75 | } 76 | 77 | /*****************************************************************************/ 78 | /* setBreak(val) switches break on or off **/ 79 | /*****************************************************************************/ 80 | 81 | void CSerialDummy::setBreak(bool value) { 82 | //LOG_MSG("UART 0x%x: Break toggeled: %d", base, value); 83 | } 84 | 85 | /*****************************************************************************/ 86 | /* setRTSDTR sets the modem control lines **/ 87 | /*****************************************************************************/ 88 | void CSerialDummy::setRTSDTR(bool rts, bool dtr) { 89 | setRTS(rts); 90 | setDTR(dtr); 91 | } 92 | void CSerialDummy::setRTS(bool val) { 93 | #ifdef CHECKIT_TESTPLUG 94 | setCTS(val); 95 | #endif 96 | } 97 | void CSerialDummy::setDTR(bool val) { 98 | #ifdef CHECKIT_TESTPLUG 99 | setDSR(val); 100 | setRI(val); 101 | setCD(val); 102 | #endif 103 | } 104 | -------------------------------------------------------------------------------- /src/hardware/serialport/serialdummy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: serialdummy.h,v 1.5 2009-05-27 09:15:41 qbix79 Exp $ */ 20 | 21 | #ifndef INCLUDEGUARD_SERIALDUMMY_H 22 | #define INCLUDEGUARD_SERIALDUMMY_H 23 | 24 | #include "serialport.h" 25 | 26 | //#define CHECKIT_TESTPLUG 27 | 28 | class CSerialDummy : public CSerial { 29 | public: 30 | CSerialDummy(Bitu id, CommandLine* cmd); 31 | ~CSerialDummy(); 32 | 33 | void setRTSDTR(bool rts, bool dtr); 34 | void setRTS(bool val); 35 | void setDTR(bool val); 36 | 37 | void updatePortConfig(Bit16u, Bit8u lcr); 38 | void updateMSR(); 39 | void transmitByte(Bit8u val, bool first); 40 | void setBreak(bool value); 41 | void handleUpperEvent(Bit16u type); 42 | 43 | #ifdef CHECKIT_TESTPLUG 44 | Bit8u loopbackdata; 45 | #endif 46 | 47 | }; 48 | 49 | #endif // INCLUDEGUARD 50 | -------------------------------------------------------------------------------- /src/ints/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I$(top_srcdir)/include 2 | 3 | noinst_LIBRARIES = libints.a 4 | libints_a_SOURCES = mouse.cpp xms.cpp xms.h ems.cpp \ 5 | int10.cpp int10.h int10_char.cpp int10_memory.cpp int10_misc.cpp int10_modes.cpp \ 6 | int10_vesa.cpp int10_pal.cpp int10_put_pixel.cpp int10_video_state.cpp int10_vptable.cpp \ 7 | bios.cpp bios_disk.cpp bios_keyboard.cpp 8 | -------------------------------------------------------------------------------- /src/ints/xms.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | #ifndef __XMS_H__ 20 | #define __XMS_H__ 21 | 22 | Bitu XMS_QueryFreeMemory (Bit16u& largestFree, Bit16u& totalFree); 23 | Bitu XMS_AllocateMemory (Bitu size, Bit16u& handle); 24 | Bitu XMS_FreeMemory (Bitu handle); 25 | Bitu XMS_MoveMemory (PhysPt bpt); 26 | Bitu XMS_LockMemory (Bitu handle, Bit32u& address); 27 | Bitu XMS_UnlockMemory (Bitu handle); 28 | Bitu XMS_GetHandleInformation(Bitu handle, Bit8u& lockCount, Bit8u& numFree, Bit16u& size); 29 | Bitu XMS_ResizeMemory (Bitu handle, Bitu newSize); 30 | 31 | Bitu XMS_EnableA20 (bool enable); 32 | Bitu XMS_GetEnabledA20 (void); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/libs/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I$(top_srcdir)/include 2 | 3 | SUBDIRS = zmbv gui_tk 4 | -------------------------------------------------------------------------------- /src/libs/gui_tk/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I$(top_srcdir)/include 2 | 3 | noinst_LIBRARIES = libgui_tk.a 4 | libgui_tk_a_SOURCES = gui_tk.cpp gui_tk.h 5 | -------------------------------------------------------------------------------- /src/libs/zmbv/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = zmbv.cpp zmbv.h 2 | -------------------------------------------------------------------------------- /src/libs/zmbv/zmbv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | #ifndef DOSBOX_DOSBOX_H 20 | #ifdef _MSC_VER 21 | #define INLINE __forceinline 22 | #else 23 | #define INLINE inline 24 | #endif 25 | #endif 26 | 27 | #define CODEC_4CC "ZMBV" 28 | 29 | typedef enum { 30 | ZMBV_FORMAT_NONE = 0x00, 31 | ZMBV_FORMAT_1BPP = 0x01, 32 | ZMBV_FORMAT_2BPP = 0x02, 33 | ZMBV_FORMAT_4BPP = 0x03, 34 | ZMBV_FORMAT_8BPP = 0x04, 35 | ZMBV_FORMAT_15BPP = 0x05, 36 | ZMBV_FORMAT_16BPP = 0x06, 37 | ZMBV_FORMAT_24BPP = 0x07, 38 | ZMBV_FORMAT_32BPP = 0x08 39 | } zmbv_format_t; 40 | 41 | void Msg(const char fmt[], ...); 42 | class VideoCodec { 43 | private: 44 | struct FrameBlock { 45 | int start; 46 | int dx,dy; 47 | }; 48 | struct CodecVector { 49 | int x,y; 50 | int slot; 51 | }; 52 | struct KeyframeHeader { 53 | unsigned char high_version; 54 | unsigned char low_version; 55 | unsigned char compression; 56 | unsigned char format; 57 | unsigned char blockwidth,blockheight; 58 | }; 59 | 60 | struct { 61 | int linesDone; 62 | int writeSize; 63 | int writeDone; 64 | unsigned char *writeBuf; 65 | } compress; 66 | 67 | CodecVector VectorTable[512]; 68 | int VectorCount; 69 | 70 | unsigned char *oldframe, *newframe; 71 | unsigned char *buf1, *buf2, *work; 72 | int bufsize; 73 | 74 | int blockcount; 75 | FrameBlock * blocks; 76 | 77 | int workUsed, workPos; 78 | 79 | int palsize; 80 | char palette[256*4]; 81 | int height, width, pitch; 82 | zmbv_format_t format; 83 | int pixelsize; 84 | 85 | z_stream zstream; 86 | 87 | // methods 88 | void FreeBuffers(void); 89 | void CreateVectorTable(void); 90 | bool SetupBuffers(zmbv_format_t format, int blockwidth, int blockheight); 91 | 92 | template 93 | void AddXorFrame(void); 94 | template 95 | void UnXorFrame(void); 96 | template 97 | INLINE int PossibleBlock(int vx,int vy,FrameBlock * block); 98 | template 99 | INLINE int CompareBlock(int vx,int vy,FrameBlock * block); 100 | template 101 | INLINE void AddXorBlock(int vx,int vy,FrameBlock * block); 102 | template 103 | INLINE void UnXorBlock(int vx,int vy,FrameBlock * block); 104 | template 105 | INLINE void CopyBlock(int vx, int vy,FrameBlock * block); 106 | public: 107 | VideoCodec(); 108 | bool SetupCompress( int _width, int _height); 109 | bool SetupDecompress( int _width, int _height); 110 | zmbv_format_t BPPFormat( int bpp ); 111 | int NeededSize( int _width, int _height, zmbv_format_t _format); 112 | 113 | void CompressLines(int lineCount, void *lineData[]); 114 | bool PrepareCompressFrame(int flags, zmbv_format_t _format, char * pal, void *writeBuf, int writeSize); 115 | int FinishCompressFrame( void ); 116 | bool DecompressFrame(void * framedata, int size); 117 | void Output_UpsideDown_24(void * output); 118 | }; 119 | -------------------------------------------------------------------------------- /src/misc/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I$(top_srcdir)/include 2 | 3 | noinst_LIBRARIES = libmisc.a 4 | libmisc_a_SOURCES = cross.cpp messages.cpp programs.cpp setup.cpp support.cpp 5 | -------------------------------------------------------------------------------- /src/misc/messages.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: messages.cpp,v 1.23 2009-06-17 08:52:35 qbix79 Exp $ */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include "dosbox.h" 25 | #include "cross.h" 26 | #include "support.h" 27 | #include "setup.h" 28 | #include "control.h" 29 | #include 30 | #include 31 | using namespace std; 32 | 33 | 34 | 35 | #define LINE_IN_MAXLEN 2048 36 | 37 | struct MessageBlock { 38 | string name; 39 | string val; 40 | MessageBlock(const char* _name, const char* _val): 41 | name(_name),val(_val){} 42 | }; 43 | 44 | static list Lang; 45 | typedef list::iterator itmb; 46 | 47 | void MSG_Add(const char * _name, const char* _val) { 48 | /* Find the message */ 49 | for(itmb tel=Lang.begin();tel!=Lang.end();tel++) { 50 | if((*tel).name==_name) { 51 | // LOG_MSG("double entry for %s",_name); //Message file might be loaded before default text messages 52 | return; 53 | } 54 | } 55 | /* if the message doesn't exist add it */ 56 | Lang.push_back(MessageBlock(_name,_val)); 57 | } 58 | 59 | void MSG_Replace(const char * _name, const char* _val) { 60 | /* Find the message */ 61 | for(itmb tel=Lang.begin();tel!=Lang.end();tel++) { 62 | if((*tel).name==_name) { 63 | Lang.erase(tel); 64 | break; 65 | } 66 | } 67 | /* Even if the message doesn't exist add it */ 68 | Lang.push_back(MessageBlock(_name,_val)); 69 | } 70 | 71 | static void LoadMessageFile(const char * fname) { 72 | if (!fname) return; 73 | if(*fname=='\0') return;//empty string=no languagefile 74 | FILE * mfile=fopen(fname,"rt"); 75 | /* This should never happen and since other modules depend on this use a normal printf */ 76 | if (!mfile) { 77 | E_Exit("MSG:Can't load messages: %s",fname); 78 | } 79 | char linein[LINE_IN_MAXLEN]; 80 | char name[LINE_IN_MAXLEN]; 81 | char string[LINE_IN_MAXLEN*10]; 82 | /* Start out with empty strings */ 83 | name[0]=0;string[0]=0; 84 | while(fgets(linein, LINE_IN_MAXLEN, mfile)!=0) { 85 | /* Parse the read line */ 86 | /* First remove characters 10 and 13 from the line */ 87 | char * parser=linein; 88 | char * writer=linein; 89 | while (*parser) { 90 | if (*parser!=10 && *parser!=13) { 91 | *writer++=*parser; 92 | } 93 | *parser++; 94 | } 95 | *writer=0; 96 | /* New string name */ 97 | if (linein[0]==':') { 98 | string[0]=0; 99 | strcpy(name,linein+1); 100 | /* End of string marker */ 101 | } else if (linein[0]=='.') { 102 | /* Replace/Add the string to the internal langaugefile */ 103 | /* Remove last newline (marker is \n.\n) */ 104 | size_t ll = strlen(string); 105 | if(ll && string[ll - 1] == '\n') string[ll - 1] = 0; //Second if should not be needed, but better be safe. 106 | MSG_Replace(name,string); 107 | } else { 108 | /* Normal string to be added */ 109 | strcat(string,linein); 110 | strcat(string,"\n"); 111 | } 112 | } 113 | fclose(mfile); 114 | } 115 | 116 | const char * MSG_Get(char const * msg) { 117 | for(itmb tel=Lang.begin();tel!=Lang.end();tel++){ 118 | if((*tel).name==msg) 119 | { 120 | return (*tel).val.c_str(); 121 | } 122 | } 123 | return "Message not Found!\n"; 124 | } 125 | 126 | 127 | void MSG_Write(const char * location) { 128 | FILE* out=fopen(location,"w+t"); 129 | if(out==NULL) return;//maybe an error? 130 | for(itmb tel=Lang.begin();tel!=Lang.end();tel++){ 131 | fprintf(out,":%s\n%s\n.\n",(*tel).name.c_str(),(*tel).val.c_str()); 132 | } 133 | fclose(out); 134 | } 135 | 136 | void MSG_Init(Section_prop * section) { 137 | std::string file_name; 138 | if (control->cmdline->FindString("-lang",file_name,true)) { 139 | LoadMessageFile(file_name.c_str()); 140 | } else { 141 | Prop_path* pathprop = section->Get_path("language"); 142 | if(pathprop) LoadMessageFile(pathprop->realpath.c_str()); 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/misc/support.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2010 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 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* $Id: support.cpp,v 1.37 2009-05-27 09:15:42 qbix79 Exp $ */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include "dosbox.h" 33 | #include "debug.h" 34 | #include "support.h" 35 | #include "video.h" 36 | 37 | 38 | void upcase(std::string &str) { 39 | int (*tf)(int) = std::toupper; 40 | std::transform(str.begin(), str.end(), str.begin(), tf); 41 | } 42 | 43 | void lowcase(std::string &str) { 44 | int (*tf)(int) = std::tolower; 45 | std::transform(str.begin(), str.end(), str.begin(), tf); 46 | } 47 | 48 | 49 | /* 50 | Ripped some source from freedos for this one. 51 | 52 | */ 53 | 54 | 55 | /* 56 | * replaces all instances of character o with character c 57 | */ 58 | 59 | 60 | void strreplace(char * str,char o,char n) { 61 | while (*str) { 62 | if (*str==o) *str=n; 63 | str++; 64 | } 65 | } 66 | char *ltrim(char *str) { 67 | while (*str && isspace(*reinterpret_cast(str))) str++; 68 | return str; 69 | } 70 | 71 | char *rtrim(char *str) { 72 | char *p; 73 | p = strchr(str, '\0'); 74 | while (--p >= str && isspace(*reinterpret_cast(p))) {}; 75 | p[1] = '\0'; 76 | return str; 77 | } 78 | 79 | char *trim(char *str) { 80 | return ltrim(rtrim(str)); 81 | } 82 | 83 | char * upcase(char * str) { 84 | for (char* idx = str; *idx ; idx++) *idx = toupper(*reinterpret_cast(idx)); 85 | return str; 86 | } 87 | 88 | char * lowcase(char * str) { 89 | for(char* idx = str; *idx ; idx++) *idx = tolower(*reinterpret_cast(idx)); 90 | return str; 91 | } 92 | 93 | 94 | 95 | bool ScanCMDBool(char * cmd,char const * const check) { 96 | char * scan=cmd;size_t c_len=strlen(check); 97 | while ((scan=strchr(scan,'/'))) { 98 | /* found a / now see behind it */ 99 | scan++; 100 | if (strncasecmp(scan,check,c_len)==0 && (scan[c_len]==' ' || scan[c_len]=='\t' || scan[c_len]=='/' || scan[c_len]==0)) { 101 | /* Found a math now remove it from the string */ 102 | memmove(scan-1,scan+c_len,strlen(scan+c_len)+1); 103 | trim(scan-1); 104 | return true; 105 | } 106 | } 107 | return false; 108 | } 109 | 110 | /* This scans the command line for a remaining switch and reports it else returns 0*/ 111 | char * ScanCMDRemain(char * cmd) { 112 | char * scan,*found;; 113 | if ((scan=found=strchr(cmd,'/'))) { 114 | while ( *scan && !isspace(*reinterpret_cast(scan)) ) scan++; 115 | *scan=0; 116 | return found; 117 | } else return 0; 118 | } 119 | 120 | char * StripWord(char *&line) { 121 | char * scan=line; 122 | scan=ltrim(scan); 123 | if (*scan=='"') { 124 | char * end_quote=strchr(scan+1,'"'); 125 | if (end_quote) { 126 | *end_quote=0; 127 | line=ltrim(++end_quote); 128 | return (scan+1); 129 | } 130 | } 131 | char * begin=scan; 132 | for (char c = *scan ;(c = *scan);scan++) { 133 | if (isspace(*reinterpret_cast(&c))) { 134 | *scan++=0; 135 | break; 136 | } 137 | } 138 | line=scan; 139 | return begin; 140 | } 141 | 142 | Bits ConvDecWord(char * word) { 143 | bool negative=false;Bitu ret=0; 144 | if (*word=='-') { 145 | negative=true; 146 | word++; 147 | } 148 | while (char c=*word) { 149 | ret*=10; 150 | ret+=c-'0'; 151 | word++; 152 | } 153 | if (negative) return 0-ret; 154 | else return ret; 155 | } 156 | 157 | Bits ConvHexWord(char * word) { 158 | Bitu ret=0; 159 | while (char c=toupper(*reinterpret_cast(word))) { 160 | ret*=16; 161 | if (c>='0' && c<='9') ret+=c-'0'; 162 | else if (c>='A' && c<='F') ret+=10+(c-'A'); 163 | word++; 164 | } 165 | return ret; 166 | } 167 | 168 | double ConvDblWord(char * word) { 169 | return 0.0f; 170 | } 171 | 172 | 173 | static char buf[1024]; //greater scope as else it doesn't always gets thrown right (linux/gcc2.95) 174 | void E_Exit(const char * format,...) { 175 | #if C_DEBUG && C_HEAVY_DEBUG 176 | DEBUG_HeavyWriteLogInstruction(); 177 | #endif 178 | va_list msg; 179 | va_start(msg,format); 180 | vsprintf(buf,format,msg); 181 | va_end(msg); 182 | strcat(buf,"\n"); 183 | 184 | throw(buf); 185 | } 186 | -------------------------------------------------------------------------------- /src/platform/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = visualc 2 | 3 | EXTRA_DIST = sdl-win32.diff -------------------------------------------------------------------------------- /src/platform/sdl-win32.diff: -------------------------------------------------------------------------------- 1 | diff -ru SDL-1.2.12/src/main/win32/version.rc SDL-1.2.12release/src/main/win32/version.rc 2 | --- SDL-1.2.12/src/main/win32/version.rc 2007-07-20 07:52:05.000000000 +0200 3 | +++ SDL-1.2.12release/src/main/win32/version.rc 2007-08-17 19:03:42.000000000 +0200 4 | @@ -13,7 +13,7 @@ 5 | FILEVERSION 1,2,12,0 6 | PRODUCTVERSION 1,2,12,0 7 | FILEFLAGSMASK 0x3fL 8 | - FILEFLAGS 0x0L 9 | + FILEFLAGS 0x4L 10 | FILEOS 0x40004L 11 | FILETYPE 0x2L 12 | FILESUBTYPE 0x0L 13 | diff -ru SDL-1.2.12/src/video/SDL_video.c SDL-1.2.12release/src/video/SDL_video.c 14 | --- SDL-1.2.12/src/video/SDL_video.c 2007-07-20 07:52:25.000000000 +0200 15 | +++ SDL-1.2.12release/src/video/SDL_video.c 2007-08-17 02:51:52.000000000 +0200 16 | @@ -75,12 +75,12 @@ 17 | #if SDL_VIDEO_DRIVER_GAPI 18 | &GAPI_bootstrap, 19 | #endif 20 | -#if SDL_VIDEO_DRIVER_WINDIB 21 | - &WINDIB_bootstrap, 22 | -#endif 23 | #if SDL_VIDEO_DRIVER_DDRAW 24 | &DIRECTX_bootstrap, 25 | #endif 26 | +#if SDL_VIDEO_DRIVER_WINDIB 27 | + &WINDIB_bootstrap, 28 | +#endif 29 | #if SDL_VIDEO_DRIVER_BWINDOW 30 | &BWINDOW_bootstrap, 31 | #endif 32 | diff -ru SDL-1.2.12/src/video/windx5/SDL_dx5events.c SDL-1.2.12release/src/video/windx5/SDL_dx5events.c 33 | --- SDL-1.2.12/src/video/windx5/SDL_dx5events.c 2007-07-20 07:52:25.000000000 +0200 34 | +++ SDL-1.2.12release/src/video/windx5/SDL_dx5events.c 2007-08-17 02:51:52.000000000 +0200 35 | @@ -519,7 +519,7 @@ 36 | case WM_SYSKEYDOWN: { 37 | /* Pass syskey to DefWindwoProc (ALT-F4, etc.) */ 38 | } 39 | - break; 40 | +// break; 41 | case WM_KEYUP: 42 | case WM_KEYDOWN: { 43 | /* Ignore windows keyboard messages */; 44 | diff -ru SDL-1.2.12/src/video/windx5/SDL_dx5video.c SDL-1.2.12release/src/video/windx5/SDL_dx5video.c 45 | --- SDL-1.2.12/src/video/windx5/SDL_dx5video.c 2007-07-20 07:52:25.000000000 +0200 46 | +++ SDL-1.2.12release/src/video/windx5/SDL_dx5video.c 2007-08-17 02:51:52.000000000 +0200 47 | @@ -1496,7 +1496,7 @@ 48 | } 49 | } 50 | dd_surface3 = NULL; 51 | -#if 0 /* FIXME: enable this when SDL consistently reports lost surfaces */ 52 | +#if 1 /* FIXME: enable this when SDL consistently reports lost surfaces */ 53 | if ( (flags & SDL_HWSURFACE) == SDL_HWSURFACE ) { 54 | video->flags |= SDL_HWSURFACE; 55 | } else { 56 | -------------------------------------------------------------------------------- /src/platform/visualc/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = unistd.h config.h ntddscsi.h ntddcdrm.h 2 | -------------------------------------------------------------------------------- /src/platform/visualc/config.h: -------------------------------------------------------------------------------- 1 | #define VERSION "0.74-3" 2 | 3 | /* Define to 1 to enable internal debugger, requires libcurses */ 4 | #define C_DEBUG 0 5 | 6 | /* Define to 1 to enable screenshots, requires libpng */ 7 | #define C_SSHOT 1 8 | 9 | /* Define to 1 to use opengl display output support */ 10 | #define C_OPENGL 1 11 | 12 | /* Define to 1 to enable internal modem support, requires SDL_net */ 13 | #define C_MODEM 1 14 | 15 | /* Define to 1 to enable IPX networking support, requires SDL_net */ 16 | #define C_IPX 1 17 | 18 | /* Enable some heavy debugging options */ 19 | #define C_HEAVY_DEBUG 0 20 | 21 | /* The type of cpu this host has */ 22 | #define C_TARGETCPU X86 23 | //#define C_TARGETCPU X86_64 24 | 25 | /* Define to 1 to use x86 dynamic cpu core */ 26 | #define C_DYNAMIC_X86 1 27 | 28 | /* Define to 1 to use recompiling cpu core. Can not be used together with the dynamic-x86 core */ 29 | #define C_DYNREC 0 30 | 31 | /* Enable memory function inlining in */ 32 | #define C_CORE_INLINE 0 33 | 34 | /* Enable the FPU module, still only for beta testing */ 35 | #define C_FPU 1 36 | 37 | /* Define to 1 to use a x86 assembly fpu core */ 38 | #define C_FPU_X86 1 39 | 40 | /* Define to 1 to use a unaligned memory access */ 41 | #define C_UNALIGNED_MEMORY 1 42 | 43 | /* environ is defined */ 44 | #define ENVIRON_INCLUDED 1 45 | 46 | /* environ can be linked */ 47 | #define ENVIRON_LINKED 1 48 | 49 | /* Define to 1 if you have the header file. */ 50 | #define HAVE_DDRAW_H 1 51 | 52 | /* Define to 1 if you want serial passthrough support (Win32 only). */ 53 | #define C_DIRECTSERIAL 1 54 | 55 | #define GCC_ATTRIBUTE(x) /* attribute not supported */ 56 | #define GCC_UNLIKELY(x) (x) 57 | #define GCC_LIKELY(x) (x) 58 | 59 | #define INLINE __forceinline 60 | #define DB_FASTCALL __fastcall 61 | 62 | #if defined(_MSC_VER) && (_MSC_VER >= 1400) 63 | #pragma warning(disable : 4996) 64 | #endif 65 | 66 | typedef double Real64; 67 | /* The internal types */ 68 | typedef unsigned char Bit8u; 69 | typedef signed char Bit8s; 70 | typedef unsigned short Bit16u; 71 | typedef signed short Bit16s; 72 | typedef unsigned long Bit32u; 73 | typedef signed long Bit32s; 74 | typedef unsigned __int64 Bit64u; 75 | typedef signed __int64 Bit64s; 76 | typedef unsigned int Bitu; 77 | typedef signed int Bits; 78 | 79 | -------------------------------------------------------------------------------- /src/platform/visualc/ntddscsi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ntddscsi.h 3 | * 4 | * SCSI port IOCTL interface. 5 | * 6 | * This file is part of the w32api package. 7 | * 8 | * Contributors: 9 | * Created by Casper S. Hornstrup 10 | * 11 | * THIS SOFTWARE IS NOT COPYRIGHTED 12 | * 13 | * This source code is offered for use in the public domain. You may 14 | * use, modify or distribute it freely. 15 | * 16 | * This code is distributed in the hope that it will be useful but 17 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 18 | * DISCLAIMED. This includes but is not limited to warranties of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | */ 22 | 23 | #ifndef __NTDDSCSI_H 24 | #define __NTDDSCSI_H 25 | 26 | #if __GNUC__ >=3 27 | #pragma GCC system_header 28 | #endif 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | #pragma pack(push,4) 35 | 36 | //#include "ntddk.h" 37 | 38 | #define DD_SCSI_DEVICE_NAME "\\Device\\ScsiPort" 39 | #define DD_SCSI_DEVICE_NAME_U L"\\Device\\ScsiPort" 40 | 41 | #define IOCTL_SCSI_BASE FILE_DEVICE_CONTROLLER 42 | 43 | #define IOCTL_SCSI_GET_INQUIRY_DATA \ 44 | CTL_CODE(IOCTL_SCSI_BASE, 0x0403, METHOD_BUFFERED, FILE_ANY_ACCESS) 45 | 46 | #define IOCTL_SCSI_GET_CAPABILITIES \ 47 | CTL_CODE(IOCTL_SCSI_BASE, 0x0404, METHOD_BUFFERED, FILE_ANY_ACCESS) 48 | 49 | #define IOCTL_SCSI_GET_ADDRESS \ 50 | CTL_CODE(IOCTL_SCSI_BASE, 0x0406, METHOD_BUFFERED, FILE_ANY_ACCESS) 51 | 52 | #define IOCTL_SCSI_MINIPORT \ 53 | CTL_CODE(IOCTL_SCSI_BASE, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) 54 | 55 | #define IOCTL_SCSI_PASS_THROUGH \ 56 | CTL_CODE(IOCTL_SCSI_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) 57 | 58 | #define IOCTL_SCSI_PASS_THROUGH_DIRECT \ 59 | CTL_CODE(IOCTL_SCSI_BASE, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) 60 | 61 | #define IOCTL_SCSI_RESCAN_BUS \ 62 | CTL_CODE(IOCTL_SCSI_BASE, 0x0407, METHOD_BUFFERED, FILE_ANY_ACCESS) 63 | 64 | 65 | DEFINE_GUID(ScsiRawInterfaceGuid, 0x53f56309L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b); 66 | 67 | DEFINE_GUID(WmiScsiAddressGuid, 0x53f5630fL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b); 68 | 69 | typedef struct _SCSI_PASS_THROUGH { 70 | USHORT Length; 71 | UCHAR ScsiStatus; 72 | UCHAR PathId; 73 | UCHAR TargetId; 74 | UCHAR Lun; 75 | UCHAR CdbLength; 76 | UCHAR SenseInfoLength; 77 | UCHAR DataIn; 78 | ULONG DataTransferLength; 79 | ULONG TimeOutValue; 80 | ULONG_PTR DataBufferOffset; 81 | ULONG SenseInfoOffset; 82 | UCHAR Cdb[16]; 83 | } SCSI_PASS_THROUGH, *PSCSI_PASS_THROUGH; 84 | 85 | typedef struct _SCSI_PASS_THROUGH_DIRECT { 86 | USHORT Length; 87 | UCHAR ScsiStatus; 88 | UCHAR PathId; 89 | UCHAR TargetId; 90 | UCHAR Lun; 91 | UCHAR CdbLength; 92 | UCHAR SenseInfoLength; 93 | UCHAR DataIn; 94 | ULONG DataTransferLength; 95 | ULONG TimeOutValue; 96 | PVOID DataBuffer; 97 | ULONG SenseInfoOffset; 98 | UCHAR Cdb[16]; 99 | } SCSI_PASS_THROUGH_DIRECT, *PSCSI_PASS_THROUGH_DIRECT; 100 | 101 | typedef struct _SRB_IO_CONTROL { 102 | ULONG HeaderLength; 103 | UCHAR Signature[8]; 104 | ULONG Timeout; 105 | ULONG ControlCode; 106 | ULONG ReturnCode; 107 | ULONG Length; 108 | } SRB_IO_CONTROL, *PSRB_IO_CONTROL; 109 | 110 | typedef struct _SCSI_ADDRESS { 111 | ULONG Length; 112 | UCHAR PortNumber; 113 | UCHAR PathId; 114 | UCHAR TargetId; 115 | UCHAR Lun; 116 | } SCSI_ADDRESS, *PSCSI_ADDRESS; 117 | 118 | typedef struct _SCSI_BUS_DATA { 119 | UCHAR NumberOfLogicalUnits; 120 | UCHAR InitiatorBusId; 121 | ULONG InquiryDataOffset; 122 | }SCSI_BUS_DATA, *PSCSI_BUS_DATA; 123 | 124 | typedef struct _SCSI_ADAPTER_BUS_INFO { 125 | UCHAR NumberOfBuses; 126 | SCSI_BUS_DATA BusData[1]; 127 | } SCSI_ADAPTER_BUS_INFO, *PSCSI_ADAPTER_BUS_INFO; 128 | 129 | typedef struct _IO_SCSI_CAPABILITIES { 130 | ULONG Length; 131 | ULONG MaximumTransferLength; 132 | ULONG MaximumPhysicalPages; 133 | ULONG SupportedAsynchronousEvents; 134 | ULONG AlignmentMask; 135 | BOOLEAN TaggedQueuing; 136 | BOOLEAN AdapterScansDown; 137 | BOOLEAN AdapterUsesPio; 138 | } IO_SCSI_CAPABILITIES, *PIO_SCSI_CAPABILITIES; 139 | 140 | typedef struct _SCSI_INQUIRY_DATA { 141 | UCHAR PathId; 142 | UCHAR TargetId; 143 | UCHAR Lun; 144 | BOOLEAN DeviceClaimed; 145 | ULONG InquiryDataLength; 146 | ULONG NextInquiryDataOffset; 147 | UCHAR InquiryData[1]; 148 | } SCSI_INQUIRY_DATA, *PSCSI_INQUIRY_DATA; 149 | 150 | #define SCSI_IOCTL_DATA_OUT 0 151 | #define SCSI_IOCTL_DATA_IN 1 152 | #define SCSI_IOCTL_DATA_UNSPECIFIED 2 153 | 154 | /* 155 | typedef struct _DUMP_POINTERS { 156 | PADAPTER_OBJECT AdapterObject; 157 | PVOID MappedRegisterBase; 158 | PVOID DumpData; 159 | PVOID CommonBufferVa; 160 | LARGE_INTEGER CommonBufferPa; 161 | ULONG CommonBufferSize; 162 | BOOLEAN AllocateCommonBuffers; 163 | BOOLEAN UseDiskDump; 164 | UCHAR Spare1[2]; 165 | PVOID DeviceObject; 166 | } DUMP_POINTERS, *PDUMP_POINTERS; 167 | */ 168 | #pragma pack(pop) 169 | 170 | #ifdef __cplusplus 171 | } 172 | #endif 173 | 174 | #endif /* __NTDDSCSI_H */ 175 | -------------------------------------------------------------------------------- /src/platform/visualc/unistd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Mingw32 package. 3 | * 4 | * unistd.h maps (roughly) to io.h 5 | */ 6 | 7 | #ifndef __STRICT_ANSI__ 8 | #include 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /src/shell/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I$(top_srcdir)/include 2 | 3 | noinst_LIBRARIES = libshell.a 4 | libshell_a_SOURCES = shell.cpp shell_batch.cpp shell_cmds.cpp shell_misc.cpp 5 | -------------------------------------------------------------------------------- /src/winres.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KolibriOS/DOSBox/27a8b89892d90c301ad80173a3347ed3af55d750/src/winres.rc -------------------------------------------------------------------------------- /visualc_net/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = dosbox.sln dosbox.vcproj -------------------------------------------------------------------------------- /visualc_net/dosbox.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 8.00 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dosbox", "dosbox.vcproj", "{7FCFFB9B-8629-4D51-849C-8490CECF8AB7}" 3 | ProjectSection(ProjectDependencies) = postProject 4 | EndProjectSection 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfiguration) = preSolution 8 | Debug = Debug 9 | Release = Release 10 | EndGlobalSection 11 | GlobalSection(ProjectConfiguration) = postSolution 12 | {7FCFFB9B-8629-4D51-849C-8490CECF8AB7}.Debug.ActiveCfg = Debug|Win32 13 | {7FCFFB9B-8629-4D51-849C-8490CECF8AB7}.Debug.Build.0 = Debug|Win32 14 | {7FCFFB9B-8629-4D51-849C-8490CECF8AB7}.Release.ActiveCfg = Release|Win32 15 | {7FCFFB9B-8629-4D51-849C-8490CECF8AB7}.Release.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(ExtensibilityGlobals) = postSolution 18 | EndGlobalSection 19 | GlobalSection(ExtensibilityAddIns) = postSolution 20 | EndGlobalSection 21 | EndGlobal 22 | -------------------------------------------------------------------------------- /warcraft.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KolibriOS/DOSBox/27a8b89892d90c301ad80173a3347ed3af55d750/warcraft.jpeg --------------------------------------------------------------------------------