Skip to content

Commit

Permalink
Add multiply setting to mochadoom.cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborbata committed Oct 12, 2023
1 parent 5f34a8d commit e29f4bf
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 22 deletions.
1 change: 1 addition & 0 deletions mochadoom.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ fuzz_mix false
greyscale_filter Luminance
line_of_sight Vanilla
mb_used 2
multiply 3
parallelism_patch_columns 0
parallelism_realcolor_tint 16
reconstruct_savegame_pointers true
Expand Down
4 changes: 2 additions & 2 deletions src/awt/EventObserver.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ protected void modifyCursor(final AWTEvent event) {
* - Good Sign 2017/04/24
*/
protected void centreCursor(final AWTEvent event) {
final int centreX = component.getWidth() >> 1;
final int centreY = component.getHeight() >> 1;
if (component.isShowing()) {
int centreX = component.getWidth() >> 1;
int centreY = component.getHeight() >> 1;
MOUSE_ROBOT.ifPresent(rob -> mouseEvent.resetIn(rob, component.getLocationOnScreen(), centreX, centreY));
}
modifyCursor(event);
Expand Down
2 changes: 1 addition & 1 deletion src/doom/DoomMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -2681,7 +2681,7 @@ public DoomMain() throws IOException {
// TODO: find out if we have requests for a specific resolution,
// and try honouring them as closely as possible.
// 23/5/2011: Experimental dynamic resolution subsystem
this.vs = VisualSettings.parse(cVarManager);
this.vs = VisualSettings.parse(cVarManager, CM);
this.spriteManager = new SpriteManager<>(this);

// Heads-up, Menu, Level Loader
Expand Down
2 changes: 1 addition & 1 deletion src/i/Strings.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public final class Strings {

public static final String MOCHA_DOOM_TITLE = "Mocha Doom Alpha 1.6.8";
public static final String MOCHA_DOOM_TITLE = "Mocha Doom Alpha 1.6.9";

public static final String MODIFIED_GAME_TITLE = "Modified game alert";

Expand Down
3 changes: 2 additions & 1 deletion src/m/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ public enum Settings {
parallelism_patch_columns(FILE_MOCHADOOM, 0), // When drawing screen graphics patches, this speeds up column drawing, <= 0 is serial
greyscale_filter(FILE_MOCHADOOM, GreyscaleFilter.Luminance), // Used for FUZZ effect or with -greypal comand line argument (for test)
scene_renderer_mode(FILE_MOCHADOOM, SceneRendererMode.Serial), // In vanilla, scene renderer is serial. Parallel can be faster
reconstruct_savegame_pointers(FILE_MOCHADOOM, true); // In vanilla, infighting targets are not restored on savegame load
reconstruct_savegame_pointers(FILE_MOCHADOOM, true), // In vanilla, infighting targets are not restored on savegame load
multiply(FILE_MOCHADOOM, 3); // Multiplies the base resolution by n times. Acceptable values are 1-5.

public final static Map<Files, EnumSet<Settings>> SETTINGS_MAP = new HashMap<>();

Expand Down
45 changes: 28 additions & 17 deletions src/v/scale/VisualSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,37 @@

import doom.CVarManager;
import doom.CommandVariable;
import doom.ConfigManager;
import m.Settings;

public class VisualSettings {

/** Default video scale is "triple vanilla: 3 x (320 x 200) */
public final static VideoScale vanilla = new VideoScaleInfo(1.0f);
public final static VideoScale double_vanilla = new VideoScaleInfo(2.0f);
public final static VideoScale triple_vanilla = new VideoScaleInfo(3.0f);
public final static VideoScale default_scale = triple_vanilla;
/** Default video scale is "triple VANILLA: 3 x (320 x 200) */
public static final VideoScale VANILLA = new VideoScaleInfo(1.0f);
public static final VideoScale DOUBLE_VANILLA = new VideoScaleInfo(2.0f);
public static final VideoScale TRIPLE_VANILLA = new VideoScaleInfo(3.0f);
public static final VideoScale DEFAULT_SCALE = TRIPLE_VANILLA;

/** Parses the command line for resolution-specific commands, and creates
* an appropriate IVideoScale object.
*
* @param CM
* @return
private static final int SCALE_MAX = 5;

/**
* Parses the command line for resolution-specific commands, and creates
* an appropriate IVideoScale object.
*
* @param CVM the command line config manager
* @param CM the config manager
* @return the video scale info instance
*/
public final static VideoScale parse(CVarManager CVM) {
public final static VideoScale parse(CVarManager CVM, ConfigManager CM) {

{ // check multiply
// -multiply parameter defined from linux doom.
// It gets priority over all others, if present.
final int multiply = CVM.get(CommandVariable.MULTIPLY, Integer.class, 0).orElse(-1);

// If -multiply was successful, trump any others.
// Implied to be a solid multiple of the vanilla resolution.
if (multiply > 0 && multiply <= 5) {
// Implied to be a solid multiple of the VANILLA resolution.
if (multiply > 0 && multiply <= SCALE_MAX) {
return new VideoScaleInfo(multiply);
}
} // forget multiply
Expand All @@ -56,24 +62,29 @@ public final static VideoScale parse(CVarManager CVM) {

// Nothing to do?
if (height == -1 && width == -1) {
return default_scale;
// check multiply from mochadoom settings
int multiply = CM.getValue(Settings.multiply, Integer.class);
if (multiply > 0 && multiply <= SCALE_MAX) {
return new VideoScaleInfo(multiply);
}
return DEFAULT_SCALE;
}

// Break them down to the nearest multiple of the base width or height.
mulx = Math.round((float) width / VideoScale.BASE_WIDTH);
muly = Math.round((float) height / VideoScale.BASE_HEIGHT);

// Do not accept zero or sub-vanilla resolutions
// Do not accept zero or sub-VANILLA resolutions
if (mulx > 0 || muly > 0) {
// Use the maximum multiplier. We don't support skewed
// aspect ratios yet.
mulf = Math.max(mulx, muly);
if (mulf >= 1 && mulf <= 5) {
if (mulf >= 1 && mulf <= SCALE_MAX) {
return new VideoScaleInfo(mulf);
}
}

// In all other cases...
return default_scale;
return DEFAULT_SCALE;
}
}

0 comments on commit e29f4bf

Please sign in to comment.