joncampbell123 / dosbox-x

DOSBox-X fork of the DOSBox project
GNU General Public License v2.0
2.64k stars 373 forks source link

Add an include macro to configuration files. #3128

Open runarorested opened 2 years ago

runarorested commented 2 years ago

Code of Conduct & Contributing Guidelines

Have you checked that no other similar feature request(s) already exists?

Is your feature request related to a problem? Please describe.

I like to execute old games and programs (old dos programming enviroments, old custom applications, etc), usually creating icons pointing to self contained folders with the matching config of said machine, in a similar way to the ones that GOG installer creates.

Specially in games because of the hardware support, sometimes I've multiple config files, depending of launching a basic vga+pc speaker setup, a "retro" ega/cga version, or an more advanced "supervga+soundcard" version. That ends being quite bothersome with lots of base set-ups duplicated many times, in every program, and lots of problems when updating dosbox(-x) itself.

What you want

I would like to request a way to use an include macro to call other config files. That would help splitting/reusing the config files a lot easier. While I do understand that keeping monolithic config files is good for debugging purposes, merely adding a command to dump/export/log the full file, includes already applied and duplicated/overwroten variables removed would generate an equivalent file to submit reports.

The idea would be to create a 3/4 layer config files. When launching dosbox with a targeted config file, said config file would:

1st layer: Hardware set up

  1. Include a machine/hardware setup in a per-system folder (/etc/dosbox or %AllUsersProfile%\dosbox (C:\ProgramData\dosbox)) that customize dosbox to your physical hardware:
    • Do you have a real 9-dot printer connected and where is connected? a printer emulator exporting files to which folder? or merely a dummy LPT port emulated?
    • Did you set up no scaling method for your old school crt monitor to do the work himself changing resolutions? Do you have an lcd flatscreen and a bootload of scalers set up?

2nd layer: Base emulation set up

  1. A common emulated machines config files.

    • I'm basing my set up on a 8086 floppy-images dos 3.3 pc?
    • A 286 16 mhz+hdd computer w/o EMS manager?
    • A 386 base machine for runing windows 3.1 with a cdrom image?
    • A popular old Nec PC 98 model to run some DOS/J?
    • Another Nec PC-98 model to run a Japanese Windows 98 image?
  2. A common scriptlets config files to modify/add certain features, depending of the program, in a generic way:

    • Adding a sound card: Soundblaster? Gus? MT-32 midi port for munt? General midi emulation?
    • Adding "hardware" lim/ems memory for old programs and demos, or old processors (8086, 80286)?
    • Enabling "software" lim/ems memory (emm386) for newer programs and demos?
    • Switching the default codepage (english/japanese) from machine default to your language.
    • Modifying the vesa emulation: version 1.2, 2.0, 3.0? Adding custom resolutions for 1 to one graphical support: FullHD (1080p)? HdReady (720p)?
    • Enabling lfn support switching dos to ver 7.1?
    • Enabling a network card?
    • Enablig glide?

3rd layer: Custom emulation set up

  1. Here are the variables to run this folder as a dosbox machine: mounting an emulated HD directory, a cd-rom image, a few per-software fixes, etc and the autoexec.bat

4th layer: Drivers redistributable files

  1. As an option, a common, readonly folder could be mounted to access driver files and tools that are not dos commands included in Z:\bin or Z:\system, and should be redistributed aside. This should be implemented as an conf scriptlets, to not burden development of dosbox-x.
    • Original drivers for ogl accelerator cards, soundcards, network cards, printers, joystick calibration (if possible) for Dos.
    • Original drivers for emulated videocard, cpu, soundcard, etc for windows 3.0, 3.1, 95, 98, 2000.
    • In a future version, virtual drivers like Virtualbox OS Additions to access other hardware? ex. an USB passthru so i can patch a pendrive in a virtual Windows 98 machine.
    • Where would this directory be located? in a shared folder (/var/dosbox/redist maybe?), it's path set up in your machine/hardware set up file, so you could mount it if you wanted. %additions%=/var/dosbox/redist

