Skip to content

Commit

Permalink
Add classic controls configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborbata committed Sep 27, 2023
1 parent 80ee7ea commit 332573c
Show file tree
Hide file tree
Showing 4 changed files with 256 additions and 43 deletions.
134 changes: 134 additions & 0 deletions CONFIG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Configuration file

The Doom configuration file is a text file which holds settings set by setup.exe and from inside the game and its menus.
The file is normally named `default.cfg`, but the `-config` command line parameter can be used to specify an alternate file to use.

The file takes the format of a list of configuration settings, with each line of the form: `<name> <value>`

## Settings

### Display

* `screenblocks`
Controls the screensize, ranging from 3–11. A value of 10 gives a fullscreen window with the status bar, while 11 gives fullscreen without status bar. The default value is 9.
* `detaillevel`
Boolean value which controls the resolution of the screen. The logic here is inverted: 0 is high resolution, while 1 is low resolution.
* `usegamma`
Gamma correction setting. This ranges from 0–4, with 0 representing no gamma correction, while 4 gives maximum gamma correction. The default value is 0.

### Joystick

* `use_joystick`
Boolean value used to control whether the joystick is enabled. Default is 0 (off).
* `joyb_fire`
Joystick button used to make the player attack.
* `joyb_use`
Joystick button used to make the player "use" (activate switches, open doors, etc).
* `joyb_speed`
Joystick button used to make the player run. Can also be used to activate always run.
* `joyb_strafe`
Joystick button used to make the player strafe.

### Keyboard

* `key_right`
Keyboard scan code of the key used to turn the player to the right.
* `key_left`
Keyboard scan code of the key used to turn the player to the left.
* `key_up`
Keyboard scan code of the key used to move the player forward.
* `key_down`
Keyboard scan code of the key used to move the player backwards.
* `key_strafeleft`
Keyboard scan code of the key used to make the player strafe left.
* `key_straferight`
Keyboard scan code of the key used to make the player strafe right.
* `key_fire`
Keyboard scan code of the key used to make the player attack.
* `key_use`
Keyboard scan code of the "use" key (key used to open doors, activate switches, etc).
* `key_strafe`
Keyboard scan code of the key used to make the player strafe rather than turn.
* `key_speed`
Keyboard scan code of the key used to make the player run.

### Mouse

* `use_mouse`
Boolean value used to control whether the mouse is enabled. Default is 1 (on).
* `mouseb_fire`
Mouse button used to make the player attack.
* `mouseb_strafe`
Mouse button used to make the player strafe.
* `mouseb_forward`
Mouse button used to make the player move forward.
* `mouse_sensitivity`
Numerical value storing the value of the mouse sensitivity setting. The default value is "5".

### Sound

* `sfx_volume`
The volume of sound effects, ranging from 0–15. The default is 8.
* `music_volume`
The volume of the background music, ranging from 0–15. The default is 8.
* `snd_channels`
The number of sound channels to use. The default is 3.
* `snd_musicdevice`
Numeric value indicating which kind of music card is installed.
0 None
2 Adlib
3 Sound Blaster
4 Pro Audio Spectrum
5 Gravis UltraSound
6 WaveBlaster
7 Sound Canvas
8 General MIDI
9 Soud Blaster AWE32
* `snd_sfxdevice`
Numeric value indicating which kind of card to use for sound effects.
0 None
1 PC Speaker
2 Sound Blaster
3 Pro Audio Spectrum
4 Gravis UltraSound
* `snd_sbport`
I/O Port to use to access the soundblaster card.
* `snd_sbirq`
IRQ to use to access the soundblaster card.
* `snd_sbdma`
DMA channel to use when accessing the soundblaster card.
* `snd_mport`
I/O Port to use to access the music card.

### Other

* `show_messages`
Boolean value which controls whether messages are displayed in the heads up display. The default is 1 (on)
* `chatmacro0`
Multiplayer chat macro sent when alt+0 is pressed.
* `chatmacro1`
Multiplayer chat macro sent when alt+1 is pressed.
* `chatmacro2`
Multiplayer chat macro sent when alt+2 is pressed.
* `chatmacro3`
Multiplayer chat macro sent when alt+3 is pressed.
* `chatmacro4`
Multiplayer chat macro sent when alt+4 is pressed.
* `chatmacro5`
Multiplayer chat macro sent when alt+5 is pressed.
* `chatmacro6`
Multiplayer chat macro sent when alt+6 is pressed.
* `chatmacro7`
Multiplayer chat macro sent when alt+7 is pressed.
* `chatmacro8`
Multiplayer chat macro sent when alt+8 is pressed.
* `chatmacro9`
Multiplayer chat macro sent when alt+9 is pressed.

### Additional settings

The `joyb_speed` setting can be set to 29 to make the player always run in most Doom versions and Doom engine games. Originally it was discovered that setting the value to 31 would produce the effect, but that value does not work on the engines of some games, such as Final Doom, Heretic, and Strife. Doom v1.0 is noteworthy in that neither 29 nor 31 enables autorun; the only currently known working value is 2029.