This would simplify per-machine config files from a 20kb full config file to something similar to this:

`$include "%commonconfs%/system.conf" # System config.Sets the output to your second monitor in full screen with the right scalers. # Elvira, Mistress of the dark $include "%commonconfs%/clone286.conf" # Basic machine # scriptlets for required hardware support $include "%commonconfs%/vga-pure.conf" $include "%commonconfs%/mouse-ps2.conf" $include "%commonconfs%/mt-32.conf" $include "%commonconfs%/gog_drive.conf" $include "%commonconfs%/gog_cloud_saves.conf"

[autoexec] mount c %gog_drive% cd elvira1 elvira.exe Z:\DOS\shutdown.exe `

`$include "%commonconfs%/system.conf" # System config.Sets the output to your second monitor in full screen with the right scalers. # Wordperfect 6.0 $include "%commonconfs%/clone286.conf" # Basic machine # scriptlets for required hardware support $include "%commonconfs%/svga-vesa12.conf" $include "%commonconfs%/text-ttf.conf" $include "%commonconfs%/mouse-ps2.conf" $include "%commonconfs%/lpt1_passthru.conf"

[ttf] font=./font/retro-ega.ttf fontbold=./font/retro-ega-bold.ttf

[autoexec] mount c ".\wordperfect-6.0\installation" share.exe c: cls ver `

`$include "%commonconfs%/system.conf" # System config.Sets the output to your second monitor in full screen with the right scalers. # Flight simulator 5 $include "%commonconfs%/clone486.conf" # Basic machine # scriptlets for required hardware support $include "%commonconfs%/svga-vesa12.conf" $include "%commonconfs%/mouse-ps2.conf"

[autoexec] mount c ".\msfs\5" c: fs.exe `

`$include "%commonconfs%/system.conf" # System config.Sets the output to your second monitor in full screen with the right scalers. # Doom2 $include "%commonconfs%/clone486.conf" # Basic machine # scriptlets for required hardware support $include "%commonconfs%/svga-vesa2.conf" $include "%commonconfs%/mouse-ps2.conf" $include "%commonconfs%/soundblaster-pro.conf"

[autoexec] mount c ".\doom" c: cd doom1 doom.exe ` As you can see, far shorter and easier to understand.

Describe alternatives you've considered

I've already been using a handmade script that would concatenate several text files to generate a dosbox.conf before launching it, but it is not ideal. And while solutions with custom launchers exist, to be really useful, it should be usable without extra software.

Additional context

As a complement it would be nice to be able to set enviroment variables inside the emulated machine from the config file, so batch files inside could use them to enable features depending of having emulated hardware support set-up. Like the %Blaster% variable is set up if sound-blaster emulation is enabled, but for other things: %CPU%=protected if running with protected mode memory managers are set up or not (so i can load tp.exe or tpx.exe in turbo-pascal depending of it), %GUS%=C:\ULTRASOUND\ if Gravis ultrasound is enabled.

Wengier commented 2 years ago

This is certainly not a bad suggestion, but it does require quite some work to implement since it requires changes not only to the main config file parsing code, but also to e.g. the CONFIG command, the Configuration Tool, the Windows installer, and so on. For example, when you used layered config files and made some changes and want to write back to the configuration via CONFIG command or Configuration Tool, will they write to a single config file, or also layered ones? If they write to a single config file, then the layered structure will no longer exists; on the other hand, if you want them to also write to layered config files, then how to determine which config file each config option will be written to? Apparently, some important decisions have to be made before any attempts to implement such a structure.

For the environment variables, the %BLASTER% variable is a standard environment variable in DOS with a Sound Blaster card. On the other hand, I don't think %CPU% variable is a standard DOS environment variable. However, you can manually set environment variables in [config] or [autoexec] section, which will then be seen inside the DOS emulation.

As for the Z drive, you can currently add your own files by putting them in the drivez directory of the DOSBox-X program folder.

joncampbell123 commented 2 years ago

Currently if multiple conf files are needed, they're given sequentially on the DOSBox command line.

I noticed GOG.COM likes to do that when you buy DOS games on their site. Some of their combinations let you choose between networked and non-networked gameplay.

runarorested commented 2 years ago

@joncampbell 123I've been experimenting with chaining multiple .conf files as you said. Right now I'm using something like this:

`@ECHO OFF

SET DOSBOX_PATH=%~dp0 SET DOSBOX_CONFIGS=%~dp0configs

"%DOSBOX_PATH%dosbox-x.exe" ^ --conf "%DOSBOX_CONFIGS%\system.conf" ^ --conf "%DOSBOX_CONFIGS%\systems\generic_i80286_pcclone.conf" ^ --conf "%DOSBOX_CONFIGS%\hardware\cpu_speed16mhz.conf" ^ --conf "%DOSBOX_CONFIGS%\hardware\math_nomath.conf" ^ --conf "%DOSBOX_CONFIGS%\hardware\keyboard_auto.conf" ^ --conf "%DOSBOX_CONFIGS%\hardware\mouse_serial1.conf" ^ --conf "%DOSBOX_CONFIGS%\hardware\mouse_msmouse_2btn.conf" ^ --conf "%DOSBOX_CONFIGS%\hardware\video_vga_pure.conf" ^ --conf "%DOSBOX_CONFIGS%\hardware\audio_mt-32.conf" ^ --conf "%DOSBOX_CONFIGS%\gog_drive.conf" ^ --c "@CD \wax" --c "@wax.bat" --fastlaunch --exit exit`

While not having includes makes me having to split certain devices setup in multiple files (like mouse, split in physical characteristics (msmouse_2btn) and connection type (serial_1)), also good chaining in autoexec.bat and config.sys allow me to load the mouse drivers for the proper setup.

This example setup mimics a real world setup I owned: An Amstrad 3286, with a Intel 80286 at 16MHz, a Genius 3 button serial mouse in Microsoft mode (2 buttons working only), a generic Trident VGA with only 256KB of RAM, Pc Speaker and a MIDI I/O port card connected to an old professional Casio keyboard that we sometimes used as an external MIDI sound module instead of a much more expensive MT-32 or similar.

Still, some things would be way easier or at least more portable, if we could use system variables in conf files, mainly to specify paths for shared files. If I could do that, I would not need to use cmd batch files. Instead I would create single pif/lnk files with proper icons. Later pasing said variables to the DOS enviroment can be done with another base conf file, helping mount and set up the system.

Trying up this led me to a couple of bugs/strange behaviours:

  1. I do not know if the 2 button/3 button mice are microsoft mouse or pc mouse style. I do not recall pc mouse style beyond 3 buttons. But taking into account that old software distinguished them, maybe there should be different options. I remember making a BASICA program to read the port, and the two standards had different binary sequences transmitted. I do remember having to reboot when I switched the mouse from ms mode to pc mouse mode and back, for the genius mouse driver to reload properly, so I could use Windows 3.0 and Deluxe Paint II, or some CAD program and the vectorial drawing program included with the mouse.

  2. The Int33 virtual driver does not always work correctly. If you do set int33=true and the mouse is serial, dosbox hangs booting up, instead of silently fail and not enabling int33. So I've disabled it and use a real mouse driver like qtmouse.

  3. The folder drivez (the Z drive of the dosbox) does not work like normal mounted folders. As a result of being a mixture of a real folder and virtual folders for internal commands, it does not allow to view multiple subdirectory levels, which it is a bother when you want to create a directory structure for drivers, like Z:\drivers\qtmouse\bin\qtm.exe. It does show the first level directories, Z:\drivers\, and the files inside it, but it appears empty of subdirectories. You can mount it as a different drive, like y:, and it works without problems then, but the idea would be to make Z: a single service drive, encompassing everything tool possible.