The configuration file can be used to set the mouse sensitivity above the regular maximum of 9, though note that setting it to a value higher than 30 will make the game terminate upon entering the options menu.

The configuration file can be rearranged and comments added; however, the game will overwrite any such changes on exit. The file can be made read-only to avoid this problem.
59 changes: 46 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,66 @@
# Mocha Doom

![Top Language](https://img.shields.io/github/languages/top/axdoomer/mochadoom.svg?style=flat)
![Code Size](https://img.shields.io/github/languages/code-size/axdoomer/mochadoom.svg?style=flat)
![License](https://img.shields.io/github/license/axdoomer/mochadoom.svg?style=flat&logo=gnu)
![Top Language](https://img.shields.io/github/languages/top/gaborbata/mochadoom.svg?style=flat)
![Code Size](https://img.shields.io/github/languages/code-size/gaborbata/mochadoom.svg?style=flat)
![License](https://img.shields.io/github/license/gaborbata/mochadoom.svg?style=flat&logo=gnu)
[![Java CI with Gradle](https://github.com/gaborbata/mochadoom/workflows/Java%20CI%20with%20Gradle/badge.svg)](https://github.com/gaborbata/mochadoom/actions/workflows/gradle.yml)

Mocha Doom is a pure Java Doom source port. Most of the hard work of porting Doom to Java has already been done, thanks to Velktron (Maes), but he has stopped working on it in 2013. Although the port is almost complete, some work remains to do, most importantly the network code for the multiplayer is missing. Features like support for the Boom format would also be great. I have decided to continue the development in my free time and fix some bugs.
Mocha Doom is a pure Java Doom source port. Most of the hard work of porting Doom to Java has already been done, thanks to Velktron (Maes), but he has stopped working on it in 2013. Although the port is almost complete, some work remains to do, most importantly the network code for the multiplayer is missing.

Mocha Doom can play original variants of Doom. If you don't own any, you may download the [Shareware](http://cdn.debian.net/debian/pool/non-free/d/doom-wad-shareware/doom-wad-shareware_1.9.fixed.orig.tar.gz) version of Doom, extract it and copy the `DOOM1.WAD` file into your Mocha Doom directory.

# How to run

1. Open the project with Eclipse or NetBeans
2. Delete every file that has errors (if any)
3. Build and run the project
## IDE

1. Open the project with IntelliJ IDEA, Eclipse or NetBeans
2. Build and run the project

## Advanced users
## Linux shell scripts

On Linux, two different scripts can be used.

1. `build-and-run.sh` which will build Mocha Doom and run it. You can use it as such: `./build-and-run.sh -iwad ~/DOOM2.WAD`. This is the preferred way to quickly test changes for developers.
2. `build-jar.sh` which will build a JAR file. You can then run the JAR file as such: `java -jar mochadoom.jar -iwad ~/DOOM2.WAD`. This is the preferred way for distributing a Mocha Doom executable.
1. `build-and-run.sh` which will build Mocha Doom and run it. You can use it as such: `./build-and-run.sh -iwad ~/DOOM1.WAD`. This is the preferred way to quickly test changes for developers.
2. `build-jar.sh` which will build a JAR file. You can then run the JAR file as such: `java -jar mochadoom.jar -iwad ~/DOOM1.WAD`. This is the preferred way for distributing a Mocha Doom executable.

### Build with Gradle
## Gradle

[Gradle](https://gradle.org/) is a cross-platform build tool, which can be also used to run and build Mocha Doom.
First of all, you have to install Gradle following its [installation notes](https://gradle.org/install/). After that you can use the following commands:
First of all, you have to install Gradle following its [installation notes](https://gradle.org/install/). After that you can use one of the following commands:

* Run Mocha Doom: `gradle clean run`
* Build a JAR file: `gradle clean build`

This creates a JAR file in the `build/libs/` folder.
You can then run the JAR file as such: `java -jar build/libs/mochadoom.jar -iwad ~/DOOM.WAD`.
You can then run the JAR file as such: `java -jar build/libs/mochadoom.jar -iwad ~/DOOM1.WAD`.

## Launch Doom with classic controls

You can use `classic.cfg` configuration in order to have the old-school classic key controls, e.g.

`java -jar mochadoom.jar -config classic.cfg -iwad ~/DOOM1.WAD`

or

`gradle run --args="-config classic.cfg -iwad ~/DOOM1.WAD"`

The configuration has the following differences:

| Configuration | Default | Classic |
| --------------- | ---------------- | ------------------------------ |
| key_right | 77 (right arrow) | 77 (right arrow) |
| key_left | 75 (left arrow) | 75 (left arrow) |
| key_up | 17 (W) | 72 (up arrow) |
| key_down | 31 (S) | 80 (down arrow) |
| key_strafeleft | 30 (A) | 51 (Alt+left arrow) or comma |
| key_straferight | 32 (D) | 52 (Alt+right arrow) or period |
| key_fire | 29 (Control) | 29 (Control) |
| key_use | 57 (Space) | 57 (Space) |
| key_strafe | 56 (Alt) | 56 (Alt) |
| key_speed | 54 (Shift) | 54 (Shift) |
| use_mouse | 1 (enabled) | 0 (disabled) |

Check [CONFIG.md](CONFIG.md) for more options.

# License

Expand Down
43 changes: 43 additions & 0 deletions classic.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
mouse_sensitivity 5
sfx_volume 8
music_volume 8
show_messages 1
key_right 77
key_left 75
key_up 72
key_down 80
key_strafeleft 51
key_straferight 52
key_fire 29
key_use 57
key_strafe 56
key_speed 54
use_mouse 0
mouseb_fire 0
mouseb_strafe 1
mouseb_forward 2
use_joystick 0
joyb_fire 0
joyb_strafe 1
joyb_use 3
joyb_speed 2
screenblocks 9
detaillevel 0
snd_channels 8
snd_musicdevice 3
snd_sfxdevice 3
snd_sbport 0
snd_sbirq 0
snd_sbdma 0
snd_mport 0
usegamma 0
chatmacro0 "No"
chatmacro1 "I'm ready to kick butt!"
chatmacro2 "I'm OK."
chatmacro3 "I'm not looking too good!"
chatmacro4 "Help!"
chatmacro5 "You suck!"
chatmacro6 "Next time, scumbag..."
chatmacro7 "Come here!"
chatmacro8 "I'll take care of it."
chatmacro9 "Yes"
63 changes: 33 additions & 30 deletions src/doom/DoomMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import f.EndLevel;
import f.Finale;
import f.Wiper;
import g.Signals;
import static g.Signals.ScanCode.*;
import hu.HU;
import i.DiskDrawer;
Expand Down Expand Up @@ -1289,21 +1290,7 @@ public boolean Responder(event_t ev) {
ev.withKey(sc -> {
gamekeydown[sc.ordinal()] = true;
if (vanillaKeyBehavior) {
switch(sc) {
case SC_LSHIFT:
case SC_RSHIFT:
gamekeydown[SC_RSHIFT.ordinal()] = gamekeydown[SC_LSHIFT.ordinal()] = true;
break;
case SC_LCTRL:
case SC_RCTRL:
gamekeydown[SC_RCTRL.ordinal()] = gamekeydown[SC_LCTRL.ordinal()] = true;
break;
case SC_LALT:
case SC_RALT:
gamekeydown[SC_RALT.ordinal()] = gamekeydown[SC_LALT.ordinal()] = true;
break;
default: break;
}
handleVanillaKeys(sc, true);
}
});
return true; // eat key down events
Expand All @@ -1318,21 +1305,7 @@ public boolean Responder(event_t ev) {
ev.withKey(sc -> {
gamekeydown[sc.ordinal()] = false;
if (vanillaKeyBehavior) {
switch(sc) {
case SC_LSHIFT:
case SC_RSHIFT:
gamekeydown[SC_RSHIFT.ordinal()] = gamekeydown[SC_LSHIFT.ordinal()] = false;
break;
case SC_LCTRL:
case SC_RCTRL:
gamekeydown[SC_RCTRL.ordinal()] = gamekeydown[SC_LCTRL.ordinal()] = false;
break;
case SC_LALT:
case SC_RALT:
gamekeydown[SC_RALT.ordinal()] = gamekeydown[SC_LALT.ordinal()] = false;
break;
default: break;
}
handleVanillaKeys(sc, false);
}
});
return false; // always let key up events filter down
Expand Down Expand Up @@ -1368,6 +1341,36 @@ public boolean Responder(event_t ev) {
return false;
}

private void handleVanillaKeys(Signals.ScanCode sc, boolean keyDown) {
switch(sc) {
case SC_LSHIFT:
case SC_RSHIFT:
gamekeydown[SC_RSHIFT.ordinal()] = gamekeydown[SC_LSHIFT.ordinal()] = keyDown;
break;
case SC_LCTRL:
case SC_RCTRL:
gamekeydown[SC_RCTRL.ordinal()] = gamekeydown[SC_LCTRL.ordinal()] = keyDown;
break;
case SC_LALT:
case SC_RALT:
gamekeydown[SC_RALT.ordinal()] = gamekeydown[SC_LALT.ordinal()] = keyDown;
break;
case SC_UP:
gamekeydown[SC_NUMKEY8.ordinal()] = keyDown;
break;
case SC_DOWN:
gamekeydown[SC_NUMKEY2.ordinal()] = keyDown;
break;
case SC_LEFT:
gamekeydown[SC_NUMKEY4.ordinal()] = keyDown;
break;
case SC_RIGHT:
gamekeydown[SC_NUMKEY6.ordinal()] = keyDown;
break;
default: break;
}
}

private final String turbomessage="is turbo!";

/**
Expand Down

0 comments on commit 332573c

Please sign in to comment.